Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java284
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiFactory.java142
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/EclipseLinkPersistenceUnitCachingEditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/PersistenceXmlCachingTab.java)60
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/EclipseLinkPersistenceUnitCachingEditorPageDefinition.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/EclipseLinkPersistenceUnitConnectionEditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/PersistenceXmlConnectionTab.java)80
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/EclipseLinkPersistenceUnitConnectionEditorPageDefinition.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/EclipseLinkPersistenceUnitCustomizationEditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/PersistenceXmlCustomizationTab.java)85
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/EclipseLinkPersistenceUnitCustomizationEditorPageDefinition.java76
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralEditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralTab.java)80
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralEditorPageDefinition.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitMappingFilesComposite.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/EclipseLinkPersistenceUnitOptionsEditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/PersistenceXmlOptionsTab.java)75
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/EclipseLinkPersistenceUnitOptionsEditorPageDefinition.java60
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLink2_0PersistenceXmlUiFactory.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLink2_4PersistenceXmlUiFactory.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCaching2_0EditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlCaching2_0Tab.java)91
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCaching2_0EditorPageDefinition.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCustomization2_0EditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlCustomization2_0Tab.java)14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCustomization2_0EditorPageDefinition.java76
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_0EditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlOptions2_0Tab.java)992
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_0EditorPageDefinition.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_4EditorPage.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_4EditorPageDefinition.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlOptions2_4Tab.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_persistence.properties5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceXmlResourceUiDefinition.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/ResourceUiDefinition.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/editors/JpaEditorPageDefinition.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/editors/JpaPageComposite.java)28
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractResourceUiDefinition.java57
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/JpaXmlEditor.java511
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceEditor.java435
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaUiFactory.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/Generic2_0PersistenceXmlUiFactory.java82
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnit2_0OptionsEditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/GenericPersistenceUnit2_0OptionsTab.java)1087
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitConnection2_0EditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/GenericPersistenceUnit2_0ConnectionTab.java)527
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitConnection2_0EditorPageDefinition.java71
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitEditorPageDefinition.java76
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitOptions2_0EditorPageDefinition.java70
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/AbstractPersistenceXmlResourceUiDefinition.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceUnitGeneralTab.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceUnitMappingFilesComposite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceXmlUiFactory.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/JptUiPersistenceMessages.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionEditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionTab.java)490
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionEditorPageDefinition.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralEditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralTab.java)322
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralEditorPageDefinition.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitJarFilesComposite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesEditorPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesTab.java)803
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesEditorPageDefinition.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiFactory.java38
62 files changed, 4047 insertions, 3785 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java
index 8f2dc5b95b..12be6ef798 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java
@@ -116,7 +116,7 @@ public abstract class Pane<T extends Model>
/**
* The subject of this pane.
*/
- private PropertyValueModel<T> subjectHolder;
+ private PropertyValueModel<T> subjectModel;
/**
* The collection of registered sub-panes will be automatically notified
@@ -266,19 +266,19 @@ public abstract class Pane<T extends Model>
/**
* Creates a new <code>Pane</code>.
*
- * @param subjectHolder The holder of this pane's subject
+ * @param subjectModel The holder of this pane's subject
* @param parent The parent container
* @param widgetFactory The factory used to create various common widgets
*
* @category Constructor
*/
protected Pane(
- PropertyValueModel<? extends T> subjectHolder,
+ PropertyValueModel<? extends T> subjectModel,
Composite parent,
WidgetFactory widgetFactory) {
super();
- this.initialize(subjectHolder, this.buildNonNullEnabledModel(subjectHolder), widgetFactory);
+ this.initialize(subjectModel, this.buildNonNullEnabledModel(subjectModel), widgetFactory);
if (this.addsComposite()) {
this.container = this.addComposite(parent);
this.initializeLayout(this.container);
@@ -317,8 +317,8 @@ public abstract class Pane<T extends Model>
this.populate();
}
- protected PropertyValueModel<Boolean> buildNonNullEnabledModel(PropertyValueModel<? extends T> subjectHolder) {
- return new TransformationPropertyValueModel<T, Boolean>(subjectHolder) {
+ protected PropertyValueModel<Boolean> buildNonNullEnabledModel(PropertyValueModel<? extends T> subjectModel) {
+ return new TransformationPropertyValueModel<T, Boolean>(subjectModel) {
@Override
protected Boolean transform(T value) {
return Boolean.valueOf(value != null);
@@ -331,13 +331,13 @@ public abstract class Pane<T extends Model>
@SuppressWarnings("unchecked")
private void initialize(
- PropertyValueModel<? extends T> subjectHolder,
+ PropertyValueModel<? extends T> subjectModel,
PropertyValueModel<Boolean> enabledModel,
WidgetFactory widgetFactory) {
- Assert.isNotNull(subjectHolder, "The subject holder cannot be null");
+ Assert.isNotNull(subjectModel, "The subject model cannot be null");
- this.subjectHolder = (PropertyValueModel<T>) subjectHolder;
+ this.subjectModel = (PropertyValueModel<T>) subjectModel;
this.widgetFactory = widgetFactory;
this.enabledModel = enabledModel;
this.subPanes = new ArrayList<Pane<?>>();
@@ -588,187 +588,6 @@ public abstract class Pane<T extends Model>
}
/**
- * Creates a new <code>Section</code> that can be collapsed. A sub-pane is
- * automatically added as its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSection(
- Composite container,
- String sectionText) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- new SimplePropertyValueModel<Boolean>(Boolean.FALSE));
- }
-
- /**
- * Creates a new <code>Section</code> that can be collapsed. A sub-pane is
- * automatically added as its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param description The section's description or <code>null</code> if none
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSection(Composite container,
- String sectionText,
- String description) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- description,
- new SimplePropertyValueModel<Boolean>(Boolean.FALSE)
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param type The type of section to create
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- private Composite addCollapsibleSection(Composite container,
- String sectionText,
- int type,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- return addCollapsibleSection(container, sectionText, null, type, expandedStateHolder);
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param description The section's description or <code>null</code> if none
- * was provided
- * @param type The type of section to create
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- private Composite addCollapsibleSection(Composite container,
- String sectionText,
- String description,
- int type,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- Composite subPane = this.addSection(
- container,
- sectionText,
- description,
- ExpandableComposite.TWISTIE | type
- );
-
- Section section = (Section) subPane.getParent();
-
- expandedStateHolder.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- buildExpandedStateChangeListener(section)
- );
-
- section.setExpanded(
- expandedStateHolder.getValue() != null ? expandedStateHolder.getValue() : true
- );
-
- return subPane;
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSection(Composite container,
- String sectionText,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE,
- expandedStateHolder
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param description The section's description or <code>null</code> if none
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSection(Composite container,
- String sectionText,
- String description,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- description,
- ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE,
- expandedStateHolder
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client which can be typed cast directly as a <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSubSection(Composite container,
- String sectionText,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- SWT.NULL,
- expandedStateHolder
- );
- }
-
- /**
* Creates a new non-editable <code>Combo</code>.
*
* @param container The parent container
@@ -1039,22 +858,6 @@ public abstract class Pane<T extends Model>
return viewer;
}
- private PropertyChangeListener buildExpandedStateChangeListener(final Section section) {
- return new SWTPropertyChangeListenerWrapper(buildExpandedStateChangeListener_(section));
- }
-
- private PropertyChangeListener buildExpandedStateChangeListener_(final Section section) {
- return new PropertyChangeListener() {
- public void propertyChanged(final PropertyChangeEvent e) {
- Boolean value = (Boolean) e.getNewValue();
- if (value == null) {
- value = Boolean.TRUE;
- }
- section.setExpanded(value);
- }
- };
- }
-
/**
* Creates a new <code>Hyperlink</code> that will invoked the given
* <code>Runnable</code> when selected. The given action is always invoked
@@ -1655,46 +1458,6 @@ public abstract class Pane<T extends Model>
*
* @param container The container of the new widget
* @param sectionText The text of the new section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addSection(Composite container,
- String sectionText) {
-
- return this.addSection(
- container,
- sectionText,
- ExpandableComposite.TITLE_BAR
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param type The type of section to create
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- private Composite addSection(Composite container,
- String sectionText,
- int type) {
-
- return this.addSection(container, sectionText, null, type);
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
* @param description The section's description
* @return The <code>Section</code>'s sub-pane
*
@@ -1721,7 +1484,6 @@ public abstract class Pane<T extends Model>
* @param description The section's description or <code>null</code> if none
* was provider
* @param type The type of section to create
- * @param expandedStateHolder The holder of the boolean that will dictate
* when to expand or collapse the section
* @return The <code>Section</code>'s sub-pane
*
@@ -1881,26 +1643,6 @@ public abstract class Pane<T extends Model>
}
/**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client which can be typed cast directly as a <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addSubSection(Composite container,
- String sectionText) {
-
- return this.addCollapsibleSubSection(
- container,
- sectionText,
- new SimplePropertyValueModel<Boolean>(Boolean.TRUE)
- );
- }
-
- /**
* Creates a new table.
*
* @param container The parent container
@@ -2415,7 +2157,7 @@ public abstract class Pane<T extends Model>
}
private void engageSubjectHolder() {
- this.subjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
+ this.subjectModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
}
/**
@@ -2459,7 +2201,7 @@ public abstract class Pane<T extends Model>
}
private void disengageSubjectHolder() {
- this.subjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
+ this.subjectModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
}
/**
@@ -2484,7 +2226,7 @@ public abstract class Pane<T extends Model>
* @category Populate
*/
protected final PropertyValueModel<T> getSubjectHolder() {
- return this.subjectHolder;
+ return this.subjectModel;
}
/**
@@ -2626,7 +2368,7 @@ public abstract class Pane<T extends Model>
* @category Populate
*/
public T getSubject() {
- return this.subjectHolder.getValue();
+ return this.subjectModel.getValue();
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java
index c56f51830e..efa6c6fb81 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java
@@ -9,18 +9,25 @@
******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence;
+import java.util.List;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.ui.internal.jface.SimpleItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXmlDefinition;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.caching.EclipseLinkPersistenceUnitCachingEditorPageDefinition;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.connection.EclipseLinkPersistenceUnitConnectionEditorPageDefinition;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.customization.EclipseLinkPersistenceUnitCustomizationEditorPageDefinition;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.general.EclipseLinkPersistenceUnitGeneralEditorPageDefinition;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options.EclipseLinkPersistenceUnitOptionsEditorPageDefinition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.structure.EclipseLinkPersistenceStructureItemContentProviderFactory;
import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.internal.persistence.AbstractPersistenceXmlResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceXmlUiFactory;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.AbstractResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.structure.PersistenceStructureItemLabelProviderFactory;
public class EclipseLinkPersistenceXmlUiDefinition
- extends AbstractPersistenceXmlResourceUiDefinition
+ extends AbstractResourceUiDefinition
{
// singleton
private static final ResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXmlUiDefinition();
@@ -43,8 +50,13 @@ public class EclipseLinkPersistenceXmlUiDefinition
@Override
- protected PersistenceXmlUiFactory buildPersistenceXmlUiFactory() {
- return new EclipseLinkPersistenceXmlUiFactory();
+ protected void addEditorPageDefinitionsTo(List<JpaEditorPageDefinition> definitions) {
+ definitions.add(EclipseLinkPersistenceUnitGeneralEditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitConnectionEditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitCustomizationEditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitCachingEditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitOptionsEditorPageDefinition.instance());
+ definitions.add(PersistenceUnitPropertiesEditorPageDefinition.instance());
}
public boolean providesUi(JptResourceType resourceType) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiFactory.java
deleted file mode 100644
index e18c095491..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiFactory.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 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.jpa.eclipselink.ui.internal.persistence;
-
-import java.util.ArrayList;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Caching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Connection;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Customization;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.caching.PersistenceXmlCachingTab;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.connection.PersistenceXmlConnectionTab;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.customization.PersistenceXmlCustomizationTab;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.general.EclipseLinkPersistenceUnitGeneralTab;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options.PersistenceXmlOptionsTab;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesTab;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceXmlUiFactory;
-import org.eclipse.swt.widgets.Composite;
-
-public class EclipseLinkPersistenceXmlUiFactory implements PersistenceXmlUiFactory
-{
- // ********** constructors **********
-
- public EclipseLinkPersistenceXmlUiFactory() {
- super();
- }
-
- // **************** persistence unit composites ****************************
-
- public ListIterator<JpaPageComposite> createPersistenceUnitComposites(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- ArrayList<JpaPageComposite> pages = new ArrayList<JpaPageComposite>(8);
-
- pages.add(this.buildGeneralTab(subjectHolder, parent, widgetFactory));
- pages.add(this.buildConnectionTab(subjectHolder, parent, widgetFactory));
- pages.add(this.buildCustomizationTab(subjectHolder, parent, widgetFactory));
- pages.add(this.buildCachingTab(subjectHolder, parent, widgetFactory));
- pages.add(this.buildOptionsTab(subjectHolder, parent, widgetFactory));
- pages.add(this.buildPropertiesTab(subjectHolder, parent, widgetFactory));
-
- return pages.listIterator();
- }
-
- // ********** persistence unit tabs **********
-
- protected EclipseLinkPersistenceUnitGeneralTab buildGeneralTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- return new EclipseLinkPersistenceUnitGeneralTab(subjectHolder, parent, widgetFactory);
- }
-
- protected PersistenceXmlConnectionTab<? extends Connection> buildConnectionTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- return new PersistenceXmlConnectionTab<Connection>( this.buildConnectionHolder(subjectHolder), parent, widgetFactory);
- }
-
- protected PersistenceXmlCustomizationTab<? extends Customization> buildCustomizationTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- return new PersistenceXmlCustomizationTab<Customization>(this.buildCustomizationHolder(subjectHolder), parent, widgetFactory);
- }
-
- protected PersistenceXmlCachingTab<? extends Caching> buildCachingTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
- PropertyValueModel<Caching> cachingHolder = this.buildCachingHolder(subjectHolder);
-
- return new PersistenceXmlCachingTab<Caching>(cachingHolder, parent, widgetFactory);
- }
-
- protected PersistenceXmlOptionsTab<? extends PersistenceUnit> buildOptionsTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- return new PersistenceXmlOptionsTab<PersistenceUnit>(subjectHolder, parent, widgetFactory);
- }
-
- protected PersistenceUnitPropertiesTab buildPropertiesTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- return new PersistenceUnitPropertiesTab(subjectHolder, parent, widgetFactory);
- }
-
- // ********** private methods **********
-
- private PropertyValueModel<Connection> buildConnectionHolder(
- PropertyValueModel<PersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<PersistenceUnit, Connection>(subjectHolder) {
- @Override
- protected Connection transform_(PersistenceUnit value) {
-
- return ((EclipseLinkPersistenceUnit) value).getConnection();
- }
- };
- }
-
- protected PropertyValueModel<Customization> buildCustomizationHolder(
- PropertyValueModel<PersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<PersistenceUnit, Customization>(subjectHolder) {
- @Override
- protected Customization transform_(PersistenceUnit value) {
- return ((EclipseLinkPersistenceUnit) value).getCustomization();
- }
- };
- }
-
- protected PropertyValueModel<Caching> buildCachingHolder(
- PropertyValueModel<PersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<PersistenceUnit, Caching>(subjectHolder) {
- @Override
- protected Caching transform_(PersistenceUnit value) {
- return ((EclipseLinkPersistenceUnit) value).getCaching();
- }
- };
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/PersistenceXmlCachingTab.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/EclipseLinkPersistenceUnitCachingEditorPage.java
index 80be10a55e..37b4183ff4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/PersistenceXmlCachingTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/EclipseLinkPersistenceUnitCachingEditorPage.java
@@ -10,7 +10,6 @@
package org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.caching;
import java.util.Collection;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
import org.eclipse.jpt.common.ui.internal.widgets.Pane;
@@ -19,64 +18,57 @@ import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Caching;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.FlushClearCache;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
-/**
- * PersistenceXmlCachingTab
- */
-public class PersistenceXmlCachingTab<T extends Caching>
+public class EclipseLinkPersistenceUnitCachingEditorPage<T extends Caching>
extends Pane<T>
- implements JpaPageComposite
{
- public PersistenceXmlCachingTab(
- PropertyValueModel<T> subjectHolder,
+ public EclipseLinkPersistenceUnitCachingEditorPage(
+ PropertyValueModel<T> subjectModel,
Composite parent,
WidgetFactory widgetFactory) {
- super(subjectHolder, parent, widgetFactory);
+ super(subjectModel, parent, widgetFactory);
}
- // ********** JpaPageComposite implementation **********
-
- public String getHelpID() {
- return EclipseLinkHelpContextIds.PERSISTENCE_CACHING;
- }
-
- public ImageDescriptor getPageImageDescriptor() {
- return null;
- }
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlCachingTab_title;
- }
-
-
@Override
protected void initializeLayout(Composite container) {
- container = this.addSection(
- container,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionTitle,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionDescription
- );
- container.setLayout(new GridLayout(2, false));
+ Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ section.setText(EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionTitle);
+ section.setDescription(EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionDescription);
+
+ Composite client = this.getWidgetFactory().createComposite(section);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginTop = 0;
+ layout.marginLeft = 0;
+ layout.marginBottom = 0;
+ layout.marginRight = 0;
+ client.setLayout(layout);
+ client.setLayoutData(new GridData(GridData.FILL_BOTH));
+ section.setClient(client);
// Defaults
- CacheDefaultsComposite<T> defaultsComposite = new CacheDefaultsComposite<T>(this, container);
+ CacheDefaultsComposite<T> defaultsComposite = new CacheDefaultsComposite<T>(this, client);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
defaultsComposite.getControl().setLayoutData(gridData);
// EntitiesList
- EntityListComposite<T> entitiesComposite = new EntityListComposite<T>(this, container);
+ EntityListComposite<T> entitiesComposite = new EntityListComposite<T>(this, client);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
entitiesComposite.getControl().setLayoutData(gridData);
// Flush Clear Cache
- this.addLabel(container, EclipseLinkUiMessages.PersistenceXmlCachingTab_FlushClearCacheLabel);
- this.addFlushClearCacheCombo(container);
+ this.addLabel(client, EclipseLinkUiMessages.PersistenceXmlCachingTab_FlushClearCacheLabel);
+ this.addFlushClearCacheCombo(client);
}
protected EnumFormComboViewer<Caching, FlushClearCache> addFlushClearCacheCombo(Composite container) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/EclipseLinkPersistenceUnitCachingEditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/EclipseLinkPersistenceUnitCachingEditorPageDefinition.java
new file mode 100644
index 0000000000..b2facfae40
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/caching/EclipseLinkPersistenceUnitCachingEditorPageDefinition.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+* Copyright (c) 2007, 2012 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.jpa.eclipselink.ui.internal.persistence.caching;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Caching;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class EclipseLinkPersistenceUnitCachingEditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new EclipseLinkPersistenceUnitCachingEditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private EclipseLinkPersistenceUnitCachingEditorPageDefinition() {
+ super();
+ }
+
+ public String getPageText() {
+ return EclipseLinkUiMessages.PersistenceXmlCachingTab_title;
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return null;
+ }
+
+ public String getHelpID() {
+ return EclipseLinkHelpContextIds.PERSISTENCE_CACHING;
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new EclipseLinkPersistenceUnitCachingEditorPage<Caching>(this.buildCachingModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+
+ private PropertyValueModel<Caching> buildCachingModel(PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ return new TransformationPropertyValueModel<PersistenceUnit, Caching>(this.buildPersistenceUnitModel(jpaRootStructureNodeModel)) {
+ @Override
+ protected Caching transform_(PersistenceUnit value) {
+ return ((EclipseLinkPersistenceUnit) value).getCaching();
+ }
+ };
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/PersistenceXmlConnectionTab.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/EclipseLinkPersistenceUnitConnectionEditorPage.java
index 34faa61da3..c9c373a436 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/PersistenceXmlConnectionTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/EclipseLinkPersistenceUnitConnectionEditorPage.java
@@ -10,7 +10,6 @@
package org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.connection;
import java.util.Collection;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
@@ -27,51 +26,33 @@ import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionTy
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.BatchWriting;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Connection;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
-/**
- * PersistenceXmlConnectionTab
- */
-public class PersistenceXmlConnectionTab<T extends Connection>
- extends Pane<T>
- implements JpaPageComposite
-{
- // ********** constructors/initialization **********
- public PersistenceXmlConnectionTab(
- PropertyValueModel<T> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- // ********** JpaPageComposite implementation **********
-
- public String getHelpID() {
- return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION;
- }
+public class EclipseLinkPersistenceUnitConnectionEditorPage
+ extends Pane<Connection> {
- public ImageDescriptor getPageImageDescriptor() {
- return null;
- }
+ public EclipseLinkPersistenceUnitConnectionEditorPage(
+ PropertyValueModel<Connection> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlConnectionTab_title;
+ super(subjectHolder, parent, widgetFactory);
}
-
@Override
protected void initializeLayout(Composite container) {
- container = addSection(
- container,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_sectionTitle,
- EclipseLinkUiMessages.PersistenceXmlConnectionTab_sectionDescription
- );
+ Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ section.setText(EclipseLinkUiMessages.PersistenceXmlConnectionTab_sectionTitle);
+ section.setDescription(EclipseLinkUiMessages.PersistenceXmlConnectionTab_sectionDescription);
+
+ Composite client = this.getWidgetFactory().createComposite(section);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
@@ -79,32 +60,34 @@ public class PersistenceXmlConnectionTab<T extends Connection>
layout.marginLeft = 0;
layout.marginBottom = 0;
layout.marginRight = 0;
- container.setLayout(layout);
+ client.setLayout(layout);
+ client.setLayoutData(new GridData(GridData.FILL_BOTH));
+ section.setClient(client);
//transaction type
- this.addLabel(container, EclipseLinkUiMessages.PersistenceXmlConnectionTab_transactionTypeLabel);
- this.addTransactionTypeCombo(container);
+ this.addLabel(client, EclipseLinkUiMessages.PersistenceXmlConnectionTab_transactionTypeLabel);
+ this.addTransactionTypeCombo(client);
//batch writing
- this.addLabel(container, EclipseLinkUiMessages.PersistenceXmlConnectionTab_batchWritingLabel);
- this.addBatchWritingCombo(container);
+ this.addLabel(client, EclipseLinkUiMessages.PersistenceXmlConnectionTab_batchWritingLabel);
+ this.addBatchWritingCombo(client);
//cache statements
ModifiablePropertyValueModel<Boolean> cacheStatementsHolder = buildCacheStatementsHolder();
this.addTriStateCheckBox(
- container,
+ client,
EclipseLinkUiMessages.PersistenceXmlConnectionTab_cacheStatementsLabel,
cacheStatementsHolder,
JpaHelpContextIds.PERSISTENCE_XML_CONNECTION
);
- IntegerCombo<?> combo = addCacheStatementsSizeCombo(container);
+ IntegerCombo<?> combo = addCacheStatementsSizeCombo(client);
this.installControlEnabler(cacheStatementsHolder, combo);
-
+
TriStateCheckBox nativeSqlCheckBox = this.addTriStateCheckBoxWithDefault(
- container,
+ client,
EclipseLinkUiMessages.PersistenceXmlConnectionTab_nativeSqlLabel,
this.buildNativeSqlHolder(),
this.buildNativeSqlStringHolder(),
@@ -113,8 +96,8 @@ public class PersistenceXmlConnectionTab<T extends Connection>
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
nativeSqlCheckBox.getCheckBox().setLayoutData(gridData);
-
- ConnectionPropertiesComposite<T> connectionPropertiesComposite = new ConnectionPropertiesComposite<T>(this, container);
+
+ ConnectionPropertiesComposite<Connection> connectionPropertiesComposite = new ConnectionPropertiesComposite<Connection>(this, client);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
connectionPropertiesComposite.getControl().setLayoutData(gridData);
@@ -182,7 +165,6 @@ public class PersistenceXmlConnectionTab<T extends Connection>
return this.subject.getPersistenceUnit();
}
};
-
}
private void clearJTAProperties() {
@@ -284,7 +266,7 @@ public class PersistenceXmlConnectionTab<T extends Connection>
}
};
}
-
+
private PropertyValueModel<Boolean> buildDefaultNativeSqlHolder() {
return new PropertyAspectAdapter<Connection, Boolean>(
getSubjectHolder(),
@@ -326,7 +308,7 @@ public class PersistenceXmlConnectionTab<T extends Connection>
}
};
}
-
+
private IntegerCombo<Connection> addCacheStatementsSizeCombo(Composite container) {
return new IntegerCombo<Connection>(this, container) {
@Override
@@ -343,7 +325,7 @@ public class PersistenceXmlConnectionTab<T extends Connection>
}
};
}
-
+
@Override
protected ModifiablePropertyValueModel<Integer> buildSelectedItemHolder() {
return new PropertyAspectAdapter<Connection, Integer>(getSubjectHolder(), Connection.CACHE_STATEMENTS_SIZE_PROPERTY) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/EclipseLinkPersistenceUnitConnectionEditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/EclipseLinkPersistenceUnitConnectionEditorPageDefinition.java
new file mode 100644
index 0000000000..092ff71f17
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/connection/EclipseLinkPersistenceUnitConnectionEditorPageDefinition.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2012 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.jpa.eclipselink.ui.internal.persistence.connection;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Connection;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class EclipseLinkPersistenceUnitConnectionEditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new EclipseLinkPersistenceUnitConnectionEditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private EclipseLinkPersistenceUnitConnectionEditorPageDefinition() {
+ super();
+ }
+
+ public String getPageText() {
+ return EclipseLinkUiMessages.PersistenceXmlConnectionTab_title;
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return null;
+ }
+
+ public String getHelpID() {
+ return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION;
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new EclipseLinkPersistenceUnitConnectionEditorPage(this.buildConnectionModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+
+ private PropertyValueModel<Connection> buildConnectionModel(PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ return new TransformationPropertyValueModel<PersistenceUnit, Connection>(this.buildPersistenceUnitModel(jpaRootStructureNodeModel)) {
+ @Override
+ protected Connection transform_(PersistenceUnit value) {
+ return ((EclipseLinkPersistenceUnit) value).getConnection();
+ }
+ };
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/PersistenceXmlCustomizationTab.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/EclipseLinkPersistenceUnitCustomizationEditorPage.java
index 24da558146..3a943b7bd7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/PersistenceXmlCustomizationTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/EclipseLinkPersistenceUnitCustomizationEditorPage.java
@@ -10,7 +10,6 @@
package org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.customization;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
import org.eclipse.jpt.common.ui.internal.widgets.ClassChooserPane;
@@ -23,7 +22,6 @@ import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Customization;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -34,33 +32,15 @@ import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.Section;
-/**
- * PersistenceXmlCustomizationTabItem
- */
-public class PersistenceXmlCustomizationTab<T extends Customization>
- extends Pane<T>
- implements JpaPageComposite
+public class EclipseLinkPersistenceUnitCustomizationEditorPage<T extends Customization>
+ extends Pane<T>
{
- public PersistenceXmlCustomizationTab(
- PropertyValueModel<T> subjectHolder,
+ public EclipseLinkPersistenceUnitCustomizationEditorPage(
+ PropertyValueModel<T> subjectModel,
Composite parent,
WidgetFactory widgetFactory) {
- super(subjectHolder, parent, widgetFactory);
- }
-
- // ********** JpaPageComposite implementation **********
-
- public String getHelpID() {
- return EclipseLinkHelpContextIds.PERSISTENCE_CUSTOMIZATION;
- }
-
- public ImageDescriptor getPageImageDescriptor() {
- return null;
- }
-
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_title;
+ super(subjectModel, parent, widgetFactory);
}
@Override
@@ -84,7 +64,7 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.verticalAlignment = SWT.TOP;
weavingSection.setLayoutData(gridData);
-
+
Section customizersSection = this.getWidgetFactory().createSection(parent, ExpandableComposite.TITLE_BAR);
customizersSection.setText(EclipseLinkUiMessages.PersistenceXmlCustomizationTab_customizersSection);
customizersSection.setClient(this.initializeCustomizersSection(customizersSection));
@@ -112,8 +92,8 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
TriStateCheckBox validationOnlyCheckBox = this.addTriStateCheckBoxWithDefault(
container,
EclipseLinkUiMessages.PersistenceXmlCustomizationTab_validationOnlyLabel,
- this.buildValidationOnlyHolder(),
- this.buildValidationOnlyStringHolder(),
+ this.buildValidationOnlyModel(),
+ this.buildValidationOnlyStringModel(),
EclipseLinkHelpContextIds.PERSISTENCE_CUSTOMIZATION
);
GridData gridData = new GridData();
@@ -125,8 +105,8 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
TriStateCheckBox validateSchemaCheckBox = this.addTriStateCheckBoxWithDefault(
container,
EclipseLinkUiMessages.PersistenceXmlCustomizationTab_validateSchemaLabel,
- this.buildValidateSchemaHolder(),
- this.buildValidateSchemaStringHolder(),
+ this.buildValidateSchemaModel(),
+ this.buildValidateSchemaStringModel(),
EclipseLinkHelpContextIds.PERSISTENCE_CUSTOMIZATION
);
gridData = new GridData();
@@ -138,7 +118,7 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
container,
EclipseLinkUiMessages.PersistenceXmlCustomizationTab_throwExceptionsLabel,
this.buildThrowExceptionsHolder(),
- this.buildThrowExceptionsStringHolder(),
+ this.buildThrowExceptionsStringModel(),
EclipseLinkHelpContextIds.PERSISTENCE_CUSTOMIZATION
);
gridData = new GridData();
@@ -166,15 +146,15 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
return container;
}
-
+
protected void buildEntityListComposite(Composite parent) {
new EntityListComposite(this, parent);
}
//********* validation only ***********
-
- private ModifiablePropertyValueModel<Boolean> buildValidationOnlyHolder() {
+
+ private ModifiablePropertyValueModel<Boolean> buildValidationOnlyModel() {
return new PropertyAspectAdapter<Customization, Boolean>(getSubjectHolder(), Customization.VALIDATION_ONLY_PROPERTY) {
@Override
protected Boolean buildValue_() {
@@ -188,8 +168,8 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
};
}
- private PropertyValueModel<String> buildValidationOnlyStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildDefaultValidationOnlyHolder()) {
+ private PropertyValueModel<String> buildValidationOnlyStringModel() {
+ return new TransformationPropertyValueModel<Boolean, String>(buildDefaultValidationOnlyModel()) {
@Override
protected String transform(Boolean value) {
if (value != null) {
@@ -200,8 +180,8 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
}
};
}
-
- private PropertyValueModel<Boolean> buildDefaultValidationOnlyHolder() {
+
+ private PropertyValueModel<Boolean> buildDefaultValidationOnlyModel() {
return new PropertyAspectAdapter<Customization, Boolean>(
getSubjectHolder(),
Customization.VALIDATION_ONLY_PROPERTY)
@@ -218,8 +198,8 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
//********* validate schema ***********
-
- private ModifiablePropertyValueModel<Boolean> buildValidateSchemaHolder() {
+
+ private ModifiablePropertyValueModel<Boolean> buildValidateSchemaModel() {
return new PropertyAspectAdapter<Customization, Boolean>(getSubjectHolder(), Customization.VALIDATE_SCHEMA_PROPERTY) {
@Override
protected Boolean buildValue_() {
@@ -233,8 +213,8 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
};
}
- private PropertyValueModel<String> buildValidateSchemaStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildDefaultValidateSchemaHolder()) {
+ private PropertyValueModel<String> buildValidateSchemaStringModel() {
+ return new TransformationPropertyValueModel<Boolean, String>(buildDefaultValidateSchemaModel()) {
@Override
protected String transform(Boolean value) {
if (value != null) {
@@ -245,8 +225,8 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
}
};
}
-
- private PropertyValueModel<Boolean> buildDefaultValidateSchemaHolder() {
+
+ private PropertyValueModel<Boolean> buildDefaultValidateSchemaModel() {
return new PropertyAspectAdapter<Customization, Boolean>(
getSubjectHolder(),
Customization.VALIDATE_SCHEMA_PROPERTY)
@@ -263,7 +243,7 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
//********* throw exceptions ***********
-
+
private ModifiablePropertyValueModel<Boolean> buildThrowExceptionsHolder() {
return new PropertyAspectAdapter<Customization, Boolean>(getSubjectHolder(), Customization.THROW_EXCEPTIONS_PROPERTY) {
@Override
@@ -277,8 +257,8 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
};
}
- private PropertyValueModel<String> buildThrowExceptionsStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildDefaultThrowExceptionsHolder()) {
+ private PropertyValueModel<String> buildThrowExceptionsStringModel() {
+ return new TransformationPropertyValueModel<Boolean, String>(buildDefaultThrowExceptionsModel()) {
@Override
protected String transform(Boolean value) {
if (value != null) {
@@ -289,8 +269,8 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
}
};
}
-
- private PropertyValueModel<Boolean> buildDefaultThrowExceptionsHolder() {
+
+ private PropertyValueModel<Boolean> buildDefaultThrowExceptionsModel() {
return new PropertyAspectAdapter<Customization, Boolean>(
getSubjectHolder(),
Customization.THROW_EXCEPTIONS_PROPERTY)
@@ -336,22 +316,21 @@ public class PersistenceXmlCustomizationTab<T extends Customization>
protected String getClassName() {
return this.getSubject().getExceptionHandler();
}
-
+
@Override
protected IJavaProject getJavaProject() {
return getSubject().getJpaProject().getJavaProject();
}
-
+
@Override
protected void setClassName(String className) {
this.getSubject().setExceptionHandler(className);
}
-
+
@Override
protected String getSuperInterfaceName() {
return Customization.ECLIPSELINK_EXCEPTION_HANDLER_CLASS_NAME;
}
};
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/EclipseLinkPersistenceUnitCustomizationEditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/EclipseLinkPersistenceUnitCustomizationEditorPageDefinition.java
new file mode 100644
index 0000000000..9ea912ee72
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/customization/EclipseLinkPersistenceUnitCustomizationEditorPageDefinition.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 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.jpa.eclipselink.ui.internal.persistence.customization;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Customization;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class EclipseLinkPersistenceUnitCustomizationEditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new EclipseLinkPersistenceUnitCustomizationEditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private EclipseLinkPersistenceUnitCustomizationEditorPageDefinition() {
+ super();
+ }
+
+ public String getPageText() {
+ return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_title;
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return null;
+ }
+
+ public String getHelpID() {
+ return EclipseLinkHelpContextIds.PERSISTENCE_CUSTOMIZATION;
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new EclipseLinkPersistenceUnitCustomizationEditorPage<Customization>(
+ this.buildCustomizationHolder(jpaRootStructureNodeModel),
+ parent,
+ widgetFactory);
+ }
+
+ private PropertyValueModel<Customization> buildCustomizationHolder(PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ return new TransformationPropertyValueModel<PersistenceUnit, Customization>(this.buildPersistenceUnitModel(jpaRootStructureNodeModel)) {
+ @Override
+ protected Customization transform_(PersistenceUnit value) {
+ return ((EclipseLinkPersistenceUnit) value).getCustomization();
+ }
+ };
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralTab.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralEditorPage.java
index 3877d46bfa..e96f17fef5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralEditorPage.java
@@ -1,42 +1,40 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 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.jpa.eclipselink.ui.internal.persistence.general;
-
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitGeneralTab;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * EclipseLinkPersistenceUnitGeneralTab
- */
-public class EclipseLinkPersistenceUnitGeneralTab
- extends PersistenceUnitGeneralTab
-{
- // ********** constructors **********
- public EclipseLinkPersistenceUnitGeneralTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite container,
- WidgetFactory widgetFactory) {
- super(subjectHolder, container, widgetFactory);
- }
-
- @Override
- protected Control buildMappingFilesComposite(Composite parent) {
- return new EclipseLinkPersistenceUnitMappingFilesComposite(this, parent).getControl();
- }
-
- @Override
- protected Control buildJarFilesComposite(Composite parent) {
- return new EclipseLinkPersistenceUnitJarFilesComposite(this, parent).getControl();
- }
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.eclipselink.ui.internal.persistence.general;
+
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitGeneralEditorPage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public class EclipseLinkPersistenceUnitGeneralEditorPage
+ extends PersistenceUnitGeneralEditorPage
+{
+
+ public EclipseLinkPersistenceUnitGeneralEditorPage(
+ PropertyValueModel<PersistenceUnit> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ @Override
+ protected Control buildMappingFilesComposite(Composite parent) {
+ return new EclipseLinkPersistenceUnitMappingFilesComposite(this, parent).getControl();
+ }
+
+ @Override
+ protected Control buildJarFilesComposite(Composite parent) {
+ return new EclipseLinkPersistenceUnitJarFilesComposite(this, parent).getControl();
+ }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralEditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralEditorPageDefinition.java
new file mode 100644
index 0000000000..4aaf11bd9c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitGeneralEditorPageDefinition.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.eclipselink.ui.internal.persistence.general;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitGeneralEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class EclipseLinkPersistenceUnitGeneralEditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new EclipseLinkPersistenceUnitGeneralEditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private EclipseLinkPersistenceUnitGeneralEditorPageDefinition() {
+ super();
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new EclipseLinkPersistenceUnitGeneralEditorPage(this.buildPersistenceUnitModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+
+ public String getPageText() {
+ return PersistenceUnitGeneralEditorPageDefinition.instance().getPageText();
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return PersistenceUnitGeneralEditorPageDefinition.instance().getPageImageDescriptor();
+ }
+
+ public String getHelpID() {
+ return PersistenceUnitGeneralEditorPageDefinition.instance().getHelpID();
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitMappingFilesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitMappingFilesComposite.java
index dc483c06a9..1c76275e6b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitMappingFilesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/general/EclipseLinkPersistenceUnitMappingFilesComposite.java
@@ -21,7 +21,7 @@ import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersi
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.GeneralProperties;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitGeneralTab;
+import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitGeneralEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitMappingFilesComposite;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Composite;
@@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Composite;
* -----------------------------------------------------------------------------</pre>
*
* @see PersistenceUnit
- * @see PersistenceUnitGeneralTab - The parent container
+ * @see PersistenceUnitGeneralEditorPageDefinition - The parent container
* @see AddRemoveListPane
*
* @version 2.0
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/PersistenceXmlOptionsTab.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/EclipseLinkPersistenceUnitOptionsEditorPage.java
index b318cabea2..0e219581bd 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/PersistenceXmlOptionsTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/EclipseLinkPersistenceUnitOptionsEditorPage.java
@@ -12,9 +12,8 @@ package org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
+
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.StringConverter;
import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
@@ -46,7 +45,6 @@ import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.TargetDatabase;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.TargetServer;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -57,37 +55,19 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.Section;
-import com.ibm.icu.text.Collator;
-
-/**
- * EclipseLinkOptionsComposite
- */
-public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
- extends Pane<T>
- implements JpaPageComposite
-{
- private PropertyValueModel<Options> optionsHolder;
-
- public PersistenceXmlOptionsTab(
- PropertyValueModel<T> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
- super(subjectHolder, parent, widgetFactory);
- }
+import com.ibm.icu.text.Collator;
- // ********** JpaPageComposite implementation **********
+public class EclipseLinkPersistenceUnitOptionsEditorPage extends Pane<PersistenceUnit>{
- public String getHelpID() {
- return EclipseLinkHelpContextIds.PERSISTENCE_OPTIONS;
- }
+ private PropertyValueModel<Options> optionsHolder;
- public ImageDescriptor getPageImageDescriptor() {
- return null;
- }
+ public EclipseLinkPersistenceUnitOptionsEditorPage(
+ PropertyValueModel<PersistenceUnit> subjectModel,
+ Composite parent,
+ WidgetFactory widgetFactory) {
- public String getPageText() {
- return EclipseLinkUiMessages.PersistenceXmlOptionsTab_title;
+ super(subjectModel, parent, widgetFactory);
}
@Override
@@ -129,7 +109,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
Control miscellaneousComposite = this.initializeMiscellaneousSection(miscellaneousSection);
miscellaneousSection.setClient(miscellaneousComposite);
}
-
+
private Control initializeSessionOptionsSection(Section section) {
this.optionsHolder = this.buildOptionsHolder();
GridLayout layout = new GridLayout(2, false);
@@ -148,7 +128,6 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
this.buildSessionNameHolder(),
StringObjectTransformer.<String>instance(),
EclipseLinkHelpContextIds.PERSISTENCE_OPTIONS_SESSION_NAME
-
);
SWTUtil.attachDefaultValueHandler(sessionNameCombo);
@@ -172,7 +151,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
EclipseLinkHelpContextIds.PERSISTENCE_OPTIONS_TARGET_DATABASE
);
SWTUtil.attachDefaultValueHandler(targetDatabaseCombo);
-
+
this.addLabel(container, EclipseLinkUiMessages.PersistenceXmlOptionsTab_targetServerLabel);
Combo targetServerCombo = addEditableCombo(
@@ -197,7 +176,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
includeDescriptorQueriesCheckBox.getCheckBox().setLayoutData(gridData);
-
+
return container;
}
@@ -218,10 +197,10 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
this.buildTemporalMutableStringHolder(),
EclipseLinkHelpContextIds.PERSISTENCE_OPTIONS
);
-
+
return container;
}
-
+
private PropertyValueModel<SchemaGeneration> buildSchemaGenerationHolder() {
return new TransformationPropertyValueModel<PersistenceUnit, SchemaGeneration>(getSubjectHolder()) {
@Override
@@ -230,7 +209,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
}
};
}
-
+
private PropertyValueModel<Logging> buildLoggingHolder() {
return new TransformationPropertyValueModel<PersistenceUnit, Logging>(getSubjectHolder()) {
@Override
@@ -239,7 +218,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
}
};
}
-
+
private PropertyValueModel<Options> buildOptionsHolder() {
return new TransformationPropertyValueModel<PersistenceUnit, Options>(getSubjectHolder()) {
@Override
@@ -257,7 +236,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
return new PropertyAspectAdapter<Options, String>(this.optionsHolder, Options.DEFAULT_SESSION_NAME) {
@Override
protected String buildValue_() {
- return PersistenceXmlOptionsTab.this.getSessionNameDefaultValue(subject);
+ return EclipseLinkPersistenceUnitOptionsEditorPage.this.getSessionNameDefaultValue(subject);
}
};
}
@@ -275,7 +254,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
String name = subject.getSessionName();
if (name == null) {
- name = PersistenceXmlOptionsTab.this.getSessionNameDefaultValue(subject);
+ name = EclipseLinkPersistenceUnitOptionsEditorPage.this.getSessionNameDefaultValue(subject);
}
return name;
}
@@ -310,7 +289,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
return new PropertyAspectAdapter<Options, String>(this.optionsHolder, Options.DEFAULT_SESSIONS_XML) {
@Override
protected String buildValue_() {
- return PersistenceXmlOptionsTab.this.getSessionsXmlDefaultValue(subject);
+ return EclipseLinkPersistenceUnitOptionsEditorPage.this.getSessionsXmlDefaultValue(subject);
}
};
}
@@ -328,7 +307,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
String name = subject.getSessionsXml();
if (name == null) {
- name = PersistenceXmlOptionsTab.this.getSessionsXmlDefaultValue(subject);
+ name = EclipseLinkPersistenceUnitOptionsEditorPage.this.getSessionsXmlDefaultValue(subject);
}
return name;
}
@@ -363,7 +342,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
return new PropertyAspectAdapter<Options, String>(this.optionsHolder, Options.DEFAULT_TARGET_DATABASE) {
@Override
protected String buildValue_() {
- return PersistenceXmlOptionsTab.this.getTargetDatabaseDefaultValue(subject);
+ return EclipseLinkPersistenceUnitOptionsEditorPage.this.getTargetDatabaseDefaultValue(subject);
}
};
}
@@ -464,7 +443,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
String name = subject.getTargetDatabase();
if (name == null) {
- name = PersistenceXmlOptionsTab.this.getTargetDatabaseDefaultValue(subject);
+ name = EclipseLinkPersistenceUnitOptionsEditorPage.this.getTargetDatabaseDefaultValue(subject);
}
return name;
}
@@ -528,7 +507,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
return new PropertyAspectAdapter<Options, String>(this.optionsHolder, Options.DEFAULT_TARGET_SERVER) {
@Override
protected String buildValue_() {
- return PersistenceXmlOptionsTab.this.getTargetServerDefaultValue(subject);
+ return EclipseLinkPersistenceUnitOptionsEditorPage.this.getTargetServerDefaultValue(subject);
}
};
}
@@ -600,7 +579,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
protected String buildValue_() {
String name = subject.getTargetServer();
if (name == null) {
- name = PersistenceXmlOptionsTab.this.getTargetServerDefaultValue(subject);
+ name = EclipseLinkPersistenceUnitOptionsEditorPage.this.getTargetServerDefaultValue(subject);
}
return name;
}
@@ -686,7 +665,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
protected String getClassName() {
return this.getSubject().getEventListener();
}
-
+
@Override
protected IJavaProject getJavaProject() {
return getSubject().getJpaProject().getJavaProject();
@@ -696,7 +675,7 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
protected void setClassName(String className) {
this.getSubject().setEventListener(className);
}
-
+
@Override
protected String getSuperInterfaceName() {
return Options.ECLIPSELINK_EVENT_LISTENER_CLASS_NAME;
@@ -793,4 +772,4 @@ public class PersistenceXmlOptionsTab<T extends PersistenceUnit>
}
};
}
-}
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/EclipseLinkPersistenceUnitOptionsEditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/EclipseLinkPersistenceUnitOptionsEditorPageDefinition.java
new file mode 100644
index 0000000000..099fc928e3
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/options/EclipseLinkPersistenceUnitOptionsEditorPageDefinition.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.eclipselink.ui.internal.persistence.options;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class EclipseLinkPersistenceUnitOptionsEditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new EclipseLinkPersistenceUnitOptionsEditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private EclipseLinkPersistenceUnitOptionsEditorPageDefinition() {
+ super();
+ }
+
+ public String getPageText() {
+ return EclipseLinkUiMessages.PersistenceXmlOptionsTab_title;
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return null;
+ }
+
+ public String getHelpID() {
+ return EclipseLinkHelpContextIds.PERSISTENCE_OPTIONS;
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new EclipseLinkPersistenceUnitOptionsEditorPage(this.buildPersistenceUnitModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLink2_0PersistenceXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLink2_0PersistenceXmlUiFactory.java
deleted file mode 100644
index 4d9cbe9e1b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLink2_0PersistenceXmlUiFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2009, 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
-
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Caching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Customization;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.EclipseLinkPersistenceXmlUiFactory;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.caching.PersistenceXmlCachingTab;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.customization.PersistenceXmlCustomizationTab;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options.PersistenceXmlOptionsTab;
-import org.eclipse.swt.widgets.Composite;
-
-public class EclipseLink2_0PersistenceXmlUiFactory extends EclipseLinkPersistenceXmlUiFactory
-{
- // ********** constructors **********
-
- public EclipseLink2_0PersistenceXmlUiFactory() {
- super();
- }
-
- // ********** persistence unit tabs **********
-
- @Override
- protected PersistenceXmlCustomizationTab<Customization> buildCustomizationTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
- return new PersistenceXmlCustomization2_0Tab(this.buildCustomizationHolder(subjectHolder), parent, widgetFactory);
- }
-
- @Override
- protected PersistenceXmlCachingTab<Caching> buildCachingTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
- return new PersistenceXmlCaching2_0Tab(this.buildCachingHolder(subjectHolder), parent, widgetFactory);
- }
-
- @Override
- protected PersistenceXmlOptionsTab<PersistenceUnit> buildOptionsTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
- return new PersistenceXmlOptions2_0Tab(subjectHolder, parent, widgetFactory);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLink2_4PersistenceXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLink2_4PersistenceXmlUiFactory.java
deleted file mode 100644
index 91ce68f5b7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLink2_4PersistenceXmlUiFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
-
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options.PersistenceXmlOptionsTab;
-import org.eclipse.swt.widgets.Composite;
-
-public class EclipseLink2_4PersistenceXmlUiFactory extends EclipseLink2_0PersistenceXmlUiFactory {
-
- // ********** persistence unit tabs **********
-
- @Override
- protected PersistenceXmlOptionsTab<PersistenceUnit> buildOptionsTab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
- return new PersistenceXmlOptions2_4Tab(subjectHolder, parent, widgetFactory);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlCaching2_0Tab.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCaching2_0EditorPage.java
index e55f83abd1..f732e6fd4d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlCaching2_0Tab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCaching2_0EditorPage.java
@@ -14,6 +14,7 @@ import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo;
+import org.eclipse.jpt.common.utility.internal.model.value.CompositeBooleanPropertyValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
@@ -24,55 +25,68 @@ import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.CacheType;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Caching;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.caching.PersistenceXmlCachingTab;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.caching.EclipseLinkPersistenceUnitCachingEditorPage;
import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
-/**
- * PersistenceXmlCaching2_0Tab
- */
-public class PersistenceXmlCaching2_0Tab extends PersistenceXmlCachingTab<Caching>
+public class EclipseLinkPersistenceUnitCaching2_0EditorPage
+ extends EclipseLinkPersistenceUnitCachingEditorPage<Caching>
{
- public PersistenceXmlCaching2_0Tab(
- PropertyValueModel<Caching> subjectHolder,
+ public EclipseLinkPersistenceUnitCaching2_0EditorPage(
+ PropertyValueModel<Caching> subjectModel,
Composite parent,
WidgetFactory widgetFactory) {
- super(subjectHolder, parent, widgetFactory);
+ super(subjectModel, parent, widgetFactory);
}
@Override
protected void initializeLayout(Composite container) {
- container = this.addSection(
- container,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionTitle,
- EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionDescription
- );
- container.setLayout(new GridLayout(2, false));
+ Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ section.setText(EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionTitle);
+ section.setDescription(EclipseLinkUiMessages.PersistenceXmlCachingTab_sectionDescription);
+
+ Composite client = this.getWidgetFactory().createComposite(section);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginTop = 0;
+ layout.marginLeft = 0;
+ layout.marginBottom = 0;
+ layout.marginRight = 0;
+ client.setLayout(layout);
+ client.setLayoutData(new GridData(GridData.FILL_BOTH));
+ section.setClient(client);
+
+ PropertyValueModel<PersistenceUnit2_0> persistenceUnitModel = this.buildPersistenceUnit2_0Model();
// SharedCacheMode
- this.addLabel(container, JptUiPersistence2_0Messages.SharedCacheModeComposite_sharedCacheModeLabel);
- this.addSharedCacheModeCombo(container, this.buildPersistenceUnit2_0Holder());
+ this.addLabel(client, JptUiPersistence2_0Messages.SharedCacheModeComposite_sharedCacheModeLabel);
+ this.addSharedCacheModeCombo(client, persistenceUnitModel);
// Defaults
// Default Cache Type
- Label cacheTypeLabel = this.addLabel(container, EclipseLinkUiMessages.PersistenceXmlCachingTab_defaultCacheTypeLabel);
- Combo cacheTypeCombo = this.buildDefaultCacheTypeCombo(container).getControl();
+ Label cacheTypeLabel = this.addLabel(client, EclipseLinkUiMessages.PersistenceXmlCachingTab_defaultCacheTypeLabel);
+ Combo cacheTypeCombo = this.buildDefaultCacheTypeCombo(client).getControl();
// Default Cache Size
- Label cacheSizeLabel = this.addLabel(container, EclipseLinkUiMessages.DefaultCacheSizeComposite_defaultCacheSize);
- Combo cacheSizeCombo = this.addDefaultCacheSizeCombo(container).getControl();
+ Label cacheSizeLabel = this.addLabel(client, EclipseLinkUiMessages.DefaultCacheSizeComposite_defaultCacheSize);
+ Combo cacheSizeCombo = this.addDefaultCacheSizeCombo(client).getControl();
// Flush Clear Cache
- Label flushClearCacheLabel = this.addLabel(container, EclipseLinkUiMessages.PersistenceXmlCachingTab_FlushClearCacheLabel);
- Combo flushClearCacheCombo = this.addFlushClearCacheCombo(container).getControl();
+ Label flushClearCacheLabel = this.addLabel(client, EclipseLinkUiMessages.PersistenceXmlCachingTab_FlushClearCacheLabel);
+ Combo flushClearCacheCombo = this.addFlushClearCacheCombo(client).getControl();
SWTTools.controlEnabledState(
- this.buildSharedCacheModeEnablerHolder(),
+ this.buildSharedCacheModeEnablerModel(persistenceUnitModel),
cacheTypeLabel,
cacheTypeCombo,
cacheSizeLabel,
@@ -81,7 +95,7 @@ public class PersistenceXmlCaching2_0Tab extends PersistenceXmlCachingTab<Cachin
flushClearCacheCombo);
}
- private PropertyValueModel<PersistenceUnit2_0> buildPersistenceUnit2_0Holder() {
+ private PropertyValueModel<PersistenceUnit2_0> buildPersistenceUnit2_0Model() {
return new PropertyAspectAdapter<Caching, PersistenceUnit2_0>(this.getSubjectHolder()) {
@Override
protected PersistenceUnit2_0 buildValue_() {
@@ -92,9 +106,9 @@ public class PersistenceXmlCaching2_0Tab extends PersistenceXmlCachingTab<Cachin
//********* shared cache mode ***********
-
- private EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode> addSharedCacheModeCombo(Composite parent, PropertyValueModel<? extends PersistenceUnit2_0> subjectHolder) {
- return new EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode>(this, subjectHolder, parent) {
+
+ private EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode> addSharedCacheModeCombo(Composite parent, PropertyValueModel<? extends PersistenceUnit2_0> subjectModel) {
+ return new EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode>(this, subjectModel, parent) {
@Override
protected void addPropertyNames(Collection<String> propertyNames) {
super.addPropertyNames(propertyNames);
@@ -146,18 +160,21 @@ public class PersistenceXmlCaching2_0Tab extends PersistenceXmlCachingTab<Cachin
};
}
- private PropertyValueModel<Boolean> buildSharedCacheModeEnablerHolder() {
- return new TransformationPropertyValueModel<SharedCacheMode, Boolean>(this.buildSharedCacheModeHolder()) {
- @Override
- protected Boolean transform(SharedCacheMode value) {
- return value != SharedCacheMode.NONE;
- }
- };
+ @SuppressWarnings("unchecked")
+ private PropertyValueModel<Boolean> buildSharedCacheModeEnablerModel(PropertyValueModel<PersistenceUnit2_0> persistenceUnitModel) {
+ return CompositeBooleanPropertyValueModel.and(
+ this.getEnabledModel(),
+ new TransformationPropertyValueModel<SharedCacheMode, Boolean>(this.buildSharedCacheModeModel(persistenceUnitModel)) {
+ @Override
+ protected Boolean transform(SharedCacheMode value) {
+ return Boolean.valueOf(value != SharedCacheMode.NONE);
+ }
+ });
}
- private PropertyValueModel<SharedCacheMode> buildSharedCacheModeHolder() {
+ private PropertyValueModel<SharedCacheMode> buildSharedCacheModeModel(PropertyValueModel<PersistenceUnit2_0> persistenceUnitModel) {
return new PropertyAspectAdapter<PersistenceUnit2_0, SharedCacheMode>(
- this.buildPersistenceUnit2_0Holder(),
+ persistenceUnitModel,
PersistenceUnit2_0.SPECIFIED_SHARED_CACHE_MODE_PROPERTY,
PersistenceUnit2_0.DEFAULT_SHARED_CACHE_MODE_PROPERTY) {
@Override
@@ -226,7 +243,7 @@ public class PersistenceXmlCaching2_0Tab extends PersistenceXmlCachingTab<Cachin
return EclipseLinkHelpContextIds.PERSISTENCE_CACHING_DEFAULT_TYPE;
}
};
- }
+ }
protected IntegerCombo<Caching> addDefaultCacheSizeCombo(Composite container) {
return new IntegerCombo<Caching>(this, container) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCaching2_0EditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCaching2_0EditorPageDefinition.java
new file mode 100644
index 0000000000..4696fccef9
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCaching2_0EditorPageDefinition.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+* Copyright (c) 2009, 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Caching;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.caching.EclipseLinkPersistenceUnitCachingEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class EclipseLinkPersistenceUnitCaching2_0EditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new EclipseLinkPersistenceUnitCaching2_0EditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private EclipseLinkPersistenceUnitCaching2_0EditorPageDefinition() {
+ super();
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new EclipseLinkPersistenceUnitCaching2_0EditorPage(this.buildCachingModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+
+ private PropertyValueModel<Caching> buildCachingModel(PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ return new TransformationPropertyValueModel<PersistenceUnit, Caching>(this.buildPersistenceUnitModel(jpaRootStructureNodeModel)) {
+ @Override
+ protected Caching transform_(PersistenceUnit value) {
+ return ((EclipseLinkPersistenceUnit) value).getCaching();
+ }
+ };
+ }
+
+ public String getPageText() {
+ return EclipseLinkPersistenceUnitCachingEditorPageDefinition.instance().getPageText();
+ }
+
+ public String getHelpID() {
+ return EclipseLinkPersistenceUnitCachingEditorPageDefinition.instance().getHelpID();
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return EclipseLinkPersistenceUnitCachingEditorPageDefinition.instance().getPageImageDescriptor();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlCustomization2_0Tab.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCustomization2_0EditorPage.java
index 47259000a7..f58df389fc 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlCustomization2_0Tab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCustomization2_0EditorPage.java
@@ -12,20 +12,17 @@ package org.eclipse.jpt.jpa.eclipselink.ui.internal.v2_0.persistence;
import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Customization;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.customization.PersistenceXmlCustomizationTab;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.customization.EclipseLinkPersistenceUnitCustomizationEditorPage;
import org.eclipse.swt.widgets.Composite;
-/**
- * PersistenceXmlCustomization2_0Tab
- */
-public class PersistenceXmlCustomization2_0Tab extends PersistenceXmlCustomizationTab<Customization>
+public class EclipseLinkPersistenceUnitCustomization2_0EditorPage extends EclipseLinkPersistenceUnitCustomizationEditorPage<Customization>
{
- public PersistenceXmlCustomization2_0Tab(
- PropertyValueModel<Customization> subjectHolder,
+ public EclipseLinkPersistenceUnitCustomization2_0EditorPage(
+ PropertyValueModel<Customization> subjectModel,
Composite parent,
WidgetFactory widgetFactory) {
- super(subjectHolder, parent, widgetFactory);
+ super(subjectModel, parent, widgetFactory);
}
@@ -33,5 +30,4 @@ public class PersistenceXmlCustomization2_0Tab extends PersistenceXmlCustomizati
protected void buildEntityListComposite(Composite parent) {
// do nothing
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCustomization2_0EditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCustomization2_0EditorPageDefinition.java
new file mode 100644
index 0000000000..727ad31d01
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitCustomization2_0EditorPageDefinition.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Customization;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.customization.EclipseLinkPersistenceUnitCustomizationEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class EclipseLinkPersistenceUnitCustomization2_0EditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new EclipseLinkPersistenceUnitCustomization2_0EditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private EclipseLinkPersistenceUnitCustomization2_0EditorPageDefinition() {
+ super();
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new EclipseLinkPersistenceUnitCustomization2_0EditorPage(
+ this.buildCustomizationModel(jpaRootStructureNodeModel),
+ parent,
+ widgetFactory);
+ }
+
+ private PropertyValueModel<Customization> buildCustomizationModel(PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ return new TransformationPropertyValueModel<PersistenceUnit, Customization>(this.buildPersistenceUnitModel(jpaRootStructureNodeModel)) {
+ @Override
+ protected Customization transform_(PersistenceUnit value) {
+ return ((EclipseLinkPersistenceUnit) value).getCustomization();
+ }
+ };
+ }
+
+ public String getPageText() {
+ return EclipseLinkPersistenceUnitCustomizationEditorPageDefinition.instance().getPageText();
+ }
+
+ public String getHelpID() {
+ return EclipseLinkPersistenceUnitCustomizationEditorPageDefinition.instance().getHelpID();
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return EclipseLinkPersistenceUnitCustomizationEditorPageDefinition.instance().getPageImageDescriptor();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlOptions2_0Tab.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_0EditorPage.java
index d130115f3f..6ad6c46435 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlOptions2_0Tab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_0EditorPage.java
@@ -1,499 +1,493 @@
-/*******************************************************************************
-* Copyright (c) 2009, 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
-
-import java.util.Collection;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-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.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane;
-import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter;
-import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo;
-import org.eclipse.jpt.common.ui.internal.widgets.TriStateCheckBox;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.iterable.ListIterable;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.ValidationMode;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Logging2_0;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Options2_0;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options.PersistenceXmlOptionsTab;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.plugin.JptJpaEclipseLinkUiPlugin;
-import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.progress.IProgressService;
-
-/**
- * EclipseLinkOptions2_0Composite
- */
-public class PersistenceXmlOptions2_0Tab extends PersistenceXmlOptionsTab<PersistenceUnit>
-{
- private PropertyValueModel<Options2_0> optionsHolder;
-
- public PersistenceXmlOptions2_0Tab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- @Override
- protected Control initializeMiscellaneousSection(Section section) {
- Composite container = this.addSubPane(section, 2, 0, 0, 0, 0);
-
- TriStateCheckBox checkBox = this.addTriStateCheckBoxWithDefault(
- container,
- EclipseLinkUiMessages.PersistenceXmlOptionsTab_temporalMutableLabel,
- this.buildTemporalMutableHolder(),
- this.buildTemporalMutableStringHolder(),
- EclipseLinkHelpContextIds.PERSISTENCE_OPTIONS
- );
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
- checkBox.getCheckBox().setLayoutData(gridData);
-
- this.optionsHolder = this.buildOptions2_0Holder();
- this.addLabel(container, JptUiPersistence2_0Messages.LockingConfigurationComposite_lockTimeoutLabel);
- this.addLockTimeoutCombo(container);
-
- this.addLabel(container, JptUiPersistence2_0Messages.QueryConfigurationComposite_queryTimeoutLabel);
- this.addQueryTimeoutCombo(container);
-
-
- // ValidationMode
- this.addLabel(container, JptUiPersistence2_0Messages.ValidationModeComposite_validationModeLabel);
- this.addValidationModeCombo(container);
-
- // ValidationGroupPrePersist
- this.addLabel(container, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPrePersistLabel);
- this.addPrePersistListPane(container);
-
- // ValidationGroupPreUpdate
- this.addLabel(container, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreUpdateLabel);
- this.addPreUpdateListPane(container);
-
- // ValidationGroupPreRemove
- this.addLabel(container, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreRemoveLabel);
- this.addPreRemoveListPane(container);
-
- return container;
- }
-
- @Override
- protected Control initializeLoggingSection(Section section) {
- return new EclipseLinkLogging2_0Composite(this.buildLoggingHolder(), section, getWidgetFactory()).getControl();
- }
-
- protected PropertyValueModel<Logging2_0> buildLoggingHolder() {
- return new TransformationPropertyValueModel<PersistenceUnit, Logging2_0>(getSubjectHolder()) {
- @Override
- protected Logging2_0 transform_(PersistenceUnit value) {
- return (Logging2_0) ((EclipseLinkPersistenceUnit) value).getLogging();
- }
- };
- }
-
- private void addLockTimeoutCombo(Composite container) {
- new IntegerCombo<Options2_0>(this, this.optionsHolder, container) {
- @Override
- protected String getHelpId() {
- return null; // TODO
- }
- @Override
- protected PropertyValueModel<Integer> buildDefaultHolder() {
- return new PropertyAspectAdapter<Options2_0, Integer>(this.getSubjectHolder()) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getDefaultLockTimeout();
- }
- };
- }
-
- @Override
- protected ModifiablePropertyValueModel<Integer> buildSelectedItemHolder() {
- return new PropertyAspectAdapter<Options2_0, Integer>(this.getSubjectHolder(), Options2_0.LOCK_TIMEOUT_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getLockTimeout();
- }
-
- @Override
- protected void setValue_(Integer value) {
- this.subject.setLockTimeout(value);
- }
- };
- }
- };
- }
-
- private void addQueryTimeoutCombo(Composite container) {
- new IntegerCombo<Options2_0>(this, this.optionsHolder, container) {
- @Override
- protected String getHelpId() {
- return null; // TODO
- }
-
- @Override
- protected PropertyValueModel<Integer> buildDefaultHolder() {
- return new PropertyAspectAdapter<Options2_0, Integer>(this.getSubjectHolder()) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getDefaultQueryTimeout();
- }
- };
- }
-
- @Override
- protected ModifiablePropertyValueModel<Integer> buildSelectedItemHolder() {
- return new PropertyAspectAdapter<Options2_0, Integer>(this.getSubjectHolder(), Options2_0.QUERY_TIMEOUT_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getQueryTimeout();
- }
-
- @Override
- protected void setValue_(Integer value) {
- this.subject.setQueryTimeout(value);
- }
- };
- }
- };
- }
-
- private EnumFormComboViewer<PersistenceUnit, ValidationMode> addValidationModeCombo(Composite parent) {
- return new EnumFormComboViewer<PersistenceUnit, ValidationMode>(this, this.getSubjectHolder(), parent) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(PersistenceUnit2_0.SPECIFIED_VALIDATION_MODE_PROPERTY);
- }
-
- @Override
- protected ValidationMode[] getChoices() {
- return ValidationMode.values();
- }
-
- @Override
- protected boolean sortChoices() {
- return false;
- }
-
- @Override
- protected ValidationMode getDefaultValue() {
- return ((PersistenceUnit2_0) this.getSubject()).getDefaultValidationMode();
- }
-
- @Override
- protected String displayString(ValidationMode value) {
- switch (value) {
- case AUTO :
- return JptUiPersistence2_0Messages.ValidationModeComposite_auto;
- case CALLBACK :
- return JptUiPersistence2_0Messages.ValidationModeComposite_callback;
- case NONE :
- return JptUiPersistence2_0Messages.ValidationModeComposite_none;
- default :
- throw new IllegalStateException();
- }
- }
-
- @Override
- protected ValidationMode getValue() {
- return ((PersistenceUnit2_0) this.getSubject()).getSpecifiedValidationMode();
- }
-
- @Override
- protected void setValue(ValidationMode value) {
- ((PersistenceUnit2_0) this.getSubject()).setSpecifiedValidationMode(value);
- }
- };
- }
-
- // ********** ValidationGroupPrePersists **********
-
- private void addPrePersistListPane(Composite parent) {
- new AddRemoveListPane<Options2_0, String>(
- this,
- this.optionsHolder,
- parent,
- this.buildPrePersistAdapter(),
- this.buildPrePersistListHolder(),
- this.buildSelectedItemsModel(),
- this.buildLabelProvider()
- );
- }
-
- private Adapter<String> buildPrePersistAdapter() {
- return new AddRemoveListPane.AbstractAdapter<String>() {
- public String addNewItem() {
- return addPrePersistClass();
- }
-
- @Override
- public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
- //enable the remove button only when 1 item is selected, same as the optional button
- return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
- }
-
- public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
- String item = selectedItemsModel.iterator().next();
- optionsHolder.getValue().removeValidationGroupPrePersist(item);
- }
- };
- }
-
- private ListValueModel<String> buildPrePersistListHolder() {
- return new ListAspectAdapter<Options2_0, String>(this.optionsHolder, JpaOptions2_0.VALIDATION_GROUP_PRE_PERSIST_LIST) {
- @Override
- protected ListIterable<String> getListIterable() {
- return subject.getValidationGroupPrePersists();
- }
-
- @Override
- protected int size_() {
- return subject.getValidationGroupPrePersistsSize();
- }
- };
- }
-
- private String addPrePersistClass() {
-
- IType type = this.chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('$');
- if( ! this.optionsHolder.getValue().validationGroupPrePersistExists(className)) {
-
- return this.optionsHolder.getValue().addValidationGroupPrePersist(className);
- }
- }
- return null;
- }
-
- // ********** ValidationGroupPreUpdates **********
-
- private void addPreUpdateListPane(Composite parent) {
- new AddRemoveListPane<Options2_0, String>(
- this,
- this.optionsHolder,
- parent,
- this.buildPreUpdateAdapter(),
- this.buildPreUpdateListHolder(),
- this.buildSelectedItemsModel(),
- this.buildLabelProvider()
- );
- }
-
- private Adapter<String> buildPreUpdateAdapter() {
- return new AddRemoveListPane.AbstractAdapter<String>() {
- public String addNewItem() {
- return addPreUpdateClass();
- }
-
- @Override
- public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
- //enable the remove button only when 1 item is selected, same as the optional button
- return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
- }
-
- public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
- String item = selectedItemsModel.iterator().next();
- optionsHolder.getValue().removeValidationGroupPreUpdate(item);
- }
- };
- }
-
- private ListValueModel<String> buildPreUpdateListHolder() {
- return new ListAspectAdapter<Options2_0, String>(this.optionsHolder, Options2_0.VALIDATION_GROUP_PRE_UPDATE_LIST) {
- @Override
- protected ListIterable<String> getListIterable() {
- return subject.getValidationGroupPreUpdates();
- }
-
- @Override
- protected int size_() {
- return subject.getValidationGroupPreUpdatesSize();
- }
- };
- }
-
- private String addPreUpdateClass() {
-
- IType type = this.chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('$');
- if( ! this.optionsHolder.getValue().validationGroupPreUpdateExists(className)) {
-
- return this.optionsHolder.getValue().addValidationGroupPreUpdate(className);
- }
- }
- return null;
- }
-
- // ********** ValidationGroupPreRemoves **********
-
- private void addPreRemoveListPane(Composite parent) {
- new AddRemoveListPane<Options2_0, String>(
- this,
- this.optionsHolder,
- parent,
- this.buildPreRemoveAdapter(),
- this.buildPreRemoveListHolder(),
- this.buildSelectedItemsModel(),
- this.buildLabelProvider()
- );
- }
-
- private Adapter<String> buildPreRemoveAdapter() {
- return new AddRemoveListPane.AbstractAdapter<String>() {
- public String addNewItem() {
- return addPreRemoveClass();
- }
-
- @Override
- public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
- //enable the remove button only when 1 item is selected, same as the optional button
- return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
- }
-
- public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
- String item = selectedItemsModel.iterator().next();
- optionsHolder.getValue().removeValidationGroupPreRemove(item);
- }
- };
- }
-
- private ListValueModel<String> buildPreRemoveListHolder() {
- return new ListAspectAdapter<Options2_0, String>(this.optionsHolder, JpaOptions2_0.VALIDATION_GROUP_PRE_REMOVE_LIST) {
- @Override
- protected ListIterable<String> getListIterable() {
- return subject.getValidationGroupPreRemoves();
- }
-
- @Override
- protected int size_() {
- return subject.getValidationGroupPreRemovesSize();
- }
- };
- }
-
- private String addPreRemoveClass() {
-
- IType type = this.chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('$');
- if( ! this.optionsHolder.getValue().validationGroupPreRemoveExists(className)) {
-
- return this.optionsHolder.getValue().addValidationGroupPreRemove(className);
- }
- }
- return null;
- }
-
-
- // ********** Private methods **********
-
- private ILabelProvider buildLabelProvider() {
- return new LabelProvider() {
-
- @Override
- public String getText(Object element) {
- String name = (String) element;
-
- if (name == null) {
- name = EclipseLinkUiMessages.PersistenceXmlOptionsTab_noName;
- }
- return name;
- }
- };
- }
-
- /**
- * Prompts the user the Open Type dialog.
- *
- * @return Either the selected type or <code>null</code> if the user
- * canceled the dialog
- */
- private IType chooseType() {
- IJavaProject javaProject = this.getSubject().getJpaProject().getJavaProject();
- IJavaElement[] elements = new IJavaElement[] { javaProject };
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- SelectionDialog typeSelectionDialog;
-
- try {
- typeSelectionDialog = JavaUI.createTypeDialog(
- getShell(),
- service,
- scope,
- IJavaElementSearchConstants.CONSIDER_CLASSES,
- false,
- ""
- );
- }
- catch (JavaModelException e) {
- JptJpaEclipseLinkUiPlugin.instance().logError(e);
- return null;
- }
-
- typeSelectionDialog.setTitle(JptCommonUiMessages.ClassChooserPane_dialogTitle);
- typeSelectionDialog.setMessage(JptCommonUiMessages.ClassChooserPane_dialogMessage);
-
- if (typeSelectionDialog.open() == Window.OK) {
- return (IType) typeSelectionDialog.getResult()[0];
- }
-
- return null;
- }
-
- private ModifiableCollectionValueModel<String> buildSelectedItemsModel() {
- return new SimpleCollectionValueModel<String>();
- }
-
- private PropertyValueModel<Options2_0> buildOptions2_0Holder() {
- return new TransformationPropertyValueModel<PersistenceUnit, Options2_0>(getSubjectHolder()) {
- @Override
- protected Options2_0 transform_(PersistenceUnit value) {
- return (Options2_0) ((PersistenceUnit2_0) value).getOptions();
- }
- };
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
+
+import java.util.Collection;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+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.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
+import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane;
+import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter;
+import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo;
+import org.eclipse.jpt.common.ui.internal.widgets.TriStateCheckBox;
+import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
+import org.eclipse.jpt.common.utility.model.value.ListValueModel;
+import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
+import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.ValidationMode;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Logging2_0;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Options2_0;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkHelpContextIds;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options.EclipseLinkPersistenceUnitOptionsEditorPage;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.plugin.JptJpaEclipseLinkUiPlugin;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.progress.IProgressService;
+
+class EclipseLinkPersistenceUnitOptions2_0EditorPage
+ extends EclipseLinkPersistenceUnitOptionsEditorPage {
+
+ private PropertyValueModel<Options2_0> optionsModel;
+
+ public EclipseLinkPersistenceUnitOptions2_0EditorPage(
+ PropertyValueModel<PersistenceUnit> subjectModel,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectModel, parent, widgetFactory);
+ }
+
+ @Override
+ protected Control initializeMiscellaneousSection(Section section) {
+ Composite container = this.addSubPane(section, 2, 0, 0, 0, 0);
+
+ TriStateCheckBox checkBox = this.addTriStateCheckBoxWithDefault(
+ container,
+ EclipseLinkUiMessages.PersistenceXmlOptionsTab_temporalMutableLabel,
+ this.buildTemporalMutableHolder(),
+ this.buildTemporalMutableStringHolder(),
+ EclipseLinkHelpContextIds.PERSISTENCE_OPTIONS
+ );
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 2;
+ checkBox.getCheckBox().setLayoutData(gridData);
+
+ this.optionsModel = this.buildOptions2_0Model();
+ this.addLabel(container, JptUiPersistence2_0Messages.LockingConfigurationComposite_lockTimeoutLabel);
+ this.addLockTimeoutCombo(container);
+
+ this.addLabel(container, JptUiPersistence2_0Messages.QueryConfigurationComposite_queryTimeoutLabel);
+ this.addQueryTimeoutCombo(container);
+
+
+ // ValidationMode
+ this.addLabel(container, JptUiPersistence2_0Messages.ValidationModeComposite_validationModeLabel);
+ this.addValidationModeCombo(container);
+
+ // ValidationGroupPrePersist
+ this.addLabel(container, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPrePersistLabel);
+ this.addPrePersistListPane(container);
+
+ // ValidationGroupPreUpdate
+ this.addLabel(container, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreUpdateLabel);
+ this.addPreUpdateListPane(container);
+
+ // ValidationGroupPreRemove
+ this.addLabel(container, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreRemoveLabel);
+ this.addPreRemoveListPane(container);
+
+ return container;
+ }
+
+ @Override
+ protected Control initializeLoggingSection(Section section) {
+ return new EclipseLinkLogging2_0Composite(this.buildLoggingModel(), section, getWidgetFactory()).getControl();
+ }
+
+ protected PropertyValueModel<Logging2_0> buildLoggingModel() {
+ return new TransformationPropertyValueModel<PersistenceUnit, Logging2_0>(getSubjectHolder()) {
+ @Override
+ protected Logging2_0 transform_(PersistenceUnit value) {
+ return (Logging2_0) ((EclipseLinkPersistenceUnit) value).getLogging();
+ }
+ };
+ }
+
+ private void addLockTimeoutCombo(Composite container) {
+ new IntegerCombo<Options2_0>(this, this.optionsModel, container) {
+ @Override
+ protected String getHelpId() {
+ return null; // TODO
+ }
+ @Override
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Options2_0, Integer>(this.getSubjectHolder()) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getDefaultLockTimeout();
+ }
+ };
+ }
+
+ @Override
+ protected ModifiablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Options2_0, Integer>(this.getSubjectHolder(), Options2_0.LOCK_TIMEOUT_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getLockTimeout();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setLockTimeout(value);
+ }
+ };
+ }
+ };
+ }
+
+ private void addQueryTimeoutCombo(Composite container) {
+ new IntegerCombo<Options2_0>(this, this.optionsModel, container) {
+ @Override
+ protected String getHelpId() {
+ return null; // TODO
+ }
+
+ @Override
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<Options2_0, Integer>(this.getSubjectHolder()) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getDefaultQueryTimeout();
+ }
+ };
+ }
+
+ @Override
+ protected ModifiablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<Options2_0, Integer>(this.getSubjectHolder(), Options2_0.QUERY_TIMEOUT_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getQueryTimeout();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setQueryTimeout(value);
+ }
+ };
+ }
+ };
+ }
+
+ private EnumFormComboViewer<PersistenceUnit, ValidationMode> addValidationModeCombo(Composite parent) {
+ return new EnumFormComboViewer<PersistenceUnit, ValidationMode>(this, this.getSubjectHolder(), parent) {
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(PersistenceUnit2_0.SPECIFIED_VALIDATION_MODE_PROPERTY);
+ }
+
+ @Override
+ protected ValidationMode[] getChoices() {
+ return ValidationMode.values();
+ }
+
+ @Override
+ protected boolean sortChoices() {
+ return false;
+ }
+
+ @Override
+ protected ValidationMode getDefaultValue() {
+ return ((PersistenceUnit2_0) this.getSubject()).getDefaultValidationMode();
+ }
+
+ @Override
+ protected String displayString(ValidationMode value) {
+ switch (value) {
+ case AUTO :
+ return JptUiPersistence2_0Messages.ValidationModeComposite_auto;
+ case CALLBACK :
+ return JptUiPersistence2_0Messages.ValidationModeComposite_callback;
+ case NONE :
+ return JptUiPersistence2_0Messages.ValidationModeComposite_none;
+ default :
+ throw new IllegalStateException();
+ }
+ }
+
+ @Override
+ protected ValidationMode getValue() {
+ return ((PersistenceUnit2_0) this.getSubject()).getSpecifiedValidationMode();
+ }
+
+ @Override
+ protected void setValue(ValidationMode value) {
+ ((PersistenceUnit2_0) this.getSubject()).setSpecifiedValidationMode(value);
+ }
+ };
+ }
+
+ // ********** ValidationGroupPrePersists **********
+
+ private void addPrePersistListPane(Composite parent) {
+ new AddRemoveListPane<Options2_0, String>(
+ this,
+ this.optionsModel,
+ parent,
+ this.buildPrePersistAdapter(),
+ this.buildPrePersistListModel(),
+ this.buildSelectedItemsModel(),
+ this.buildLabelProvider()
+ );
+ }
+
+ private Adapter<String> buildPrePersistAdapter() {
+ return new AddRemoveListPane.AbstractAdapter<String>() {
+ public String addNewItem() {
+ return addPrePersistClass();
+ }
+
+ @Override
+ public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
+ //enable the remove button only when 1 item is selected, same as the optional button
+ return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
+ }
+
+ public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
+ String item = selectedItemsModel.iterator().next();
+ optionsModel.getValue().removeValidationGroupPrePersist(item);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildPrePersistListModel() {
+ return new ListAspectAdapter<Options2_0, String>(this.optionsModel, JpaOptions2_0.VALIDATION_GROUP_PRE_PERSIST_LIST) {
+ @Override
+ protected ListIterable<String> getListIterable() {
+ return subject.getValidationGroupPrePersists();
+ }
+
+ @Override
+ protected int size_() {
+ return subject.getValidationGroupPrePersistsSize();
+ }
+ };
+ }
+
+ private String addPrePersistClass() {
+ IType type = this.chooseType();
+
+ if (type != null) {
+ String className = type.getFullyQualifiedName('$');
+ if( ! this.optionsModel.getValue().validationGroupPrePersistExists(className)) {
+ return this.optionsModel.getValue().addValidationGroupPrePersist(className);
+ }
+ }
+ return null;
+ }
+
+ // ********** ValidationGroupPreUpdates **********
+
+ private void addPreUpdateListPane(Composite parent) {
+ new AddRemoveListPane<Options2_0, String>(
+ this,
+ this.optionsModel,
+ parent,
+ this.buildPreUpdateAdapter(),
+ this.buildPreUpdateListHolder(),
+ this.buildSelectedItemsModel(),
+ this.buildLabelProvider()
+ );
+ }
+
+ private Adapter<String> buildPreUpdateAdapter() {
+ return new AddRemoveListPane.AbstractAdapter<String>() {
+ public String addNewItem() {
+ return addPreUpdateClass();
+ }
+
+ @Override
+ public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
+ //enable the remove button only when 1 item is selected, same as the optional button
+ return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
+ }
+
+ public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
+ String item = selectedItemsModel.iterator().next();
+ optionsModel.getValue().removeValidationGroupPreUpdate(item);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildPreUpdateListHolder() {
+ return new ListAspectAdapter<Options2_0, String>(this.optionsModel, Options2_0.VALIDATION_GROUP_PRE_UPDATE_LIST) {
+ @Override
+ protected ListIterable<String> getListIterable() {
+ return subject.getValidationGroupPreUpdates();
+ }
+
+ @Override
+ protected int size_() {
+ return subject.getValidationGroupPreUpdatesSize();
+ }
+ };
+ }
+
+ private String addPreUpdateClass() {
+ IType type = this.chooseType();
+
+ if (type != null) {
+ String className = type.getFullyQualifiedName('$');
+ if( ! this.optionsModel.getValue().validationGroupPreUpdateExists(className)) {
+ return this.optionsModel.getValue().addValidationGroupPreUpdate(className);
+ }
+ }
+ return null;
+ }
+
+ // ********** ValidationGroupPreRemoves **********
+
+ private void addPreRemoveListPane(Composite parent) {
+ new AddRemoveListPane<Options2_0, String>(
+ this,
+ this.optionsModel,
+ parent,
+ this.buildPreRemoveAdapter(),
+ this.buildPreRemoveListHolder(),
+ this.buildSelectedItemsModel(),
+ this.buildLabelProvider()
+ );
+ }
+
+ private Adapter<String> buildPreRemoveAdapter() {
+ return new AddRemoveListPane.AbstractAdapter<String>() {
+ public String addNewItem() {
+ return addPreRemoveClass();
+ }
+
+ @Override
+ public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
+ //enable the remove button only when 1 item is selected, same as the optional button
+ return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
+ }
+
+ public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
+ String item = selectedItemsModel.iterator().next();
+ optionsModel.getValue().removeValidationGroupPreRemove(item);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildPreRemoveListHolder() {
+ return new ListAspectAdapter<Options2_0, String>(this.optionsModel, JpaOptions2_0.VALIDATION_GROUP_PRE_REMOVE_LIST) {
+ @Override
+ protected ListIterable<String> getListIterable() {
+ return subject.getValidationGroupPreRemoves();
+ }
+
+ @Override
+ protected int size_() {
+ return subject.getValidationGroupPreRemovesSize();
+ }
+ };
+ }
+
+ private String addPreRemoveClass() {
+
+ IType type = this.chooseType();
+
+ if (type != null) {
+ String className = type.getFullyQualifiedName('$');
+ if( ! this.optionsModel.getValue().validationGroupPreRemoveExists(className)) {
+ return this.optionsModel.getValue().addValidationGroupPreRemove(className);
+ }
+ }
+ return null;
+ }
+
+
+ // ********** Private methods **********
+
+ private ILabelProvider buildLabelProvider() {
+ return new LabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ String name = (String) element;
+
+ if (name == null) {
+ name = EclipseLinkUiMessages.PersistenceXmlOptionsTab_noName;
+ }
+ return name;
+ }
+ };
+ }
+
+ /**
+ * Prompts the user the Open Type dialog.
+ *
+ * @return Either the selected type or <code>null</code> if the user
+ * canceled the dialog
+ */
+ private IType chooseType() {
+ IJavaProject javaProject = this.getSubject().getJpaProject().getJavaProject();
+ IJavaElement[] elements = new IJavaElement[] { javaProject };
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ SelectionDialog typeSelectionDialog;
+
+ try {
+ typeSelectionDialog = JavaUI.createTypeDialog(
+ getShell(),
+ service,
+ scope,
+ IJavaElementSearchConstants.CONSIDER_CLASSES,
+ false,
+ ""
+ );
+ }
+ catch (JavaModelException e) {
+ JptJpaEclipseLinkUiPlugin.instance().logError(e);
+ return null;
+ }
+
+ typeSelectionDialog.setTitle(JptCommonUiMessages.ClassChooserPane_dialogTitle);
+ typeSelectionDialog.setMessage(JptCommonUiMessages.ClassChooserPane_dialogMessage);
+
+ if (typeSelectionDialog.open() == Window.OK) {
+ return (IType) typeSelectionDialog.getResult()[0];
+ }
+
+ return null;
+ }
+
+ private ModifiableCollectionValueModel<String> buildSelectedItemsModel() {
+ return new SimpleCollectionValueModel<String>();
+ }
+
+ private PropertyValueModel<Options2_0> buildOptions2_0Model() {
+ return new TransformationPropertyValueModel<PersistenceUnit, Options2_0>(getSubjectHolder()) {
+ @Override
+ protected Options2_0 transform_(PersistenceUnit value) {
+ return (Options2_0) ((PersistenceUnit2_0) value).getOptions();
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_0EditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_0EditorPageDefinition.java
new file mode 100644
index 0000000000..d5b38345d3
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_0EditorPageDefinition.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+* Copyright (c) 2009, 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options.EclipseLinkPersistenceUnitOptionsEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class EclipseLinkPersistenceUnitOptions2_0EditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new EclipseLinkPersistenceUnitOptions2_0EditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private EclipseLinkPersistenceUnitOptions2_0EditorPageDefinition() {
+ super();
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new EclipseLinkPersistenceUnitOptions2_0EditorPage(this.buildPersistenceUnitModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+
+ public String getPageText() {
+ return EclipseLinkPersistenceUnitOptionsEditorPageDefinition.instance().getPageText();
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return EclipseLinkPersistenceUnitOptionsEditorPageDefinition.instance().getPageImageDescriptor();
+ }
+
+ public String getHelpID() {
+ return EclipseLinkPersistenceUnitOptionsEditorPageDefinition.instance().getHelpID();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_4EditorPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_4EditorPage.java
new file mode 100644
index 0000000000..e6e76b6532
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_4EditorPage.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
+
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.Section;
+
+class EclipseLinkPersistenceUnitOptions2_4EditorPage
+ extends EclipseLinkPersistenceUnitOptions2_0EditorPage {
+
+ public EclipseLinkPersistenceUnitOptions2_4EditorPage(
+ PropertyValueModel<PersistenceUnit> subjectModel,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectModel, parent, widgetFactory);
+ }
+
+ @Override
+ protected Control initializeLoggingSection(Section section) {
+ return new EclipseLinkLogging2_4Composite(this.buildLoggingModel(), section, getWidgetFactory()).getControl();
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_4EditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_4EditorPageDefinition.java
new file mode 100644
index 0000000000..d9e29703f0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceUnitOptions2_4EditorPageDefinition.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+* Copyright (c) 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options.EclipseLinkPersistenceUnitOptionsEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class EclipseLinkPersistenceUnitOptions2_4EditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new EclipseLinkPersistenceUnitOptions2_4EditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private EclipseLinkPersistenceUnitOptions2_4EditorPageDefinition() {
+ super();
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new EclipseLinkPersistenceUnitOptions2_4EditorPage(this.buildPersistenceUnitModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+
+ public String getPageText() {
+ return EclipseLinkPersistenceUnitOptionsEditorPageDefinition.instance().getPageText();
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return EclipseLinkPersistenceUnitOptionsEditorPageDefinition.instance().getPageImageDescriptor();
+ }
+
+ public String getHelpID() {
+ return EclipseLinkPersistenceUnitOptionsEditorPageDefinition.instance().getHelpID();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java
index fa38e9e159..d36bae1a34 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java
@@ -9,16 +9,20 @@
******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.ui.internal.v2_0.persistence;
+import java.util.List;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_0Definition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.EclipseLinkPersistenceXmlUiDefinition;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.connection.EclipseLinkPersistenceUnitConnectionEditorPageDefinition;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.general.EclipseLinkPersistenceUnitGeneralEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.internal.persistence.AbstractPersistenceXmlResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceXmlUiFactory;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.AbstractResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesEditorPageDefinition;
public class EclipseLinkPersistenceXml2_0UiDefinition
- extends AbstractPersistenceXmlResourceUiDefinition
+ extends AbstractResourceUiDefinition
{
// singleton
private static final ResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXml2_0UiDefinition();
@@ -29,24 +33,29 @@ public class EclipseLinkPersistenceXml2_0UiDefinition
public static ResourceUiDefinition instance() {
return INSTANCE;
}
-
-
+
+
/**
* Enforce singleton usage
*/
private EclipseLinkPersistenceXml2_0UiDefinition() {
super();
}
-
+
@Override
- protected PersistenceXmlUiFactory buildPersistenceXmlUiFactory() {
- return new EclipseLink2_0PersistenceXmlUiFactory();
+ protected void addEditorPageDefinitionsTo(List<JpaEditorPageDefinition> definitions) {
+ definitions.add(EclipseLinkPersistenceUnitGeneralEditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitConnectionEditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitCustomization2_0EditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitCaching2_0EditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitOptions2_0EditorPageDefinition.instance());
+ definitions.add(PersistenceUnitPropertiesEditorPageDefinition.instance());
}
-
+
public boolean providesUi(JptResourceType resourceType) {
return resourceType.equals(GenericPersistenceXml2_0Definition.instance().getResourceType());
}
-
+
public ItemTreeStateProviderFactoryProvider getStructureViewFactoryProvider() {
return EclipseLinkPersistenceXmlUiDefinition.STRUCTURE_VIEW_FACTORY_PROVIDER;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java
index dc3c3dbe74..34d8aea2ef 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java
@@ -9,16 +9,20 @@
******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.ui.internal.v2_0.persistence;
+import java.util.List;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_0Definition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.EclipseLinkPersistenceXmlUiDefinition;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.connection.EclipseLinkPersistenceUnitConnectionEditorPageDefinition;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.general.EclipseLinkPersistenceUnitGeneralEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.internal.persistence.AbstractPersistenceXmlResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceXmlUiFactory;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.AbstractResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesEditorPageDefinition;
public class EclipseLinkPersistenceXml2_4UiDefinition
- extends AbstractPersistenceXmlResourceUiDefinition
+ extends AbstractResourceUiDefinition
{
// singleton
private static final ResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXml2_4UiDefinition();
@@ -29,24 +33,30 @@ public class EclipseLinkPersistenceXml2_4UiDefinition
public static ResourceUiDefinition instance() {
return INSTANCE;
}
-
-
+
+
/**
* Enforce singleton usage
*/
private EclipseLinkPersistenceXml2_4UiDefinition() {
super();
}
-
+
+
@Override
- protected PersistenceXmlUiFactory buildPersistenceXmlUiFactory() {
- return new EclipseLink2_4PersistenceXmlUiFactory();
+ protected void addEditorPageDefinitionsTo(List<JpaEditorPageDefinition> definitions) {
+ definitions.add(EclipseLinkPersistenceUnitGeneralEditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitConnectionEditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitCustomization2_0EditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitCaching2_0EditorPageDefinition.instance());
+ definitions.add(EclipseLinkPersistenceUnitOptions2_4EditorPageDefinition.instance());
+ definitions.add(PersistenceUnitPropertiesEditorPageDefinition.instance());
}
-
+
public boolean providesUi(JptResourceType resourceType) {
return resourceType.equals(GenericPersistenceXml2_0Definition.instance().getResourceType());
}
-
+
public ItemTreeStateProviderFactoryProvider getStructureViewFactoryProvider() {
return EclipseLinkPersistenceXmlUiDefinition.STRUCTURE_VIEW_FACTORY_PROVIDER;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlOptions2_4Tab.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlOptions2_4Tab.java
deleted file mode 100644
index 46b4665bbc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/PersistenceXmlOptions2_4Tab.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2012 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.jpa.eclipselink.ui.internal.v2_0.persistence;
-
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * PersistenceXmlLogging2_4Tab
- */
-
-public class PersistenceXmlOptions2_4Tab extends PersistenceXmlOptions2_0Tab {
-
- // ********** constructors/initialization **********
- public PersistenceXmlOptions2_4Tab(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
-}
-
-
- @Override
- protected Control initializeLoggingSection(Section section) {
- return new EclipseLinkLogging2_4Composite(this.buildLoggingHolder(), section, getWidgetFactory()).getControl();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
index 06b447006d..0f59732ca7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
@@ -355,7 +355,7 @@
point="org.eclipse.ui.editors">
<editor
- class="org.eclipse.jpt.jpa.ui.internal.editors.PersistenceEditor"
+ class="org.eclipse.jpt.jpa.ui.internal.editors.JpaXmlEditor"
contributorClass="org.eclipse.jpt.jpa.ui.internal.editors.PersistenceContributor"
icon="$nl$/icons/full/obj16/jpa-file.gif"
id="org.eclipse.jpt.jpa.ui.internal.editors.PersistenceEditor"
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties
index 068f29b54a..b3685486d4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties
@@ -211,3 +211,6 @@ SetJpaSelection_jobName=Setting JPA selection...
JpaXmlCompletionProposalComputer_SpecialNameMsg=Special name will be written in the XML differently from what is shown in the proposal list for its legal usage.
JpaPlatformUi_missingJpaPlatform = Invalid JPA platform ''{0}'' specified in extension ''{1}'' from plug-in ''{2}''.
+
+JpaXmlEditor_page_help=Help
+JpaXmlEditor_sourcePage=Source
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_persistence.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_persistence.properties
index f9cdc7ad3f..6504ad1a81 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_persistence.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_persistence.properties
@@ -1,5 +1,5 @@
################################################################################
-# Copyright (c) 2006, 2009 Oracle. All rights reserved.
+# Copyright (c) 2006, 2012 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.
@@ -11,9 +11,6 @@
ArchiveFileSelectionDialog_jarPathHelpLabel=The correct path to the JAR file selected will vary on your runtime environment. You may alter it here to correctly reflect your particular environment.
ArchiveFileSelectionDialog_jarPathLabel=JAR file path:
-PersistenceEditor_page_help=Help
-PersistenceEditor_sourceTab=Source
-
PersistenceUnitClassesComposite_description=Specify the list of classes to be managed in this persistence unit.
PersistenceUnitClassesComposite_excludeUnlistedMappedClasses=Exclude unlisted classes
PersistenceUnitClassesComposite_excludeUnlistedMappedClassesWithDefault=Exclude unlisted classes ({0})
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceXmlResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceXmlResourceUiDefinition.java
deleted file mode 100644
index 14d85ea95e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceXmlResourceUiDefinition.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 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.jpa.ui;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface PersistenceXmlResourceUiDefinition extends ResourceUiDefinition
-{
- ListIterator<JpaPageComposite> buildPersistenceUnitComposites(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/ResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/ResourceUiDefinition.java
index fb55b620d5..db68ac6874 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/ResourceUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/ResourceUiDefinition.java
@@ -11,6 +11,8 @@ package org.eclipse.jpt.jpa.ui;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
/**
* Resource UI definition.
@@ -34,4 +36,15 @@ public interface ResourceUiDefinition {
* labels.
*/
ItemTreeStateProviderFactoryProvider getStructureViewFactoryProvider();
+
+ /**
+ * Return the <code>JpaEditorPageDefinition</code>'s to be displayed
+ * as tabs for an editor for the resource.
+ * <p>
+ * Currently we only have a persistence.xml editor
+ *
+ * @see org.eclipse.jpt.jpa.ui.internal.editors.JpaXmlEditor
+ */
+ ListIterable<JpaEditorPageDefinition> getEditorPageDefinitions();
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/editors/JpaPageComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/editors/JpaEditorPageDefinition.java
index e0031ae4d6..bc5225714d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/editors/JpaPageComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/editors/JpaEditorPageDefinition.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2012 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.
@@ -10,11 +10,21 @@
package org.eclipse.jpt.jpa.ui.editors;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jpt.jpa.ui.details.JpaComposite;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.ui.forms.IManagedForm;
/**
- * A {@link JpaPageComposite} defines the common behavior of the JPA
- * related widgets that is shown as a page within an editor.
+ * A {@link JpaEditorPageDefinition} defines the content of an editor page.
+ * We take advantage of the FormEditor behavior by not building the content
+ * of any particular editor page until that tab is selected. At this point
+ * {@link #buildEditorPageContent(IManagedForm, WidgetFactory, PropertyValueModel)}
+ * will be called.
+ *
+ * @see org.eclipse.jpt.jpa.ui.ResourceUiDefinition
+ * @see org.eclipse.jpt.jpa.ui.internal.editors.JpaXmlEditor
+ *
* <p>
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -22,7 +32,7 @@ import org.eclipse.jpt.jpa.ui.details.JpaComposite;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*/
-public interface JpaPageComposite extends JpaComposite {
+public interface JpaEditorPageDefinition {
/**
* Returns the help ID. This ID will be used if the help button is invoked.
@@ -33,7 +43,7 @@ public interface JpaPageComposite extends JpaComposite {
String getHelpID();
/**
- * The image of the tab showing this page.
+ * The image descriptor of the tab showing this page.
*
* @return The page's image
*/
@@ -45,4 +55,10 @@ public interface JpaPageComposite extends JpaComposite {
* @return The page's text
*/
String getPageText();
+
+ /**
+ * Build the content of this editor page using the given WidgetFactory
+ * and the JpaStructureNode model.
+ */
+ void buildEditorPageContent(IManagedForm form, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> rootStructureNodeModel);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractResourceUiDefinition.java
new file mode 100644
index 0000000000..a969982210
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractResourceUiDefinition.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 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.jpa.ui.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+
+/**
+ * All the state in the definition should be "static" (i.e. unchanging once it is initialized).
+ */
+public abstract class AbstractResourceUiDefinition
+ implements ResourceUiDefinition
+{
+
+ private ArrayList<JpaEditorPageDefinition> editorPageDefinitions;
+
+
+ /**
+ * zero-argument constructor
+ */
+ protected AbstractResourceUiDefinition() {
+ super();
+ }
+
+ public synchronized ListIterable<JpaEditorPageDefinition> getEditorPageDefinitions() {
+ if (this.editorPageDefinitions == null) {
+ this.editorPageDefinitions = this.buildEditorPageDefinitions();
+ }
+ return IterableTools.listIterable(this.editorPageDefinitions);
+ }
+
+ protected ArrayList<JpaEditorPageDefinition> buildEditorPageDefinitions() {
+ ArrayList<JpaEditorPageDefinition> definitions = new ArrayList<JpaEditorPageDefinition>();
+ this.addEditorPageDefinitionsTo(definitions);
+ return definitions;
+ }
+
+ /**
+ * Override to add the appropriate <code>JpaEditorPageDefinitions</code>
+ * @param definitions
+ */
+ protected void addEditorPageDefinitionsTo(List<JpaEditorPageDefinition> definitions) {
+ //subclasses override
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java
index 17127ca7bd..9d8d669bb0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java
@@ -199,6 +199,9 @@ public class JptUiMessages {
public static String JpaPlatformUi_missingJpaPlatform;
+ public static String JpaXmlEditor_page_help;
+ public static String JpaXmlEditor_sourcePage;
+
private JptUiMessages() {
throw new UnsupportedOperationException();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java
index 108f6e02da..12e85675fa 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java
@@ -31,6 +31,7 @@ import org.eclipse.jpt.jpa.ui.details.java.DefaultJavaTypeMappingUiDefinition;
import org.eclipse.jpt.jpa.ui.details.java.JavaAttributeMappingUiDefinition;
import org.eclipse.jpt.jpa.ui.details.java.JavaTypeMappingUiDefinition;
import org.eclipse.jpt.jpa.ui.details.java.JavaUiFactory;
+import org.eclipse.jpt.jpa.ui.internal.AbstractResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.structure.JavaStructureItemContentProviderFactory;
import org.eclipse.jpt.jpa.ui.internal.structure.JavaStructureItemLabelProviderFactory;
import org.eclipse.swt.widgets.Composite;
@@ -40,6 +41,7 @@ import org.eclipse.swt.widgets.Composite;
* (i.e. unchanging once it is initialized).
*/
public abstract class AbstractJavaResourceUiDefinition
+ extends AbstractResourceUiDefinition
implements MappingResourceUiDefinition
{
private final JavaUiFactory factory;
@@ -210,4 +212,5 @@ public abstract class AbstractJavaResourceUiDefinition
}
protected abstract void addDefaultAttributeMappingUiDefinitionsTo(List<DefaultJavaAttributeMappingUiDefinition<?>> definitions);
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java
index 24cc2084bc..6f2654dbc4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmXmlResourceUiDefinition.java
@@ -26,12 +26,14 @@ import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition;
import org.eclipse.jpt.jpa.ui.details.orm.OrmAttributeMappingUiDefinition;
import org.eclipse.jpt.jpa.ui.details.orm.OrmTypeMappingUiDefinition;
import org.eclipse.jpt.jpa.ui.details.orm.OrmXmlUiFactory;
+import org.eclipse.jpt.jpa.ui.internal.AbstractResourceUiDefinition;
import org.eclipse.swt.widgets.Composite;
/**
* All the state in the definition should be "static" (i.e. unchanging once it is initialized).
*/
public abstract class AbstractOrmXmlResourceUiDefinition
+ extends AbstractResourceUiDefinition
implements MappingResourceUiDefinition
{
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/JpaXmlEditor.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/JpaXmlEditor.java
new file mode 100644
index 0000000000..478db28b96
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/JpaXmlEditor.java
@@ -0,0 +1,511 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.ui.internal.editors;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jpt.common.core.JptResourceType;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.ui.internal.widgets.FormWidgetFactory;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.internal.StringBuilderTools;
+import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.CollectionPropertyValueModelAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.DoublePropertyValueModel;
+import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
+import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
+import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
+import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+import org.eclipse.jpt.jpa.core.JpaFile;
+import org.eclipse.jpt.jpa.core.JpaPlatform;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.ui.JpaFileModel;
+import org.eclipse.jpt.jpa.ui.JpaPlatformUi;
+import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
+import org.eclipse.jpt.jpa.ui.internal.plugin.JptJpaUiPlugin;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.part.MultiPageEditorSite;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+
+/**
+ * This is an implementation of a multi-page editor that includes an
+ * XML source editor source tab as the last tab. The other tabs
+ * are defined by {@link ResourceUiDefinition#getEditorPageDefinitions()}
+ * The ResourceUiDefinition is found from the <code>JptResourceType</code> of the
+ * <code>JpaFile</code>
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public class JpaXmlEditor
+ extends FormEditor
+{
+
+ /**
+ * The IFileEditorInput model
+ */
+ private final ModifiablePropertyValueModel<IFileEditorInput> editorInputModel = new SimplePropertyValueModel<IFileEditorInput>();
+
+ /**
+ * The one we listen to
+ */
+ private PropertyValueModel<JpaStructureNode> rootStructureNodeModel;
+
+ private final PropertyChangeListener rootStructureNodeListener = new RootStructureNodeListener();
+
+ /**
+ * The one to be passed to the Page
+ */
+ private ModifiablePropertyValueModel<JpaStructureNode> pageRootStructureNodeModel;
+
+
+ /**
+ * The XML source text editor.
+ */
+ private final StructuredTextEditor structuredTextEditor;
+
+ /**
+ * The factory used to create the various widgets.
+ */
+ private final WidgetFactory widgetFactory;
+
+ /**
+ * The local resource manager, used to create/destroy Images
+ */
+ final ResourceManager localResourceManager;
+
+
+ public JpaXmlEditor() {
+ super();
+ this.localResourceManager = new LocalResourceManager(JFaceResources.getResources());
+ this.widgetFactory = this.buildWidgetFactory();
+ this.structuredTextEditor = new StructuredTextEditor();
+ this.structuredTextEditor.setEditorPart(this);
+ }
+
+ private WidgetFactory buildWidgetFactory() {
+ return new FormWidgetFactory(
+ new TabbedPropertySheetWidgetFactory()
+ );
+ }
+
+ @Override
+ public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
+ Assert.isLegal(editorInput instanceof IFileEditorInput, "Invalid Input: Must be IFileEditorInput"); //$NON-NLS-1$
+ super.init(site, editorInput);
+
+ this.setPartName(editorInput.getName());
+ this.rootStructureNodeModel = this.buildRootStructureNodeModel();
+ this.rootStructureNodeModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.rootStructureNodeListener);
+ }
+
+ @Override
+ protected void setInput(IEditorInput editorInput) {
+ super.setInput(editorInput);
+ this.editorInputModel.setValue((IFileEditorInput) editorInput);
+ }
+
+ @Override
+ protected void setInputWithNotify(IEditorInput editorInput) {
+ super.setInputWithNotify(editorInput);
+ this.editorInputModel.setValue((IFileEditorInput) editorInput);
+ }
+
+ @Override
+ protected void addPages() {
+ this.addXMLSourceEditorPage();
+ //TODO this.addXMLDesignEditorPage();
+ if (this.getRootStructureNode() != null) {
+ this.setPageRootStructureNode_(this.getRootStructureNode());
+ this.setActivePage(0);
+ }
+ }
+
+ /**
+ * Adds the page containing the XML source editor.
+ */
+ protected void addXMLSourceEditorPage() {
+ try {
+ int index = this.addPage(this.structuredTextEditor, this.getEditorInput());
+ this.setPageText(index, JptUiMessages.JpaXmlEditor_sourcePage);
+ }
+ catch (PartInitException e) {
+ JptJpaUiPlugin.instance().logError(e);
+ }
+ }
+
+ /**
+ * Add the pages for editing the selected JpaStructureNode. These
+ * will be the pages that come before the XML source editor.
+ * <p>
+ * @see #getRootStructureNode()
+ * @see Page
+ */
+ protected void addSpecificPages() {
+ JptResourceType resourceType = this.getRootStructureNode().getResourceType();
+ if (resourceType == null) {
+ return; // might not ever get here... (if we have a p.xml, it probably has a resource type...)
+ }
+
+ JpaPlatform jpaPlatform = this.getRootStructureNode().getJpaPlatform();
+ JpaPlatformUi jpaPlatformUI = (JpaPlatformUi) jpaPlatform.getAdapter(JpaPlatformUi.class);
+ ResourceUiDefinition definition = jpaPlatformUI.getResourceUiDefinition(resourceType);
+
+ ListIterable<JpaEditorPageDefinition> pageDefinitions = definition.getEditorPageDefinitions();
+
+ for (JpaEditorPageDefinition editorPageDefinition : pageDefinitions) {
+ FormPage formPage = new Page(editorPageDefinition);
+
+ int index = this.getPageCount() == 0 ? 0 : this.getPageCount() - 1;//always keep the source tab as the last tab
+ try {
+ this.addPage(index, formPage);
+ }
+ catch (PartInitException e) {
+ JptJpaUiPlugin.instance().logError(e);
+ }
+ }
+ }
+
+ @Override
+ protected IEditorSite createSite(IEditorPart editor) {
+ if (editor == this.structuredTextEditor) {
+ return new MultiPageEditorSite(this, editor) {
+ @Override
+ public String getId() {
+ // sets this id so nested editor is considered an xml source page
+ // I know this makes the XML source toolbar buttons appear on all
+ // the tabs instead of just the Source tab, not sure what else it does ~kfb
+ return "org.eclipse.core.runtime.xml.source"; //$NON-NLS-1$;
+ }
+ };
+ }
+ return super.createSite(editor);
+ }
+
+ /**
+ * Delegate to the {@link #structuredTextEditor} if necessary.
+ */
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapterClass) {
+ Object adapter = super.getAdapter(adapterClass);
+ return (adapter != null) ? adapter : this.structuredTextEditor.getAdapter(adapterClass);
+ }
+
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ this.structuredTextEditor.doSave(monitor);
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ @Override
+ public void doSaveAs() {
+ // do nothing
+ }
+
+
+ // ********** JPA file **********
+
+ private PropertyValueModel<JpaFile> buildJpaFileModel() {
+ return new DoublePropertyValueModel<JpaFile>(this.buildJpaFileModelModel());
+ }
+
+ private PropertyValueModel<PropertyValueModel<JpaFile>> buildJpaFileModelModel() {
+ return new TransformationPropertyValueModel<IFileEditorInput, PropertyValueModel<JpaFile>>(this.editorInputModel, JPA_FILE_MODEL_TRANSFORMER);
+ }
+
+ private static final Transformer<IFileEditorInput, PropertyValueModel<JpaFile>> JPA_FILE_MODEL_TRANSFORMER = new JpaFileModelTransformer();
+
+ /* CU private */ static class JpaFileModelTransformer
+ extends AbstractTransformer<IFileEditorInput, PropertyValueModel<JpaFile>>
+ {
+ @Override
+ protected PropertyValueModel<JpaFile> transform_(IFileEditorInput fileEditorInput) {
+ return (JpaFileModel) fileEditorInput.getFile().getAdapter(JpaFileModel.class);
+ }
+ }
+
+ /* CU private */ class RootStructureNodeListener
+ extends PropertyChangeAdapter
+ {
+ @Override
+ public void propertyChanged(PropertyChangeEvent event) {
+ JpaXmlEditor.this.setPageRootStructureNode((JpaStructureNode) event.getNewValue());
+ }
+ }
+
+ /* CU private */ void setPageRootStructureNode(JpaStructureNode jpaStructureNode) {
+ this.execute(new SetPageRootStructureNodeRunnable(jpaStructureNode));
+ }
+
+ protected void setPageRootStructureNode_(JpaStructureNode rootStructureNode) {
+ if (this.pageRootStructureNodeModel != null) {
+ this.pageRootStructureNodeModel.setValue(null);
+ this.pageRootStructureNodeModel = null;
+ }
+
+ while (this.getPageCount() > 1) {//don't remove the XML Editor page
+ //set the XML source editor to be the active page before removing the other pages.
+ //If I don't do this and the active page gets removed it will build the contents
+ //of the next page. I don't want to do this since I'm trying to remove all the
+ //pages except the xml source page.
+ this.setActivePage(getPageCount() - 1);
+ this.removePage(0);
+ }
+ if (rootStructureNode != null) {
+ this.pageRootStructureNodeModel = new SimplePropertyValueModel<JpaStructureNode>(rootStructureNode);
+ this.addSpecificPages();
+ }
+ }
+
+ protected JpaStructureNode getRootStructureNode() {
+ return this.rootStructureNodeModel.getValue();
+ }
+
+ //*should* be only 1 root structure node for the jpa file (this is true for persistence.xml and orm.xml files)
+ protected PropertyValueModel<JpaStructureNode> buildRootStructureNodeModel() {
+ return new CollectionPropertyValueModelAdapter<JpaStructureNode, JpaStructureNode>(this.buildRootStructureNodesCollectionModel()) {
+ @Override
+ protected JpaStructureNode buildValue() {
+ return this.collectionModel.size() > 0 ? this.collectionModel.iterator().next() : null;
+ }
+ };
+ }
+
+ protected CollectionValueModel<JpaStructureNode> buildRootStructureNodesCollectionModel() {
+ return new CollectionAspectAdapter<JpaFile, JpaStructureNode>(this.buildJpaFileModel(), JpaFile.ROOT_STRUCTURE_NODES_COLLECTION) {
+ @Override
+ protected Iterable<JpaStructureNode> getIterable() {
+ return this.subject.getRootStructureNodes();
+ }
+
+ @Override
+ protected int size_() {
+ return this.subject.getRootStructureNodesSize();
+ }
+ };
+ }
+
+ /* CU private */ class SetPageRootStructureNodeRunnable
+ implements Runnable
+ {
+ private final JpaStructureNode jpaStructureNode;
+
+ SetPageRootStructureNodeRunnable(JpaStructureNode jpaStructureNode) {
+ super();
+ this.jpaStructureNode = jpaStructureNode;
+ }
+
+ public void run() {
+ JpaXmlEditor.this.setPageRootStructureNode_(this.jpaStructureNode);
+ }
+
+ @Override
+ public String toString() {
+ return ObjectTools.toString(this, this.jpaStructureNode);
+ }
+ }
+
+
+
+ @Override
+ public void dispose() {
+ this.editorInputModel.setValue(null);
+ this.localResourceManager.dispose();
+ this.rootStructureNodeModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.rootStructureNodeListener);
+
+ super.dispose();
+ }
+
+
+ // ********** misc **********
+
+ @Override
+ public IFileEditorInput getEditorInput() {
+ return (IFileEditorInput) super.getEditorInput();
+ }
+
+ public WidgetFactory getWidgetFactory() {
+ return this.widgetFactory;
+ }
+
+ private void execute(Runnable runnable) {
+ SWTUtil.execute(this.getSite().getShell().getDisplay(), runnable);
+ }
+
+ @Override
+ public String toString() {
+ return ObjectTools.toString(this, this.editorInputModel.getValue().getFile());
+ }
+
+
+ // ********** form page **********
+
+ /**
+ * This extension over <code>FormPage</code> simply completes the layout by
+ * using the <code>JpaEditorPageDefinition</code>
+ *
+ * @see JpaEditorPageDefinition#buildEditorPageContent(IManagedForm, WidgetFactory, PropertyValueModel)
+ */
+ class Page
+ extends FormPage
+ {
+ /**
+ * The editor page definition, find the page's text, image, help ID
+ * and build the content.
+ */
+ private final JpaEditorPageDefinition editorPageDefinition;
+
+ /**
+ * The FormPage's image descriptor, stored so that we can dispose of it.
+ */
+ private ImageDescriptor imageDescriptor;
+
+ Page(JpaEditorPageDefinition editorPageDefinition) {
+ super(JpaXmlEditor.this,
+ editorPageDefinition.getClass().getName(),
+ editorPageDefinition.getPageText());
+
+ this.editorPageDefinition = editorPageDefinition;
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+
+ ScrolledForm form = managedForm.getForm();
+ managedForm.getToolkit().decorateFormHeading(form.getForm());
+
+ // Update the text and image
+ updateForm(form);
+
+ // Update the layout
+ updateBody(managedForm);
+
+ // This will finish the initialization of the buttons
+ updateHelpButton();
+ form.updateToolBar();
+ }
+
+ /**
+ * Updates the text and image of the form. The image can be null.
+ *
+ */
+ private void updateForm(ScrolledForm form) {
+ form.setText(this.editorPageDefinition.getPageText());
+
+ this.imageDescriptor = this.editorPageDefinition.getPageImageDescriptor();
+ if (this.imageDescriptor != null) {
+ form.setImage(JpaXmlEditor.this.localResourceManager.createImage(this.imageDescriptor));
+ }
+ }
+
+ /**
+ * Adds the page's control to this page.
+ */
+ private void updateBody(IManagedForm form) {
+ Composite body = form.getForm().getBody();
+ body.setLayout(new GridLayout(1, true));
+
+ this.editorPageDefinition.buildEditorPageContent(form, getWidgetFactory(), JpaXmlEditor.this.pageRootStructureNodeModel);
+ //calling this because it makes the scroll bar appear on the editor tabs when the content
+ //is larger than the editor tab area. Not sure how else to make this happen
+ form.reflow(true);
+ }
+
+ /**
+ * Adds a help button to the page's toolbar if a help ID exists.
+ */
+ private void updateHelpButton() {
+ String helpID = this.editorPageDefinition.getHelpID();
+
+ if (helpID != null) {
+ Action helpAction = new HelpAction(helpID);
+
+ ScrolledForm form = getManagedForm().getForm();
+ IToolBarManager manager = form.getToolBarManager();
+ manager.add(helpAction);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ JpaXmlEditor.this.localResourceManager.destroyImage(this.imageDescriptor);
+ super.dispose();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ StringBuilderTools.appendHashCodeToString(sb, this);
+ sb.append('(');
+ sb.append(this.editorPageDefinition.getPageText());
+ sb.append(')');
+ return sb.toString();
+ }
+
+ private class HelpAction
+ extends Action
+ {
+ final String helpID;
+
+ HelpAction(String helpID) {
+ super(JptUiMessages.JpaXmlEditor_page_help);
+ this.helpID = helpID;
+ }
+
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_LCL_LINKTO_HELP);
+ }
+
+ @Override
+ public void run() {
+ BusyIndicator.showWhile(getManagedForm().getForm().getDisplay(), new Runnable() {
+ public void run() {
+ PlatformUI.getWorkbench().getHelpSystem().displayHelp(HelpAction.this.helpID);
+ }
+ });
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceEditor.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceEditor.java
deleted file mode 100644
index 4081c0952b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/editors/PersistenceEditor.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 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.jpa.ui.internal.editors;
-
-import java.util.ListIterator;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.resource.LocalResourceManager;
-import org.eclipse.jface.resource.ResourceManager;
-import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.ui.internal.widgets.FormWidgetFactory;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.ListPropertyValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.iterable.ListIterable;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
-import org.eclipse.jpt.jpa.core.context.XmlFile;
-import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
-import org.eclipse.jpt.jpa.ui.JpaPlatformUi;
-import org.eclipse.jpt.jpa.ui.PersistenceXmlResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.jpt.jpa.ui.internal.persistence.JptUiPersistenceMessages;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-
-/**
- * This is the editor for the JPA Persistence Configuration (persistence.xml).
- * The pages shown before the XML source editor are retrieved from the
- * <code>JpaUiFactory</code>.
- *
- * @version 2.3
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public class PersistenceEditor
- extends FormEditor
-{
- /**
- * The XML text editor.
- */
- private StructuredTextEditor editor;
-
- /**
- * The root of the holders used to retrieve the persistence unit and be
- * notified when it changes.
- */
- private ModifiablePropertyValueModel<IFileEditorInput> editorInputHolder;
-
- /**
- * The factory used to create the various widgets.
- */
- private WidgetFactory widgetFactory;
-
- final ResourceManager resourceManager;
-
- /**
- * Creates a new <code>PersistenceEditor</code>.
- */
- public PersistenceEditor() {
- super();
- this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
- initialize();
- }
-
- /**
- * Delegate to the {@link #editor} if necessary.
- */
- @Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapterClass) {
- Object adapter = super.getAdapter(adapterClass);
- return (adapter != null) ? adapter : this.editor.getAdapter(adapterClass);
- }
-
- @Override
- protected void addPages() {
- addPersistenceUnitPages();
- addXMLEditorPage();
- }
-
- /**
- * Adds the pages that show the properties of the persistence configuration
- * or its persistence units.
- */
- private void addPersistenceUnitPages() {
-
- JpaProject jpaProject = getJpaProject();
-
- // The project doesn't have JPA
- if (jpaProject == null) {
- return;
- }
-
- PersistenceXml persistenceXml = jpaProject.getRootContextNode().getPersistenceXml();
- if (persistenceXml == null) {
- return;
- }
- JptResourceType resourceType = persistenceXml.getResourceType();
- if (resourceType == null) {
- return; // might not ever get here... (if we have a p.xml, it probably has a resource type...)
- }
- JpaPlatformUi jpaPlatformUI = (JpaPlatformUi) jpaProject.getJpaPlatform().getAdapter(JpaPlatformUi.class);
- PersistenceXmlResourceUiDefinition definition =
- (PersistenceXmlResourceUiDefinition) jpaPlatformUI.getResourceUiDefinition(resourceType);
-
- ListIterator<JpaPageComposite> puPages = definition.buildPersistenceUnitComposites(
- buildPersistenceUnitHolder(),
- getContainer(),
- this.widgetFactory
- );
-
- while (puPages.hasNext()) {
- JpaPageComposite page = puPages.next();
-
- try {
- FormPage formPage = new Page(page);
- addPage(formPage);
- }
- catch (PartInitException e) {
- // TODO
- }
- }
- }
-
- /**
- * Adds the page containing the XML editor.
- */
- private void addXMLEditorPage() {
- try {
- editor = new StructuredTextEditor();
- editor.setEditorPart(this);
- int index = addPage(editor, getEditorInput());
- setPageText(index, JptUiPersistenceMessages.PersistenceEditor_sourceTab);
- }
- catch (PartInitException e) {
- // TODO
- }
- }
-
- private ModifiablePropertyValueModel<IFileEditorInput> buildEditorInputHolder() {
- return new SimplePropertyValueModel<IFileEditorInput>();
- }
-
- private PropertyValueModel<JpaProject> buildJpaProjectHolder() {
- return new TransformationPropertyValueModel<IFileEditorInput, JpaProject>(this.editorInputHolder) {
- @Override
- protected JpaProject transform_(IFileEditorInput fileEditorInput) {
- return PersistenceEditor.this.getJpaProject(fileEditorInput.getFile().getProject());
- }
- };
- }
-
- private PropertyValueModel<Persistence> buildPersistenceHolder() {
- return new PropertyAspectAdapter<PersistenceXml, Persistence>(buildPersistenceXmlHolder(), XmlFile.ROOT_PROPERTY) {
- @Override
- protected Persistence buildValue_() {
- return subject.getRoot();
- }
- };
- }
-
- private PropertyValueModel<PersistenceUnit> buildPersistenceUnitHolder() {
- return new ListPropertyValueModelAdapter<PersistenceUnit>(buildPersistenceUnitListHolder()) {
- @Override
- protected PersistenceUnit buildValue() {
- return listModel.size() > 0 ? (PersistenceUnit) listModel.get(0) : null;
- }
- };
- }
-
- private ListValueModel<PersistenceUnit> buildPersistenceUnitListHolder() {
- return new ListAspectAdapter<Persistence, PersistenceUnit>(buildPersistenceHolder(), Persistence.PERSISTENCE_UNITS_LIST) {
- @Override
- protected ListIterable<PersistenceUnit> getListIterable() {
- return subject.getPersistenceUnits();
- }
-
- @Override
- protected int size_() {
- return subject.getPersistenceUnitsSize();
- }
- };
- }
-
- private PropertyValueModel<PersistenceXml> buildPersistenceXmlHolder() {
- return new PropertyAspectAdapter<JpaRootContextNode, PersistenceXml>(buildRootContextNodeHolder(), JpaRootContextNode.PERSISTENCE_XML_PROPERTY) {
- @Override
- protected PersistenceXml buildValue_() {
- return subject.getPersistenceXml();
- }
- };
- }
-
- private PropertyValueModel<JpaRootContextNode> buildRootContextNodeHolder() {
- return new TransformationPropertyValueModel<JpaProject, JpaRootContextNode>(buildJpaProjectHolder()) {
- @Override
- protected JpaRootContextNode transform_(JpaProject jpaProject) {
- return jpaProject.getRootContextNode();
- }
- };
- }
-
- private WidgetFactory buildWidgetFactory() {
- return new FormWidgetFactory(
- new TabbedPropertySheetWidgetFactory()
- );
- }
-
- @Override
- public void dispose() {
- this.editorInputHolder.setValue(null);
- this.resourceManager.dispose();
- super.dispose();
- }
-
- @Override
- public void doSave(IProgressMonitor monitor) {
- getEditor(getPageCount() - 1).doSave(monitor);
- }
-
- @Override
- public void doSaveAs() {
- // do nothing
- }
-
- @Override
- public IFileEditorInput getEditorInput() {
- return (IFileEditorInput) super.getEditorInput();
- }
-
- @Override
- public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
- Assert.isLegal(editorInput instanceof IFileEditorInput, "Invalid Input: Must be IFileEditorInput");
- super.init(site, editorInput);
-
- setPartName(editorInput.getName());
- editorInputHolder.setValue(getEditorInput());
- }
-
- /**
- * Initializes this multi-page editor.
- */
- private void initialize() {
-
- widgetFactory = buildWidgetFactory();
- editorInputHolder = buildEditorInputHolder();
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- /**
- * Retrieves the JPA project associated with the project owning the editor
- * intput file.
- *
- * @return The JPA project
- */
- protected JpaProject getJpaProject() {
- return this.getJpaProject(getEditorInput().getFile().getProject());
- }
-
- protected JpaProject getJpaProject(IProject project) {
- return (JpaProject) project.getAdapter(JpaProject.class);
- }
-
- /**
- * This extension over <code>FormPage</code> simply complete the layout by
- * using the <code>JpaPageComposite</code>'s control as its form content.
- */
- class Page
- extends FormPage
- {
- /**
- * The wrapped page that actually contains the widgets to show with this
- * form page.
- */
- private final JpaPageComposite page;
-
- private ImageDescriptor imageDescriptor;
-
- /**
- * Creates a new <code>Page</code>.
- *
- * @param page The wrapped <code>JpaPageComposite</code>
- */
- Page(JpaPageComposite page) {
-
- super(PersistenceEditor.this,
- page.getClass().getName(),
- page.getPageText());
-
- this.page = page;
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
-
- ScrolledForm form = managedForm.getForm();
- managedForm.getToolkit().decorateFormHeading(form.getForm());
-
- // Update the text and image
- updateForm(form);
-
- // Update the layout
- updateBody(form);
-
- // This will finish the initialization of the buttons
- updateHelpButton();
- form.updateToolBar();
- }
-
- @Override
- public void dispose() {
- if (this.imageDescriptor != null) {
- PersistenceEditor.this.resourceManager.destroyImage(this.imageDescriptor);
- }
- super.dispose();
- }
-
- @Override
- public void setFocus() {
- this.page.getControl().setFocus();
- }
-
- /**
- * Adds the page's control to this page.
- *
- * @param form The form containing the composite with which the page's
- * control is parented
- */
- private void updateBody(ScrolledForm form) {
-
- Composite body = form.getBody();
-
- body.setLayout(new TableWrapLayout());
-
- TableWrapData wrapData = new TableWrapData(
- TableWrapData.FILL_GRAB,
- TableWrapData.FILL_GRAB
- );
-
- this.page.getControl().setLayoutData(wrapData);
- this.page.getControl().setParent(body);
- }
-
- /**
- * Updates the text and image of the form.
- *
- * @param form The form to have its title bar updated by setting the text
- * and image, the image can be <code>null</code>
- */
- private void updateForm(ScrolledForm form) {
- form.setText(this.page.getPageText());
-
- this.imageDescriptor = this.page.getPageImageDescriptor();
- if (this.imageDescriptor != null) {
- form.setImage(PersistenceEditor.this.resourceManager.createImage(this.imageDescriptor));
- }
- }
-
- /**
- * Adds a help button to the page's toolbar if a help ID exists.
- */
- private void updateHelpButton() {
-
- String helpID = this.page.getHelpID();
-
- if (helpID != null) {
- Action helpAction = new HelpAction(helpID);
-
- ScrolledForm form = getManagedForm().getForm();
- IToolBarManager manager = form.getToolBarManager();
- manager.add(helpAction);
- }
- }
-
- private class HelpAction
- extends Action
- {
- final String helpID;
-
- HelpAction(String helpID) {
- super(JptUiPersistenceMessages.PersistenceEditor_page_help,
- JFaceResources.getImageRegistry().getDescriptor(Dialog.DLG_IMG_HELP));
-
- this.helpID = helpID;
- }
-
- @Override
- public void run() {
- BusyIndicator.showWhile(getManagedForm().getForm().getDisplay(), new Runnable() {
- public void run() {
- PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpID);
- }
- });
- }
- }
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaUiFactory.java
index 4379759d8b..68786d3bfc 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaUiFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/java/Generic2_0JavaUiFactory.java
@@ -26,7 +26,6 @@ import org.eclipse.jpt.jpa.ui.details.JpaComposite;
import org.eclipse.jpt.jpa.ui.internal.details.java.BaseJavaUiFactory;
import org.eclipse.jpt.jpa.ui.internal.jpa2.details.ElementCollectionMapping2_0Composite;
import org.eclipse.jpt.jpa.ui.internal.jpa2.details.EmbeddedIdMapping2_0Composite;
-import org.eclipse.jpt.jpa.ui.internal.persistence.GenericPersistenceXmlUiFactory;
import org.eclipse.jpt.jpa.ui.jpa2.details.java.JavaUiFactory2_0;
import org.eclipse.swt.widgets.Composite;
@@ -34,8 +33,6 @@ import org.eclipse.swt.widgets.Composite;
* The default implementation of the UI factory required to show the information
* related to a JPA mapping (type or attribute).
*
- * @see GenericPersistenceXmlUiFactory
- *
* @version 1.0
* @since 1.0
*/
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/Generic2_0PersistenceXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/Generic2_0PersistenceXmlUiFactory.java
deleted file mode 100644
index 8fd80ef90c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/Generic2_0PersistenceXmlUiFactory.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 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.jpa.ui.internal.jpa2.persistence;
-
-import java.util.ArrayList;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.jpt.jpa.ui.internal.persistence.GenericPersistenceUnitGeneralTab;
-import org.eclipse.jpt.jpa.ui.internal.persistence.GenericPersistenceXmlUiFactory;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesTab;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceXmlUiFactory;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * The default implementation of the UI factory required to show the information
- * related to a JPA mapping (type or attribute).
- *
- * @see GenericPersistenceXmlUiFactory
- *
- * @version 1.0
- * @since 1.0
- */
-public class Generic2_0PersistenceXmlUiFactory implements PersistenceXmlUiFactory
-{
-
- // **************** persistence unit composites ****************************
- public ListIterator<JpaPageComposite> createPersistenceUnitComposites(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- ArrayList<JpaPageComposite> pages = new ArrayList<JpaPageComposite>(4);
-
- PropertyValueModel<JpaConnection2_0> connection2_0Holder =
- this.buildJpaConnection2_0Holder(subjectHolder);
- PropertyValueModel<JpaOptions2_0> options2_0Holder =
- this.buildJpaOptions2_0Holder(subjectHolder);
-
- pages.add(new GenericPersistenceUnitGeneralTab(subjectHolder, parent, widgetFactory));
- pages.add(new GenericPersistenceUnit2_0ConnectionTab(connection2_0Holder, parent, widgetFactory));
- pages.add(new GenericPersistenceUnit2_0OptionsTab(options2_0Holder, parent, widgetFactory));
- pages.add(new PersistenceUnitPropertiesTab(subjectHolder, parent, widgetFactory));
-
- return pages.listIterator();
- }
-
- // ********** private methods **********
-
- private PropertyValueModel<JpaConnection2_0> buildJpaConnection2_0Holder(
- PropertyValueModel<PersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<PersistenceUnit, JpaConnection2_0>(subjectHolder) {
- @Override
- protected JpaConnection2_0 transform_(PersistenceUnit value) {
- return (JpaConnection2_0) ((PersistenceUnit2_0) value).getConnection();
- }
- };
- }
-
- private PropertyValueModel<JpaOptions2_0> buildJpaOptions2_0Holder(
- PropertyValueModel<PersistenceUnit> subjectHolder) {
- return new TransformationPropertyValueModel<PersistenceUnit, JpaOptions2_0>(subjectHolder) {
- @Override
- protected JpaOptions2_0 transform_(PersistenceUnit value) {
- return (JpaOptions2_0) ((PersistenceUnit2_0) value).getOptions();
- }
- };
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/GenericPersistenceUnit2_0OptionsTab.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnit2_0OptionsEditorPage.java
index f59fe52284..a670887179 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/GenericPersistenceUnit2_0OptionsTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnit2_0OptionsEditorPage.java
@@ -1,549 +1,538 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 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.jpa.ui.internal.jpa2.persistence;
-
-import java.util.Collection;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-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.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane;
-import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter;
-import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo;
-import org.eclipse.jpt.common.ui.internal.widgets.Pane;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.iterable.ListIterable;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.SharedCacheMode;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.ValidationMode;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.jpt.jpa.ui.internal.plugin.JptJpaUiPlugin;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.progress.IProgressService;
-
-/**
- * GenericPersistenceUnit2_0OptionsTab
- */
-public class GenericPersistenceUnit2_0OptionsTab extends Pane<JpaOptions2_0>
- implements JpaPageComposite
-{
- // ********** constructors/initialization **********
- /**
- * Creates a new <code>GenericPersistenceUnit2_0OptionsTab</code>.
- *
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various common widgets
- */
- public GenericPersistenceUnit2_0OptionsTab(
- PropertyValueModel<JpaOptions2_0> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- @Override
- protected void initializeLayout(Composite parent) {
- Composite composite = this.addSection(parent,
- JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsComposite_miscellaneousSectionTitle,
- JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsComposite_miscellaneousSectionDescription);
- composite.setLayout(new GridLayout(2, false));
-
- this.addLabel(composite, JptUiPersistence2_0Messages.LockingConfigurationComposite_lockTimeoutLabel);
- this.addLockTimeoutCombo(composite);
-
- this.addLabel(composite, JptUiPersistence2_0Messages.QueryConfigurationComposite_queryTimeoutLabel);
- this.addQueryTimeoutCombo(composite);
-
- // SharedCacheMode
- this.addLabel(composite, JptUiPersistence2_0Messages.SharedCacheModeComposite_sharedCacheModeLabel);
- this.addSharedCacheModeCombo(composite, this.buildPersistenceUnit2_0Holder());
-
- // ValidationMode
- this.addLabel(composite, JptUiPersistence2_0Messages.ValidationModeComposite_validationModeLabel);
- this.addValidationModeCombo(composite, this.buildPersistenceUnit2_0Holder());
-
- // ValidationGroupPrePersist
- this.addLabel(composite, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPrePersistLabel);
- this.addPrePersistListPane(composite);
-
- // ValidationGroupPreUpdate
- this.addLabel(composite, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreUpdateLabel);
- this.addPreUpdateListPane(composite);
-
- // ValidationGroupPreRemove
- this.addLabel(composite, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreRemoveLabel);
- this.addPreRemoveListPane(composite);
- }
-
- // ********** JpaPageComposite implementation **********
-
- public String getHelpID() {
- return null; // TODO - Review for JPA 2.0
- }
-
- public ImageDescriptor getPageImageDescriptor() {
- return null;
- }
-
- public String getPageText() {
- return JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsTab_title;
- }
-
-
- //************ lock timeout **********
-
- private void addLockTimeoutCombo(Composite parent) {
- new IntegerCombo<JpaOptions2_0>(this, parent) {
- @Override
- protected String getHelpId() {
- return null; // TODO
- }
- @Override
- protected PropertyValueModel<Integer> buildDefaultHolder() {
- return new PropertyAspectAdapter<JpaOptions2_0, Integer>(getSubjectHolder()) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getDefaultLockTimeout();
- }
- };
- }
-
- @Override
- protected ModifiablePropertyValueModel<Integer> buildSelectedItemHolder() {
- return new PropertyAspectAdapter<JpaOptions2_0, Integer>(getSubjectHolder(), JpaOptions2_0.LOCK_TIMEOUT_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getLockTimeout();
- }
-
- @Override
- protected void setValue_(Integer value) {
- this.subject.setLockTimeout(value);
- }
- };
- }
- };
- }
-
-
- //************ query timeout **********
-
- private void addQueryTimeoutCombo(Composite parent) {
- new IntegerCombo<JpaOptions2_0>(this, parent) {
- @Override
- protected String getHelpId() {
- return null; // TODO
- }
- @Override
- protected PropertyValueModel<Integer> buildDefaultHolder() {
- return new PropertyAspectAdapter<JpaOptions2_0, Integer>(getSubjectHolder()) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getDefaultQueryTimeout();
- }
- };
- }
-
- @Override
- protected ModifiablePropertyValueModel<Integer> buildSelectedItemHolder() {
- return new PropertyAspectAdapter<JpaOptions2_0, Integer>(getSubjectHolder(), JpaOptions2_0.QUERY_TIMEOUT_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getQueryTimeout();
- }
-
- @Override
- protected void setValue_(Integer value) {
- this.subject.setQueryTimeout(value);
- }
- };
- }
- };
- }
-
- //************ validation configuration **********
- // ********** ValidationGroupPrePersists **********
-
- private void addPrePersistListPane(Composite parent) {
- new AddRemoveListPane<JpaOptions2_0, String>(
- this,
- parent,
- this.buildPrePersistAdapter(),
- this.buildPrePersistListHolder(),
- this.buildSelectedItemsModel(),
- this.buildLabelProvider()
- );
- }
-
- private Adapter<String> buildPrePersistAdapter() {
- return new AddRemoveListPane.AbstractAdapter<String>() {
- public String addNewItem() {
- return addPrePersistClass();
- }
-
- @Override
- public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
- //enable the remove button only when 1 item is selected, same as the optional button
- return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
- }
-
- public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
- String item = selectedItemsModel.iterator().next();
- getSubject().removeValidationGroupPrePersist(item);
- }
- };
- }
-
- private ListValueModel<String> buildPrePersistListHolder() {
- return new ListAspectAdapter<JpaOptions2_0, String>(getSubjectHolder(), JpaOptions2_0.VALIDATION_GROUP_PRE_PERSIST_LIST) {
- @Override
- protected ListIterable<String> getListIterable() {
- return subject.getValidationGroupPrePersists();
- }
-
- @Override
- protected int size_() {
- return subject.getValidationGroupPrePersistsSize();
- }
- };
- }
-
- private String addPrePersistClass() {
-
- IType type = this.chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('$');
- if( ! this.getSubject().validationGroupPrePersistExists(className)) {
-
- return this.getSubject().addValidationGroupPrePersist(className);
- }
- }
- return null;
- }
-
- // ********** ValidationGroupPreUpdates **********
-
- private void addPreUpdateListPane(Composite parent) {
- new AddRemoveListPane<JpaOptions2_0, String>(
- this,
- parent,
- this.buildPreUpdateAdapter(),
- this.buildPreUpdateListHolder(),
- this.buildSelectedItemsModel(),
- this.buildLabelProvider()
- );
- }
-
- private Adapter<String> buildPreUpdateAdapter() {
- return new AddRemoveListPane.AbstractAdapter<String>() {
- public String addNewItem() {
- return addPreUpdateClass();
- }
-
- @Override
- public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
- //enable the remove button only when 1 item is selected, same as the optional button
- return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
- }
-
- public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
- String item = selectedItemsModel.iterator().next();
- getSubject().removeValidationGroupPreUpdate(item);
- }
- };
- }
-
- private ListValueModel<String> buildPreUpdateListHolder() {
- return new ListAspectAdapter<JpaOptions2_0, String>(getSubjectHolder(), JpaOptions2_0.VALIDATION_GROUP_PRE_UPDATE_LIST) {
- @Override
- protected ListIterable<String> getListIterable() {
- return subject.getValidationGroupPreUpdates();
- }
-
- @Override
- protected int size_() {
- return subject.getValidationGroupPreUpdatesSize();
- }
- };
- }
-
- private String addPreUpdateClass() {
-
- IType type = this.chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('$');
- if( ! this.getSubject().validationGroupPreUpdateExists(className)) {
-
- return this.getSubject().addValidationGroupPreUpdate(className);
- }
- }
- return null;
- }
-
- // ********** ValidationGroupPreRemoves **********
-
- private void addPreRemoveListPane(Composite parent) {
- new AddRemoveListPane<JpaOptions2_0, String>(
- this,
- parent,
- this.buildPreRemoveAdapter(),
- this.buildPreRemoveListHolder(),
- this.buildSelectedItemsModel(),
- this.buildLabelProvider()
- );
- }
-
- private Adapter<String> buildPreRemoveAdapter() {
- return new AddRemoveListPane.AbstractAdapter<String>() {
- public String addNewItem() {
- return addPreRemoveClass();
- }
-
- @Override
- public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
- //enable the remove button only when 1 item is selected, same as the optional button
- return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
- }
-
- public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
- String item = selectedItemsModel.iterator().next();
- getSubject().removeValidationGroupPreRemove(item);
- }
- };
- }
-
- private ListValueModel<String> buildPreRemoveListHolder() {
- return new ListAspectAdapter<JpaOptions2_0, String>(getSubjectHolder(), JpaOptions2_0.VALIDATION_GROUP_PRE_REMOVE_LIST) {
- @Override
- protected ListIterable<String> getListIterable() {
- return subject.getValidationGroupPreRemoves();
- }
-
- @Override
- protected int size_() {
- return subject.getValidationGroupPreRemovesSize();
- }
- };
- }
-
- private String addPreRemoveClass() {
- IType type = this.chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName('$');
- if( ! this.getSubject().validationGroupPreRemoveExists(className)) {
-
- return this.getSubject().addValidationGroupPreRemove(className);
- }
- }
- return null;
- }
-
-
- // ********** Private methods **********
-
- private PropertyValueModel<PersistenceUnit2_0> buildPersistenceUnit2_0Holder() {
- return new PropertyAspectAdapter<JpaOptions2_0, PersistenceUnit2_0>(this.getSubjectHolder()) {
- @Override
- protected PersistenceUnit2_0 buildValue_() {
- return (PersistenceUnit2_0) this.subject.getPersistenceUnit();
- }
- };
- }
-
- private ILabelProvider buildLabelProvider() {
- return new LabelProvider() {
-
- @Override
- public String getText(Object element) {
- String name = (String) element;
-
- if (name == null) {
- name = JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsTab_noName;
- }
- return name;
- }
- };
- }
-
- /**
- * Prompts the user the Open Type dialog.
- *
- * @return Either the selected type or <code>null</code> if the user
- * canceled the dialog
- */
- private IType chooseType() {
- IJavaProject javaProject = this.getSubject().getJpaProject().getJavaProject();
- IJavaElement[] elements = new IJavaElement[] { javaProject };
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- SelectionDialog typeSelectionDialog;
-
- try {
- typeSelectionDialog = JavaUI.createTypeDialog(
- getShell(),
- service,
- scope,
- IJavaElementSearchConstants.CONSIDER_CLASSES,
- false,
- ""
- );
- }
- catch (JavaModelException e) {
- JptJpaUiPlugin.instance().logError(e);
- return null;
- }
-
- typeSelectionDialog.setTitle(JptCommonUiMessages.ClassChooserPane_dialogTitle);
- typeSelectionDialog.setMessage(JptCommonUiMessages.ClassChooserPane_dialogMessage);
-
- if (typeSelectionDialog.open() == Window.OK) {
- return (IType) typeSelectionDialog.getResult()[0];
- }
-
- return null;
- }
-
- private ModifiableCollectionValueModel<String> buildSelectedItemsModel() {
- return new SimpleCollectionValueModel<String>();
- }
-
- //********* shared cache mode ***********
-
- private EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode> addSharedCacheModeCombo(Composite parent, PropertyValueModel<? extends PersistenceUnit2_0> subjectHolder) {
- return new EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode>(this, subjectHolder, parent) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(PersistenceUnit2_0.SPECIFIED_SHARED_CACHE_MODE_PROPERTY);
- }
-
- @Override
- protected SharedCacheMode[] getChoices() {
- return SharedCacheMode.values();
- }
-
- @Override
- protected boolean sortChoices() {
- return false;
- }
-
- @Override
- protected SharedCacheMode getDefaultValue() {
- return this.getSubject().getDefaultSharedCacheMode();
- }
-
- @Override
- protected String displayString(SharedCacheMode value) {
- switch (value) {
- case ALL :
- return JptUiPersistence2_0Messages.SharedCacheModeComposite_all;
- case DISABLE_SELECTIVE :
- return JptUiPersistence2_0Messages.SharedCacheModeComposite_disable_selective;
- case ENABLE_SELECTIVE :
- return JptUiPersistence2_0Messages.SharedCacheModeComposite_enable_selective;
- case NONE :
- return JptUiPersistence2_0Messages.SharedCacheModeComposite_none;
- case UNSPECIFIED :
- return JptUiPersistence2_0Messages.SharedCacheModeComposite_unspecified;
- default :
- throw new IllegalStateException();
- }
- }
-
- @Override
- protected SharedCacheMode getValue() {
- return this.getSubject().getSpecifiedSharedCacheMode();
- }
-
- @Override
- protected void setValue(SharedCacheMode value) {
- this.getSubject().setSpecifiedSharedCacheMode(value);
- }
- };
- }
-
- //********* validation mode ***********
-
- private EnumFormComboViewer<PersistenceUnit2_0, ValidationMode> addValidationModeCombo(Composite parent, PropertyValueModel<? extends PersistenceUnit2_0> subjectHolder) {
- return new EnumFormComboViewer<PersistenceUnit2_0, ValidationMode>(this, subjectHolder, parent) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(PersistenceUnit2_0.SPECIFIED_VALIDATION_MODE_PROPERTY);
- }
-
- @Override
- protected ValidationMode[] getChoices() {
- return ValidationMode.values();
- }
-
- @Override
- protected boolean sortChoices() {
- return false;
- }
-
- @Override
- protected ValidationMode getDefaultValue() {
- return this.getSubject().getDefaultValidationMode();
- }
-
- @Override
- protected String displayString(ValidationMode value) {
- switch (value) {
- case AUTO :
- return JptUiPersistence2_0Messages.ValidationModeComposite_auto;
- case CALLBACK :
- return JptUiPersistence2_0Messages.ValidationModeComposite_callback;
- case NONE :
- return JptUiPersistence2_0Messages.ValidationModeComposite_none;
- default :
- throw new IllegalStateException();
- }
- }
-
- @Override
- protected ValidationMode getValue() {
- return this.getSubject().getSpecifiedValidationMode();
- }
-
- @Override
- protected void setValue(ValidationMode value) {
- this.getSubject().setSpecifiedValidationMode(value);
- }
- };
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 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.jpa.ui.internal.jpa2.persistence;
+
+import java.util.Collection;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+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.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
+import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane;
+import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter;
+import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.common.ui.internal.widgets.IntegerCombo;
+import org.eclipse.jpt.common.ui.internal.widgets.Pane;
+import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
+import org.eclipse.jpt.common.utility.model.value.ListValueModel;
+import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
+import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.SharedCacheMode;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.ValidationMode;
+import org.eclipse.jpt.jpa.ui.internal.plugin.JptJpaUiPlugin;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.progress.IProgressService;
+
+public class PersistenceUnit2_0OptionsEditorPage
+ extends Pane<JpaOptions2_0> {
+
+ public PersistenceUnit2_0OptionsEditorPage(
+ PropertyValueModel<JpaOptions2_0> subjectModel,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectModel, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite parent) {
+ Section section = this.getWidgetFactory().createSection(parent, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ section.setText(JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsComposite_miscellaneousSectionTitle);
+ section.setDescription(JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsComposite_miscellaneousSectionDescription);
+
+ Composite client = this.getWidgetFactory().createComposite(section);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginTop = 0;
+ layout.marginLeft = 0;
+ layout.marginBottom = 0;
+ layout.marginRight = 0;
+ client.setLayout(layout);
+ client.setLayoutData(new GridData(GridData.FILL_BOTH));
+ section.setClient(client);
+
+ this.addLabel(client, JptUiPersistence2_0Messages.LockingConfigurationComposite_lockTimeoutLabel);
+ this.addLockTimeoutCombo(client);
+
+ this.addLabel(client, JptUiPersistence2_0Messages.QueryConfigurationComposite_queryTimeoutLabel);
+ this.addQueryTimeoutCombo(client);
+
+ // SharedCacheMode
+ this.addLabel(client, JptUiPersistence2_0Messages.SharedCacheModeComposite_sharedCacheModeLabel);
+ this.addSharedCacheModeCombo(client, this.buildPersistenceUnit2_0Model());
+
+ // ValidationMode
+ this.addLabel(client, JptUiPersistence2_0Messages.ValidationModeComposite_validationModeLabel);
+ this.addValidationModeCombo(client, this.buildPersistenceUnit2_0Model());
+
+ // ValidationGroupPrePersist
+ this.addLabel(client, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPrePersistLabel);
+ this.addPrePersistListPane(client);
+
+ // ValidationGroupPreUpdate
+ this.addLabel(client, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreUpdateLabel);
+ this.addPreUpdateListPane(client);
+
+ // ValidationGroupPreRemove
+ this.addLabel(client, JptUiPersistence2_0Messages.ValidationConfigurationComposite_groupPreRemoveLabel);
+ this.addPreRemoveListPane(client);
+ }
+
+
+ //************ lock timeout **********
+
+ private void addLockTimeoutCombo(Composite parent) {
+ new IntegerCombo<JpaOptions2_0>(this, parent) {
+ @Override
+ protected String getHelpId() {
+ return null; // TODO
+ }
+ @Override
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<JpaOptions2_0, Integer>(getSubjectHolder()) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getDefaultLockTimeout();
+ }
+ };
+ }
+
+ @Override
+ protected ModifiablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<JpaOptions2_0, Integer>(getSubjectHolder(), JpaOptions2_0.LOCK_TIMEOUT_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getLockTimeout();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setLockTimeout(value);
+ }
+ };
+ }
+ };
+ }
+
+
+ //************ query timeout **********
+
+ private void addQueryTimeoutCombo(Composite parent) {
+ new IntegerCombo<JpaOptions2_0>(this, parent) {
+ @Override
+ protected String getHelpId() {
+ return null; // TODO
+ }
+ @Override
+ protected PropertyValueModel<Integer> buildDefaultHolder() {
+ return new PropertyAspectAdapter<JpaOptions2_0, Integer>(getSubjectHolder()) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getDefaultQueryTimeout();
+ }
+ };
+ }
+
+ @Override
+ protected ModifiablePropertyValueModel<Integer> buildSelectedItemHolder() {
+ return new PropertyAspectAdapter<JpaOptions2_0, Integer>(getSubjectHolder(), JpaOptions2_0.QUERY_TIMEOUT_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getQueryTimeout();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ this.subject.setQueryTimeout(value);
+ }
+ };
+ }
+ };
+ }
+
+ //************ validation configuration **********
+ // ********** ValidationGroupPrePersists **********
+
+ private void addPrePersistListPane(Composite parent) {
+ new AddRemoveListPane<JpaOptions2_0, String>(
+ this,
+ parent,
+ this.buildPrePersistAdapter(),
+ this.buildPrePersistListModel(),
+ this.buildSelectedItemsModel(),
+ this.buildLabelProvider()
+ );
+ }
+
+ private Adapter<String> buildPrePersistAdapter() {
+ return new AddRemoveListPane.AbstractAdapter<String>() {
+ public String addNewItem() {
+ return addPrePersistClass();
+ }
+
+ @Override
+ public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
+ //enable the remove button only when 1 item is selected, same as the optional button
+ return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
+ }
+
+ public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
+ String item = selectedItemsModel.iterator().next();
+ getSubject().removeValidationGroupPrePersist(item);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildPrePersistListModel() {
+ return new ListAspectAdapter<JpaOptions2_0, String>(getSubjectHolder(), JpaOptions2_0.VALIDATION_GROUP_PRE_PERSIST_LIST) {
+ @Override
+ protected ListIterable<String> getListIterable() {
+ return subject.getValidationGroupPrePersists();
+ }
+
+ @Override
+ protected int size_() {
+ return subject.getValidationGroupPrePersistsSize();
+ }
+ };
+ }
+
+ private String addPrePersistClass() {
+
+ IType type = this.chooseType();
+
+ if (type != null) {
+ String className = type.getFullyQualifiedName('$');
+ if( ! this.getSubject().validationGroupPrePersistExists(className)) {
+
+ return this.getSubject().addValidationGroupPrePersist(className);
+ }
+ }
+ return null;
+ }
+
+ // ********** ValidationGroupPreUpdates **********
+
+ private void addPreUpdateListPane(Composite parent) {
+ new AddRemoveListPane<JpaOptions2_0, String>(
+ this,
+ parent,
+ this.buildPreUpdateAdapter(),
+ this.buildPreUpdateListModel(),
+ this.buildSelectedItemsModel(),
+ this.buildLabelProvider()
+ );
+ }
+
+ private Adapter<String> buildPreUpdateAdapter() {
+ return new AddRemoveListPane.AbstractAdapter<String>() {
+ public String addNewItem() {
+ return addPreUpdateClass();
+ }
+
+ @Override
+ public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
+ //enable the remove button only when 1 item is selected, same as the optional button
+ return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
+ }
+
+ public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
+ String item = selectedItemsModel.iterator().next();
+ getSubject().removeValidationGroupPreUpdate(item);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildPreUpdateListModel() {
+ return new ListAspectAdapter<JpaOptions2_0, String>(getSubjectHolder(), JpaOptions2_0.VALIDATION_GROUP_PRE_UPDATE_LIST) {
+ @Override
+ protected ListIterable<String> getListIterable() {
+ return subject.getValidationGroupPreUpdates();
+ }
+
+ @Override
+ protected int size_() {
+ return subject.getValidationGroupPreUpdatesSize();
+ }
+ };
+ }
+
+ private String addPreUpdateClass() {
+
+ IType type = this.chooseType();
+
+ if (type != null) {
+ String className = type.getFullyQualifiedName('$');
+ if( ! this.getSubject().validationGroupPreUpdateExists(className)) {
+
+ return this.getSubject().addValidationGroupPreUpdate(className);
+ }
+ }
+ return null;
+ }
+
+ // ********** ValidationGroupPreRemoves **********
+
+ private void addPreRemoveListPane(Composite parent) {
+ new AddRemoveListPane<JpaOptions2_0, String>(
+ this,
+ parent,
+ this.buildPreRemoveAdapter(),
+ this.buildPreRemoveListModel(),
+ this.buildSelectedItemsModel(),
+ this.buildLabelProvider()
+ );
+ }
+
+ private Adapter<String> buildPreRemoveAdapter() {
+ return new AddRemoveListPane.AbstractAdapter<String>() {
+ public String addNewItem() {
+ return addPreRemoveClass();
+ }
+
+ @Override
+ public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<String> selectedItemsModel) {
+ //enable the remove button only when 1 item is selected, same as the optional button
+ return this.buildSingleSelectedItemEnabledModel(selectedItemsModel);
+ }
+
+ public void removeSelectedItems(CollectionValueModel<String> selectedItemsModel) {
+ String item = selectedItemsModel.iterator().next();
+ getSubject().removeValidationGroupPreRemove(item);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildPreRemoveListModel() {
+ return new ListAspectAdapter<JpaOptions2_0, String>(getSubjectHolder(), JpaOptions2_0.VALIDATION_GROUP_PRE_REMOVE_LIST) {
+ @Override
+ protected ListIterable<String> getListIterable() {
+ return subject.getValidationGroupPreRemoves();
+ }
+
+ @Override
+ protected int size_() {
+ return subject.getValidationGroupPreRemovesSize();
+ }
+ };
+ }
+
+ private String addPreRemoveClass() {
+ IType type = this.chooseType();
+
+ if (type != null) {
+ String className = type.getFullyQualifiedName('$');
+ if( ! this.getSubject().validationGroupPreRemoveExists(className)) {
+
+ return this.getSubject().addValidationGroupPreRemove(className);
+ }
+ }
+ return null;
+ }
+
+
+ // ********** Private methods **********
+
+ private PropertyValueModel<PersistenceUnit2_0> buildPersistenceUnit2_0Model() {
+ return new PropertyAspectAdapter<JpaOptions2_0, PersistenceUnit2_0>(this.getSubjectHolder()) {
+ @Override
+ protected PersistenceUnit2_0 buildValue_() {
+ return (PersistenceUnit2_0) this.subject.getPersistenceUnit();
+ }
+ };
+ }
+
+ private ILabelProvider buildLabelProvider() {
+ return new LabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ String name = (String) element;
+
+ if (name == null) {
+ name = JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsTab_noName;
+ }
+ return name;
+ }
+ };
+ }
+
+ /**
+ * Prompts the user the Open Type dialog.
+ *
+ * @return Either the selected type or <code>null</code> if the user
+ * canceled the dialog
+ */
+ private IType chooseType() {
+ IJavaProject javaProject = this.getSubject().getJpaProject().getJavaProject();
+ IJavaElement[] elements = new IJavaElement[] { javaProject };
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ SelectionDialog typeSelectionDialog;
+
+ try {
+ typeSelectionDialog = JavaUI.createTypeDialog(
+ getShell(),
+ service,
+ scope,
+ IJavaElementSearchConstants.CONSIDER_CLASSES,
+ false,
+ ""
+ );
+ }
+ catch (JavaModelException e) {
+ JptJpaUiPlugin.instance().logError(e);
+ return null;
+ }
+
+ typeSelectionDialog.setTitle(JptCommonUiMessages.ClassChooserPane_dialogTitle);
+ typeSelectionDialog.setMessage(JptCommonUiMessages.ClassChooserPane_dialogMessage);
+
+ if (typeSelectionDialog.open() == Window.OK) {
+ return (IType) typeSelectionDialog.getResult()[0];
+ }
+
+ return null;
+ }
+
+ private ModifiableCollectionValueModel<String> buildSelectedItemsModel() {
+ return new SimpleCollectionValueModel<String>();
+ }
+
+ //********* shared cache mode ***********
+
+ private EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode> addSharedCacheModeCombo(Composite parent, PropertyValueModel<? extends PersistenceUnit2_0> subjectHolder) {
+ return new EnumFormComboViewer<PersistenceUnit2_0, SharedCacheMode>(this, subjectHolder, parent) {
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(PersistenceUnit2_0.SPECIFIED_SHARED_CACHE_MODE_PROPERTY);
+ }
+
+ @Override
+ protected SharedCacheMode[] getChoices() {
+ return SharedCacheMode.values();
+ }
+
+ @Override
+ protected boolean sortChoices() {
+ return false;
+ }
+
+ @Override
+ protected SharedCacheMode getDefaultValue() {
+ return this.getSubject().getDefaultSharedCacheMode();
+ }
+
+ @Override
+ protected String displayString(SharedCacheMode value) {
+ switch (value) {
+ case ALL :
+ return JptUiPersistence2_0Messages.SharedCacheModeComposite_all;
+ case DISABLE_SELECTIVE :
+ return JptUiPersistence2_0Messages.SharedCacheModeComposite_disable_selective;
+ case ENABLE_SELECTIVE :
+ return JptUiPersistence2_0Messages.SharedCacheModeComposite_enable_selective;
+ case NONE :
+ return JptUiPersistence2_0Messages.SharedCacheModeComposite_none;
+ case UNSPECIFIED :
+ return JptUiPersistence2_0Messages.SharedCacheModeComposite_unspecified;
+ default :
+ throw new IllegalStateException();
+ }
+ }
+
+ @Override
+ protected SharedCacheMode getValue() {
+ return this.getSubject().getSpecifiedSharedCacheMode();
+ }
+
+ @Override
+ protected void setValue(SharedCacheMode value) {
+ this.getSubject().setSpecifiedSharedCacheMode(value);
+ }
+ };
+ }
+
+ //********* validation mode ***********
+
+ private EnumFormComboViewer<PersistenceUnit2_0, ValidationMode> addValidationModeCombo(Composite parent, PropertyValueModel<? extends PersistenceUnit2_0> subjectHolder) {
+ return new EnumFormComboViewer<PersistenceUnit2_0, ValidationMode>(this, subjectHolder, parent) {
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(PersistenceUnit2_0.SPECIFIED_VALIDATION_MODE_PROPERTY);
+ }
+
+ @Override
+ protected ValidationMode[] getChoices() {
+ return ValidationMode.values();
+ }
+
+ @Override
+ protected boolean sortChoices() {
+ return false;
+ }
+
+ @Override
+ protected ValidationMode getDefaultValue() {
+ return this.getSubject().getDefaultValidationMode();
+ }
+
+ @Override
+ protected String displayString(ValidationMode value) {
+ switch (value) {
+ case AUTO :
+ return JptUiPersistence2_0Messages.ValidationModeComposite_auto;
+ case CALLBACK :
+ return JptUiPersistence2_0Messages.ValidationModeComposite_callback;
+ case NONE :
+ return JptUiPersistence2_0Messages.ValidationModeComposite_none;
+ default :
+ throw new IllegalStateException();
+ }
+ }
+
+ @Override
+ protected ValidationMode getValue() {
+ return this.getSubject().getSpecifiedValidationMode();
+ }
+
+ @Override
+ protected void setValue(ValidationMode value) {
+ this.getSubject().setSpecifiedValidationMode(value);
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/GenericPersistenceUnit2_0ConnectionTab.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitConnection2_0EditorPage.java
index 99412dd532..e8fd27c200 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/GenericPersistenceUnit2_0ConnectionTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitConnection2_0EditorPage.java
@@ -1,271 +1,256 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 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.jpa.ui.internal.jpa2.persistence;
-
-import java.util.Collection;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.jpt.common.ui.internal.widgets.Pane;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-
-/**
- * GenericPersistenceUnit2_0ConnectionTab
- */
-public class GenericPersistenceUnit2_0ConnectionTab extends Pane<JpaConnection2_0>
- implements JpaPageComposite
-{
- // ********** constructors/initialization **********
- /**
- * Creates a new <code>GenericPersistenceUnit2_0ConnectionTab</code>.
- *
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various common widgets
- */
- public GenericPersistenceUnit2_0ConnectionTab(
- PropertyValueModel<JpaConnection2_0> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- container = this.addSection(
- container,
- JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionTitle,
- JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionDescription
- );
- container.setLayout(new GridLayout(2, false));
-
- this.addLabel(container, JptUiPersistence2_0Messages.TransactionTypeComposite_transactionTypeLabel);
- this.buildTransactionTypeCombo(container);
-
- //Connection properties
- Group group = this.addTitledGroup(
- container,
- JptUiPersistence2_0Messages.ConnectionPropertiesComposite_Database_GroupBox
- );
- group.setLayout(new GridLayout(2, false));
-
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
- group.setLayoutData(gridData);
-
- // JTA Data Source
- PropertyValueModel<Boolean> jtaEnabled = this.buildJTADataSourceHolder();
- this.addLabel(group, JptUiPersistence2_0Messages.DataSourcePropertiesComposite_jtaDataSourceLabel, jtaEnabled);
- this.addText(group, this.buildJtaDataSourceHolder(), JpaHelpContextIds.PERSISTENCE_XML_CONNECTION, jtaEnabled);
-
- // Non-JTA Data Source
- PropertyValueModel<Boolean> nonJTAEnabled = this.buildNonJTADataSourceHolder();
- this.addLabel(group, JptUiPersistence2_0Messages.DataSourcePropertiesComposite_nonJtaDataSourceLabel, nonJTAEnabled);
- this.addText(group, this.buildNonJtaDataSourceHolder(), JpaHelpContextIds.PERSISTENCE_XML_CONNECTION, nonJTAEnabled);
-
-
- Group jdbcConnectionPropertiesGroup = this.addTitledGroup(
- group,
- JptUiPersistence2_0Messages.JdbcPropertiesComposite_JdbcConnectionProperties_GroupBox
- );
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
- jdbcConnectionPropertiesGroup.setLayoutData(gridData);
-
- new JdbcConnectionPropertiesComposite(this, jdbcConnectionPropertiesGroup, buildJdbcConnectionPropertiesPaneEnbaledModel());
- }
-
- private PropertyValueModel<Boolean> buildJdbcConnectionPropertiesPaneEnbaledModel() {
- return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
- @Override
- protected Boolean transform(PersistenceUnitTransactionType value) {
- return value == PersistenceUnitTransactionType.RESOURCE_LOCAL;
- }
- };
- }
-
-
- // ********** JpaPageComposite implementation **********
-
- public String getHelpID() {
- return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION; // TODO - Review for JPA 2.0
- }
-
- public ImageDescriptor getPageImageDescriptor() {
- return null;
- }
-
- public String getPageText() {
- return JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionTab_title;
- }
-
-
- // ********** transaction type **********
- private EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType> buildTransactionTypeCombo(Composite container) {
-
- return new EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType>(this,
- this.buildPersistenceUnitHolder(),
- container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY);
- propertyNames.add(PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY);
- }
-
- @Override
- protected PersistenceUnitTransactionType[] getChoices() {
- return PersistenceUnitTransactionType.values();
- }
-
- @Override
- protected PersistenceUnitTransactionType getDefaultValue() {
- return this.getSubject().getDefaultTransactionType();
- }
-
- @Override
- protected String displayString(PersistenceUnitTransactionType value) {
- switch (value) {
- case JTA :
- return JptUiPersistence2_0Messages.TransactionTypeComposite_jta;
- case RESOURCE_LOCAL :
- return JptUiPersistence2_0Messages.TransactionTypeComposite_resource_local;
- default :
- throw new IllegalStateException();
- }
- }
-
- @Override
- protected PersistenceUnitTransactionType getValue() {
- return this.getSubject().getSpecifiedTransactionType();
- }
-
- @Override
- protected void setValue(PersistenceUnitTransactionType value) {
- this.getSubject().setSpecifiedTransactionType(value);
-
- if (value == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
- clearJTAProperties();
- }
- else {
- clearResourceLocalProperties();
- }
- }
-
- @Override
- protected String getHelpId() {
- return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION; // TODO - Review for JPA 2.0
- }
- };
- }
-
- private PropertyValueModel<PersistenceUnit> buildPersistenceUnitHolder() {
- return new PropertyAspectAdapter<JpaConnection2_0, PersistenceUnit>(this.getSubjectHolder()) {
- @Override
- protected PersistenceUnit buildValue_() {
- return this.subject.getPersistenceUnit();
- }
- };
- }
-
- private void clearJTAProperties() {
- this.getSubject().getPersistenceUnit().setJtaDataSource(null);
- }
-
- private void clearResourceLocalProperties() {
- JpaConnection2_0 connection = this.getSubject();
- connection.getPersistenceUnit().setNonJtaDataSource(null);
- connection.setDriver(null);
- connection.setUrl(null);
- connection.setUser(null);
- connection.setPassword(null);
- }
-
-
- private ModifiablePropertyValueModel<String> buildJtaDataSourceHolder() {
- return new PropertyAspectAdapter<PersistenceUnit, String>(this.buildPersistenceUnitHolder(), PersistenceUnit.JTA_DATA_SOURCE_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getJtaDataSource();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- this.subject.setJtaDataSource(value);
- }
- };
- }
-
- private PropertyValueModel<Boolean> buildJTADataSourceHolder() {
- return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
- @Override
- protected Boolean transform(PersistenceUnitTransactionType value) {
- return Boolean.valueOf(this.transform2(value));
- }
- private boolean transform2(PersistenceUnitTransactionType value) {
- return value == null || value == PersistenceUnitTransactionType.JTA;
- }
- };
- }
-
- private ModifiablePropertyValueModel<String> buildNonJtaDataSourceHolder() {
- return new PropertyAspectAdapter<PersistenceUnit, String>(buildPersistenceUnitHolder(), PersistenceUnit.NON_JTA_DATA_SOURCE_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getNonJtaDataSource();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- this.subject.setNonJtaDataSource(value);
- }
- };
- }
-
- private PropertyValueModel<Boolean> buildNonJTADataSourceHolder() {
- return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
- @Override
- protected Boolean transform(PersistenceUnitTransactionType value) {
- return Boolean.valueOf(value == PersistenceUnitTransactionType.RESOURCE_LOCAL);
- }
- };
- }
-
- private PropertyValueModel<PersistenceUnitTransactionType> buildTransactionTypeHolder() {
- return new PropertyAspectAdapter<PersistenceUnit, PersistenceUnitTransactionType>(
- buildPersistenceUnitHolder(),
- PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY,
- PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY) {
- @Override
- protected PersistenceUnitTransactionType buildValue_() {
- return this.subject.getTransactionType();
- }
- };
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 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.jpa.ui.internal.jpa2.persistence;
+
+import java.util.Collection;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.common.ui.internal.widgets.Pane;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0;
+import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+
+public class PersistenceUnitConnection2_0EditorPage
+ extends Pane<JpaConnection2_0> {
+
+ public PersistenceUnitConnection2_0EditorPage(
+ PropertyValueModel<JpaConnection2_0> subjectModel,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectModel, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ section.setText(JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionTitle);
+ section.setDescription(JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionDescription);
+
+ Composite client = this.getWidgetFactory().createComposite(section);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginTop = 0;
+ layout.marginLeft = 0;
+ layout.marginBottom = 0;
+ layout.marginRight = 0;
+ client.setLayout(layout);
+ client.setLayoutData(new GridData(GridData.FILL_BOTH));
+ section.setClient(client);
+
+ this.addLabel(client, JptUiPersistence2_0Messages.TransactionTypeComposite_transactionTypeLabel);
+ this.buildTransactionTypeCombo(client);
+
+ //Connection properties
+ Group group = this.addTitledGroup(
+ client,
+ JptUiPersistence2_0Messages.ConnectionPropertiesComposite_Database_GroupBox
+ );
+ group.setLayout(new GridLayout(2, false));
+
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 2;
+ group.setLayoutData(gridData);
+
+ // JTA Data Source
+ PropertyValueModel<Boolean> jtaEnabled = this.buildJTADataSourceModel();
+ this.addLabel(group, JptUiPersistence2_0Messages.DataSourcePropertiesComposite_jtaDataSourceLabel, jtaEnabled);
+ this.addText(group, this.buildJtaDataSourceModel(), JpaHelpContextIds.PERSISTENCE_XML_CONNECTION, jtaEnabled);
+
+ // Non-JTA Data Source
+ PropertyValueModel<Boolean> nonJTAEnabled = this.buildNonJTADataSourceModel();
+ this.addLabel(group, JptUiPersistence2_0Messages.DataSourcePropertiesComposite_nonJtaDataSourceLabel, nonJTAEnabled);
+ this.addText(group, this.buildNonJtaDataSourceModel(), JpaHelpContextIds.PERSISTENCE_XML_CONNECTION, nonJTAEnabled);
+
+
+ Group jdbcConnectionPropertiesGroup = this.addTitledGroup(
+ group,
+ JptUiPersistence2_0Messages.JdbcPropertiesComposite_JdbcConnectionProperties_GroupBox
+ );
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 2;
+ jdbcConnectionPropertiesGroup.setLayoutData(gridData);
+
+ new JdbcConnectionPropertiesComposite(this, jdbcConnectionPropertiesGroup, buildJdbcConnectionPropertiesPaneEnbaledModel());
+ }
+
+ private PropertyValueModel<Boolean> buildJdbcConnectionPropertiesPaneEnbaledModel() {
+ return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeModel()) {
+ @Override
+ protected Boolean transform(PersistenceUnitTransactionType value) {
+ return Boolean.valueOf(value == PersistenceUnitTransactionType.RESOURCE_LOCAL);
+ }
+ };
+ }
+
+
+
+ // ********** transaction type **********
+ private EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType> buildTransactionTypeCombo(Composite container) {
+
+ return new EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType>(this,
+ this.buildPersistenceUnitModel(),
+ container) {
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY);
+ propertyNames.add(PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY);
+ }
+
+ @Override
+ protected PersistenceUnitTransactionType[] getChoices() {
+ return PersistenceUnitTransactionType.values();
+ }
+
+ @Override
+ protected PersistenceUnitTransactionType getDefaultValue() {
+ return this.getSubject().getDefaultTransactionType();
+ }
+
+ @Override
+ protected String displayString(PersistenceUnitTransactionType value) {
+ switch (value) {
+ case JTA :
+ return JptUiPersistence2_0Messages.TransactionTypeComposite_jta;
+ case RESOURCE_LOCAL :
+ return JptUiPersistence2_0Messages.TransactionTypeComposite_resource_local;
+ default :
+ throw new IllegalStateException();
+ }
+ }
+
+ @Override
+ protected PersistenceUnitTransactionType getValue() {
+ return this.getSubject().getSpecifiedTransactionType();
+ }
+
+ @Override
+ protected void setValue(PersistenceUnitTransactionType value) {
+ this.getSubject().setSpecifiedTransactionType(value);
+
+ if (value == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
+ clearJTAProperties();
+ }
+ else {
+ clearResourceLocalProperties();
+ }
+ }
+
+ @Override
+ protected String getHelpId() {
+ return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION; // TODO - Review for JPA 2.0
+ }
+ };
+ }
+
+ private PropertyValueModel<PersistenceUnit> buildPersistenceUnitModel() {
+ return new PropertyAspectAdapter<JpaConnection2_0, PersistenceUnit>(this.getSubjectHolder()) {
+ @Override
+ protected PersistenceUnit buildValue_() {
+ return this.subject.getPersistenceUnit();
+ }
+ };
+ }
+
+ private void clearJTAProperties() {
+ this.getSubject().getPersistenceUnit().setJtaDataSource(null);
+ }
+
+ private void clearResourceLocalProperties() {
+ JpaConnection2_0 connection = this.getSubject();
+ connection.getPersistenceUnit().setNonJtaDataSource(null);
+ connection.setDriver(null);
+ connection.setUrl(null);
+ connection.setUser(null);
+ connection.setPassword(null);
+ }
+
+
+ private ModifiablePropertyValueModel<String> buildJtaDataSourceModel() {
+ return new PropertyAspectAdapter<PersistenceUnit, String>(this.buildPersistenceUnitModel(), PersistenceUnit.JTA_DATA_SOURCE_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getJtaDataSource();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ this.subject.setJtaDataSource(value);
+ }
+ };
+ }
+
+ private PropertyValueModel<Boolean> buildJTADataSourceModel() {
+ return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeModel()) {
+ @Override
+ protected Boolean transform(PersistenceUnitTransactionType value) {
+ return Boolean.valueOf(this.transform2(value));
+ }
+ private boolean transform2(PersistenceUnitTransactionType value) {
+ return value == null || value == PersistenceUnitTransactionType.JTA;
+ }
+ };
+ }
+
+ private ModifiablePropertyValueModel<String> buildNonJtaDataSourceModel() {
+ return new PropertyAspectAdapter<PersistenceUnit, String>(buildPersistenceUnitModel(), PersistenceUnit.NON_JTA_DATA_SOURCE_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getNonJtaDataSource();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ this.subject.setNonJtaDataSource(value);
+ }
+ };
+ }
+
+ private PropertyValueModel<Boolean> buildNonJTADataSourceModel() {
+ return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeModel()) {
+ @Override
+ protected Boolean transform(PersistenceUnitTransactionType value) {
+ return Boolean.valueOf(value == PersistenceUnitTransactionType.RESOURCE_LOCAL);
+ }
+ };
+ }
+
+ private PropertyValueModel<PersistenceUnitTransactionType> buildTransactionTypeModel() {
+ return new PropertyAspectAdapter<PersistenceUnit, PersistenceUnitTransactionType>(
+ buildPersistenceUnitModel(),
+ PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY,
+ PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY) {
+ @Override
+ protected PersistenceUnitTransactionType buildValue_() {
+ return this.subject.getTransactionType();
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitConnection2_0EditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitConnection2_0EditorPageDefinition.java
new file mode 100644
index 0000000000..f1c8f7e862
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitConnection2_0EditorPageDefinition.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 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.jpa.ui.internal.jpa2.persistence;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
+import org.eclipse.swt.widgets.Composite;
+
+public class PersistenceUnitConnection2_0EditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new PersistenceUnitConnection2_0EditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private PersistenceUnitConnection2_0EditorPageDefinition() {
+ super();
+ }
+
+ public String getPageText() {
+ return JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionTab_title;
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return null;
+ }
+
+ public String getHelpID() {
+ return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION; // TODO - Review for JPA 2.0
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new PersistenceUnitConnection2_0EditorPage(this.buildJpaConnection2_0Model(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+
+ protected PropertyValueModel<JpaConnection2_0> buildJpaConnection2_0Model(PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ return new TransformationPropertyValueModel<PersistenceUnit, JpaConnection2_0>(this.buildPersistenceUnitModel(jpaRootStructureNodeModel)) {
+ @Override
+ protected JpaConnection2_0 transform_(PersistenceUnit value) {
+ return (JpaConnection2_0) ((PersistenceUnit2_0) value).getConnection();
+ }
+ };
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitEditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitEditorPageDefinition.java
new file mode 100644
index 0000000000..ea6726d1d2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitEditorPageDefinition.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.jpa.ui.internal.jpa2.persistence;
+
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.ListPropertyValueModelAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.common.utility.model.value.ListValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.IManagedForm;
+
+public abstract class PersistenceUnitEditorPageDefinition
+ implements JpaEditorPageDefinition
+{
+
+ protected PersistenceUnitEditorPageDefinition() {
+ super();
+ }
+
+ public void buildEditorPageContent(IManagedForm form, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ this.buildEditorPageContent(form.getForm().getBody(), widgetFactory, jpaRootStructureNodeModel);
+ }
+
+ protected abstract void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel);
+
+ protected PropertyValueModel<PersistenceUnit> buildPersistenceUnitModel(PropertyValueModel<JpaStructureNode> jpaStructureNodeModel) {
+ return new ListPropertyValueModelAdapter<PersistenceUnit>(this.buildPersistenceUnitListModel(jpaStructureNodeModel)) {
+ @Override
+ protected PersistenceUnit buildValue() {
+ return this.listModel.size() > 0 ? (PersistenceUnit) this.listModel.get(0) : null;
+ }
+ };
+ }
+
+ protected ListValueModel<PersistenceUnit> buildPersistenceUnitListModel(PropertyValueModel<JpaStructureNode> jpaStructureNodeModel) {
+ return new ListAspectAdapter<Persistence, PersistenceUnit>(this.buildPersistenceModel(jpaStructureNodeModel), Persistence.PERSISTENCE_UNITS_LIST) {
+ @Override
+ protected ListIterable<PersistenceUnit> getListIterable() {
+ return this.subject.getPersistenceUnits();
+ }
+
+ @Override
+ protected int size_() {
+ return this.subject.getPersistenceUnitsSize();
+ }
+ };
+ }
+
+ protected PropertyValueModel<Persistence> buildPersistenceModel(PropertyValueModel<JpaStructureNode> jpaStructureNodeModel) {
+ return new TransformationPropertyValueModel<JpaStructureNode, Persistence>(jpaStructureNodeModel) {
+ @Override
+ protected Persistence transform(JpaStructureNode jpaStructureNode) {
+ return (Persistence) jpaStructureNode;
+ }
+ };
+ }
+
+ @Override
+ public String toString() {
+ return this.getPageText();
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitOptions2_0EditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitOptions2_0EditorPageDefinition.java
new file mode 100644
index 0000000000..63ec14026d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceUnitOptions2_0EditorPageDefinition.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 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.jpa.ui.internal.jpa2.persistence;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+public class PersistenceUnitOptions2_0EditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new PersistenceUnitOptions2_0EditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private PersistenceUnitOptions2_0EditorPageDefinition() {
+ super();
+ }
+
+ public String getPageText() {
+ return JptUiPersistence2_0Messages.GenericPersistenceUnit2_0OptionsTab_title;
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return null;
+ }
+
+ public String getHelpID() {
+ return null; // TODO - Review for JPA 2.0
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new PersistenceUnit2_0OptionsEditorPage(this.buildJpaOptions2_0Model(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+
+ private PropertyValueModel<JpaOptions2_0> buildJpaOptions2_0Model(PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ return new TransformationPropertyValueModel<PersistenceUnit, JpaOptions2_0>(this.buildPersistenceUnitModel(jpaRootStructureNodeModel)) {
+ @Override
+ protected JpaOptions2_0 transform_(PersistenceUnit value) {
+ return (JpaOptions2_0) ((PersistenceUnit2_0) value).getOptions();
+ }
+ };
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java
index 548f3410a6..013de295fe 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java
@@ -9,46 +9,50 @@
******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal.jpa2.persistence;
+import java.util.List;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_0Definition;
import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.internal.persistence.AbstractPersistenceXmlResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.AbstractResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitGeneralEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceXmlUiDefinition;
-import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceXmlUiFactory;
public class PersistenceXml2_0UiDefinition
- extends AbstractPersistenceXmlResourceUiDefinition
+ extends AbstractResourceUiDefinition
{
// singleton
private static final ResourceUiDefinition INSTANCE = new PersistenceXml2_0UiDefinition();
-
-
+
/**
* Return the singleton
*/
public static ResourceUiDefinition instance() {
return INSTANCE;
}
-
-
+
+
/**
* Enforce singleton usage
*/
private PersistenceXml2_0UiDefinition() {
super();
}
-
-
+
@Override
- protected PersistenceXmlUiFactory buildPersistenceXmlUiFactory() {
- return new Generic2_0PersistenceXmlUiFactory();
+ protected void addEditorPageDefinitionsTo(List<JpaEditorPageDefinition> definitions) {
+ definitions.add(PersistenceUnitGeneralEditorPageDefinition.instance());
+ definitions.add(PersistenceUnitConnection2_0EditorPageDefinition.instance());
+ definitions.add(PersistenceUnitOptions2_0EditorPageDefinition.instance());
+ definitions.add(PersistenceUnitPropertiesEditorPageDefinition.instance());
}
-
+
public boolean providesUi(JptResourceType resourceType) {
return resourceType.equals(GenericPersistenceXml2_0Definition.instance().getResourceType());
}
-
+
public ItemTreeStateProviderFactoryProvider getStructureViewFactoryProvider() {
return PersistenceXmlUiDefinition.STRUCTURE_VIEW_FACTORY_PROVIDER;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/AbstractPersistenceXmlResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/AbstractPersistenceXmlResourceUiDefinition.java
deleted file mode 100644
index 16fe4c06e2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/AbstractPersistenceXmlResourceUiDefinition.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 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.jpa.ui.internal.persistence;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.PersistenceXmlResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * All the state in the definition should be "static" (i.e. unchanging once it is initialized).
- */
-public abstract class AbstractPersistenceXmlResourceUiDefinition
- implements ResourceUiDefinition, PersistenceXmlResourceUiDefinition
-{
-
-
- private final PersistenceXmlUiFactory factory;
-
-
- /**
- * zero-argument constructor
- */
- protected AbstractPersistenceXmlResourceUiDefinition() {
- super();
- this.factory = buildPersistenceXmlUiFactory();
- }
-
-
- protected abstract PersistenceXmlUiFactory buildPersistenceXmlUiFactory();
-
- public PersistenceXmlUiFactory getFactory() {
- return this.factory;
- }
-
- public ListIterator<JpaPageComposite> buildPersistenceUnitComposites(PropertyValueModel<PersistenceUnit> subjectHolder, Composite parent, WidgetFactory widgetFactory) {
- return this.factory.createPersistenceUnitComposites(subjectHolder, parent, widgetFactory);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceUnitGeneralTab.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceUnitGeneralTab.java
deleted file mode 100644
index 40aa6b4eb3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceUnitGeneralTab.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
-
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | |
- * | - General --------------------------------------------------------------- |
- * | ------------------------------------------------- |
- * | Name: | I | |
- * | ------------------------------------------------- |
- * | ------------------------------------------------- |
- * | Persistence Provider: | |v| |
- * | ------------------------------------------------- |
- * | |
- * | |
- * | - Mapped Classes -------------------------------------------------------- |
- * | |
- * | Description |
- * | |
- * | ----------------------------------------------------------------------- |
- * | | | |
- * | | PersistenceUnitMappedClassesComposite | |
- * | | | |
- * | ----------------------------------------------------------------------- |
- * | |
- * | |
- * | - XML Mapping Files ----------------------------------------------------- |
- * | |
- * | Description |
- * | |
- * | ----------------------------------------------------------------------- |
- * | | | |
- * | | PersistenceUnitMappingFilesComposite | |
- * | | | |
- * | ----------------------------------------------------------------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @see PersistenceUnit
- * @see PersistenceUnitGeneralComposite
- * @see PersistenceUnitJarFilesComposite
- * @see PersistenceUnitMappedClassesComposite
- * @see PersistenceUnitMappingFilesComposite
- *
- * @version 2.0
- * @since 2.0
- */
-public class GenericPersistenceUnitGeneralTab extends PersistenceUnitGeneralTab
- implements JpaPageComposite
-{
- /**
- * Creates a new <code>PersistenceUnitGeneralComposite</code>.
- *
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various common widgets
- */
- public GenericPersistenceUnitGeneralTab(PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite container,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, container, widgetFactory);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceUnitMappingFilesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceUnitMappingFilesComposite.java
index 3a07ffc783..454f5d7338 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceUnitMappingFilesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceUnitMappingFilesComposite.java
@@ -25,7 +25,7 @@ import org.eclipse.swt.widgets.Composite;
* -----------------------------------------------------------------------------</pre>
*
* @see PersistenceUnit
- * @see PersistenceUnitGeneralTab - The parent container
+ * @see PersistenceUnitGeneralEditorPageDefinition - The parent container
* @see AddRemoveListPane
*
* @version 2.0
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceXmlUiFactory.java
deleted file mode 100644
index c57fc8c6b0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/GenericPersistenceXmlUiFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 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.jpa.ui.internal.persistence;
-
-import java.util.ArrayList;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.swt.widgets.Composite;
-
-public class GenericPersistenceXmlUiFactory implements PersistenceXmlUiFactory
-{
- // **************** persistence unit composites ****************************
-
- public ListIterator<JpaPageComposite> createPersistenceUnitComposites(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- ArrayList<JpaPageComposite> pages = new ArrayList<JpaPageComposite>(3);
-
- pages.add(new GenericPersistenceUnitGeneralTab(subjectHolder, parent, widgetFactory));
- pages.add(new PersistenceUnitConnectionTab(subjectHolder, parent, widgetFactory));
- pages.add(new PersistenceUnitPropertiesTab(subjectHolder, parent, widgetFactory));
-
- return pages.listIterator();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/JptUiPersistenceMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/JptUiPersistenceMessages.java
index fa852649bc..c52cfeab87 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/JptUiPersistenceMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/JptUiPersistenceMessages.java
@@ -22,9 +22,6 @@ public class JptUiPersistenceMessages {
public static String ArchiveFileSelectionDialog_jarPathHelpLabel;
public static String ArchiveFileSelectionDialog_jarPathLabel;
- public static String PersistenceEditor_page_help;
- public static String PersistenceEditor_sourceTab;
-
public static String PersistenceUnitClassesComposite_description;
public static String PersistenceUnitClassesComposite_excludeUnlistedMappedClasses;
public static String PersistenceUnitClassesComposite_excludeUnlistedMappedClassesWithDefault;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java
index 4ff1016e26..fc1ff1bd83 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java
@@ -73,7 +73,7 @@ import org.eclipse.ui.progress.IProgressService;
* -----------------------------------------------------------------------------</pre>
*
* @see PersistenceUnit
- * @see PersistenceUnitGeneralTab - The parent container
+ * @see PersistenceUnitGeneralEditorPageDefinition - The parent container
* @see AddRemoveListPane
*
* @version 2.3
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionTab.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionEditorPage.java
index 0d43765bcf..5d1867fd35 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionEditorPage.java
@@ -1,250 +1,240 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
-
-import java.util.Collection;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
-import org.eclipse.jpt.common.ui.internal.widgets.Pane;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
-import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-
-/**
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | |
- * | - General --------------------------------------------------------------- |
- * | ------------------------------------------------------------------------- |
- * | | | |
- * | | PersistenceUnitConnectionGeneralComposite | |
- * | | | |
- * | ------------------------------------------------------------------------- |
- * | |
- * | - Database -------------------------------------------------------------- |
- * | ------------------------------------------------------------------------- |
- * | | | |
- * | | PersistenceUnitConnectionDatabaseComposite | |
- * | | | |
- * | ------------------------------------------------------------------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @see PersistenceUnit
- * @see PersistenceUnitConnectionGeneralComposite
- * @see PersistenceUnitConnectionDatabaseComposite
- *
- * @version 2.0
- * @since 2.0
- */
-public class PersistenceUnitConnectionTab extends Pane<PersistenceUnit>
- implements JpaPageComposite
-{
- /**
- * Creates a new <code>PersistenceUnitConnectionComposite</code>.
- *
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various common widgets
- */
- public PersistenceUnitConnectionTab(PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite container,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, container, widgetFactory);
- }
-
- public String getHelpID() {
- return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION;
- }
-
-
- public ImageDescriptor getPageImageDescriptor() {
- return null;
- }
-
- public String getPageText() {
- return JptUiPersistenceMessages.PersistenceUnitConnectionComposite_connection;
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- container = this.addSection(
- container,
- JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionTitle,
- JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionDescription
- );
- container.setLayout(new GridLayout(2, false));
-
- // Transaction Type widgets
- this.addLabel(container, JptUiPersistenceMessages.PersistenceUnitConnectionGeneralComposite_transactionType);
- this.buildTransactionTypeCombo(container).getControl();
-
- Group databaseGroup = this.addTitledGroup(container, JptUiPersistenceMessages.PersistenceUnitConnectionComposite_database, 2, JpaHelpContextIds.PERSISTENCE_XML_CONNECTION);
- GridData gridData = new GridData(GridData.FILL_BOTH);
- gridData.horizontalSpan = 2;
- databaseGroup.setLayoutData(gridData);
-
- // JTA Datasource Name widgets
- PropertyValueModel<Boolean> enabled = this.buildJTADatasourceNameBooleanHolder();
- this.addLabel(
- databaseGroup,
- JptUiPersistenceMessages.PersistenceUnitConnectionDatabaseComposite_jtaDatasourceName,
- enabled
- );
- this.addText(
- databaseGroup,
- buildJTADatasourceNameHolder(),
- JpaHelpContextIds.PERSISTENCE_XML_CONNECTION,
- enabled
- );
-
-
- // Non-JTA Datasource Name widgets
- enabled = this.buildNonJTADatasourceNameBooleanHolder();
- this.addLabel(
- databaseGroup,
- JptUiPersistenceMessages.PersistenceUnitConnectionDatabaseComposite_nonJtaDatasourceName,
- enabled
- );
- this.addText(
- databaseGroup,
- buildNonJTADatasourceNameHolder(),
- JpaHelpContextIds.PERSISTENCE_XML_CONNECTION,
- enabled
- );
- }
-
- private EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType> buildTransactionTypeCombo(Composite container) {
-
- return new EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType>(this, container) {
-
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY);
- propertyNames.add(PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY);
- }
-
- @Override
- protected PersistenceUnitTransactionType[] getChoices() {
- return PersistenceUnitTransactionType.values();
- }
-
- @Override
- protected PersistenceUnitTransactionType getDefaultValue() {
- return getSubject().getDefaultTransactionType();
- }
-
- @Override
- protected String displayString(PersistenceUnitTransactionType value) {
- switch (value) {
- case JTA :
- return JptUiPersistenceMessages.PersistenceUnitConnectionGeneralComposite_jta;
- case RESOURCE_LOCAL :
- return JptUiPersistenceMessages.PersistenceUnitConnectionGeneralComposite_resource_local;
- default :
- throw new IllegalStateException();
- }
- }
-
- @Override
- protected PersistenceUnitTransactionType getValue() {
- return getSubject().getSpecifiedTransactionType();
- }
-
- @Override
- protected void setValue(PersistenceUnitTransactionType value) {
- getSubject().setSpecifiedTransactionType(value);
- }
-
- @Override
- protected String getHelpId() {
- return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION;
- }
- };
- }
-
- private PropertyValueModel<Boolean> buildJTADatasourceNameBooleanHolder() {
- return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
- @Override
- protected Boolean transform_(PersistenceUnitTransactionType value) {
- return Boolean.valueOf(value == PersistenceUnitTransactionType.JTA);
- }
- };
- }
-
- private ModifiablePropertyValueModel<String> buildJTADatasourceNameHolder() {
- return new PropertyAspectAdapter<PersistenceUnit, String>(getSubjectHolder(), PersistenceUnit.JTA_DATA_SOURCE_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getJtaDataSource();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- subject.setJtaDataSource(value);
- }
- };
- }
-
- private PropertyValueModel<Boolean> buildNonJTADatasourceNameBooleanHolder() {
- return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
- @Override
- protected Boolean transform_(PersistenceUnitTransactionType value) {
- return Boolean.valueOf(value == PersistenceUnitTransactionType.RESOURCE_LOCAL);
- }
- };
- }
-
- private ModifiablePropertyValueModel<String> buildNonJTADatasourceNameHolder() {
- return new PropertyAspectAdapter<PersistenceUnit, String>(getSubjectHolder(), PersistenceUnit.NON_JTA_DATA_SOURCE_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getNonJtaDataSource();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- subject.setNonJtaDataSource(value);
- }
- };
- }
-
- private PropertyValueModel<PersistenceUnitTransactionType> buildTransactionTypeHolder() {
- return new PropertyAspectAdapter<PersistenceUnit, PersistenceUnitTransactionType>(
- getSubjectHolder(),
- PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY,
- PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY)
- {
- @Override
- protected PersistenceUnitTransactionType buildValue_() {
- return subject.getTransactionType();
- }
- };
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
+
+import java.util.Collection;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.common.ui.internal.widgets.Pane;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType;
+import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.JptUiPersistence2_0Messages;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * Here the layout of this pane:
+ * <pre>
+ * -----------------------------------------------------------------------------
+ * | |
+ * | - General --------------------------------------------------------------- |
+ * | ------------------------------------------------------------------------- |
+ * | | | |
+ * | | PersistenceUnitConnectionGeneralComposite | |
+ * | | | |
+ * | ------------------------------------------------------------------------- |
+ * | |
+ * | - Database -------------------------------------------------------------- |
+ * | ------------------------------------------------------------------------- |
+ * | | | |
+ * | | PersistenceUnitConnectionDatabaseComposite | |
+ * | | | |
+ * | ------------------------------------------------------------------------- |
+ * -----------------------------------------------------------------------------</pre>
+ *
+ * @see PersistenceUnit
+ *
+ * @version 3.3
+ * @since 2.0
+ */
+
+public class PersistenceUnitConnectionEditorPage
+ extends Pane<PersistenceUnit> {
+
+ public PersistenceUnitConnectionEditorPage(
+ PropertyValueModel<PersistenceUnit> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
+ section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ section.setText(JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionTitle);
+ section.setDescription(JptUiPersistence2_0Messages.GenericPersistenceUnit2_0ConnectionComposite_sectionDescription);
+
+ Composite client = this.getWidgetFactory().createComposite(section);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginTop = 0;
+ layout.marginLeft = 0;
+ layout.marginBottom = 0;
+ layout.marginRight = 0;
+ client.setLayout(layout);
+ client.setLayoutData(new GridData(GridData.FILL_BOTH));
+ section.setClient(client);
+
+ // Transaction Type widgets
+ this.addLabel(client, JptUiPersistenceMessages.PersistenceUnitConnectionGeneralComposite_transactionType);
+ this.buildTransactionTypeCombo(client).getControl();
+
+ Group databaseGroup = this.addTitledGroup(client, JptUiPersistenceMessages.PersistenceUnitConnectionComposite_database, 2, JpaHelpContextIds.PERSISTENCE_XML_CONNECTION);
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.horizontalSpan = 2;
+ databaseGroup.setLayoutData(gridData);
+
+ // JTA Datasource Name widgets
+ PropertyValueModel<Boolean> enabled = this.buildJTADatasourceNameBooleanHolder();
+ this.addLabel(
+ databaseGroup,
+ JptUiPersistenceMessages.PersistenceUnitConnectionDatabaseComposite_jtaDatasourceName,
+ enabled
+ );
+ this.addText(
+ databaseGroup,
+ buildJTADatasourceNameHolder(),
+ JpaHelpContextIds.PERSISTENCE_XML_CONNECTION,
+ enabled
+ );
+
+
+ // Non-JTA Datasource Name widgets
+ enabled = this.buildNonJTADatasourceNameBooleanHolder();
+ this.addLabel(
+ databaseGroup,
+ JptUiPersistenceMessages.PersistenceUnitConnectionDatabaseComposite_nonJtaDatasourceName,
+ enabled
+ );
+ this.addText(
+ databaseGroup,
+ buildNonJTADatasourceNameHolder(),
+ JpaHelpContextIds.PERSISTENCE_XML_CONNECTION,
+ enabled
+ );
+ }
+
+ private EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType> buildTransactionTypeCombo(Composite container) {
+
+ return new EnumFormComboViewer<PersistenceUnit, PersistenceUnitTransactionType>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY);
+ propertyNames.add(PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY);
+ }
+
+ @Override
+ protected PersistenceUnitTransactionType[] getChoices() {
+ return PersistenceUnitTransactionType.values();
+ }
+
+ @Override
+ protected PersistenceUnitTransactionType getDefaultValue() {
+ return getSubject().getDefaultTransactionType();
+ }
+
+ @Override
+ protected String displayString(PersistenceUnitTransactionType value) {
+ switch (value) {
+ case JTA :
+ return JptUiPersistenceMessages.PersistenceUnitConnectionGeneralComposite_jta;
+ case RESOURCE_LOCAL :
+ return JptUiPersistenceMessages.PersistenceUnitConnectionGeneralComposite_resource_local;
+ default :
+ throw new IllegalStateException();
+ }
+ }
+
+ @Override
+ protected PersistenceUnitTransactionType getValue() {
+ return getSubject().getSpecifiedTransactionType();
+ }
+
+ @Override
+ protected void setValue(PersistenceUnitTransactionType value) {
+ getSubject().setSpecifiedTransactionType(value);
+ }
+
+ @Override
+ protected String getHelpId() {
+ return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION;
+ }
+ };
+ }
+
+ private PropertyValueModel<Boolean> buildJTADatasourceNameBooleanHolder() {
+ return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
+ @Override
+ protected Boolean transform_(PersistenceUnitTransactionType value) {
+ return Boolean.valueOf(value == PersistenceUnitTransactionType.JTA);
+ }
+ };
+ }
+
+ private ModifiablePropertyValueModel<String> buildJTADatasourceNameHolder() {
+ return new PropertyAspectAdapter<PersistenceUnit, String>(getSubjectHolder(), PersistenceUnit.JTA_DATA_SOURCE_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getJtaDataSource();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ subject.setJtaDataSource(value);
+ }
+ };
+ }
+
+ private PropertyValueModel<Boolean> buildNonJTADatasourceNameBooleanHolder() {
+ return new TransformationPropertyValueModel<PersistenceUnitTransactionType, Boolean>(buildTransactionTypeHolder()) {
+ @Override
+ protected Boolean transform_(PersistenceUnitTransactionType value) {
+ return Boolean.valueOf(value == PersistenceUnitTransactionType.RESOURCE_LOCAL);
+ }
+ };
+ }
+
+ private ModifiablePropertyValueModel<String> buildNonJTADatasourceNameHolder() {
+ return new PropertyAspectAdapter<PersistenceUnit, String>(getSubjectHolder(), PersistenceUnit.NON_JTA_DATA_SOURCE_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getNonJtaDataSource();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ subject.setNonJtaDataSource(value);
+ }
+ };
+ }
+
+ private PropertyValueModel<PersistenceUnitTransactionType> buildTransactionTypeHolder() {
+ return new PropertyAspectAdapter<PersistenceUnit, PersistenceUnitTransactionType>(
+ getSubjectHolder(),
+ PersistenceUnit.DEFAULT_TRANSACTION_TYPE_PROPERTY,
+ PersistenceUnit.SPECIFIED_TRANSACTION_TYPE_PROPERTY)
+ {
+ @Override
+ protected PersistenceUnitTransactionType buildValue_() {
+ return subject.getTransactionType();
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionEditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionEditorPageDefinition.java
new file mode 100644
index 0000000000..a549e69b92
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitConnectionEditorPageDefinition.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @see PersistenceUnit
+ *
+ * @version 3.3
+ * @since 2.0
+ */
+public class PersistenceUnitConnectionEditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new PersistenceUnitConnectionEditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private PersistenceUnitConnectionEditorPageDefinition() {
+ super();
+ }
+
+ public String getPageText() {
+ return JptUiPersistenceMessages.PersistenceUnitConnectionComposite_connection;
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return null;
+ }
+
+ public String getHelpID() {
+ return JpaHelpContextIds.PERSISTENCE_XML_CONNECTION;
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new PersistenceUnitConnectionEditorPage(this.buildPersistenceUnitModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralTab.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralEditorPage.java
index a530917dd1..6c78d3662a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralEditorPage.java
@@ -1,172 +1,150 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.ui.internal.widgets.Pane;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
-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;
-
-/**
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | |
- * | - General --------------------------------------------------------------- |
- * | ------------------------------------------------- |
- * | Name: | I | |
- * | ------------------------------------------------- |
- * | ------------------------------------------------- |
- * | Persistence Provider: | |v| |
- * | ------------------------------------------------- |
- * | |
- * | |
- * | - Mapped Classes -------------------------------------------------------- |
- * | |
- * | Description |
- * | |
- * | ----------------------------------------------------------------------- |
- * | | | |
- * | | PersistenceUnitMappedClassesComposite | |
- * | | | |
- * | ----------------------------------------------------------------------- |
- * | |
- * | |
- * | - XML Mapping Files ----------------------------------------------------- |
- * | |
- * | Description |
- * | |
- * | ----------------------------------------------------------------------- |
- * | | | |
- * | | PersistenceUnitMappingFilesComposite | |
- * | | | |
- * | ----------------------------------------------------------------------- |
- * | |
- * | |
- * | - JAR Files ------------------------------------------------------------- |
- * | |
- * | Description |
- * | |
- * | ----------------------------------------------------------------------- |
- * | | | |
- * | | PersistenceUnitJarFilesComposite | |
- * | | | |
- * | ----------------------------------------------------------------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @see PersistenceUnit
- * @see PersistenceUnitMappedClassesComposite
- * @see PersistenceUnitMappingFilesComposite
- * @see PersistenceUnitJarFilesComposite
- *
- * @version 2.0
- * @since 2.0
- */
-public abstract class PersistenceUnitGeneralTab extends Pane<PersistenceUnit>
- implements JpaPageComposite
-{
- /**
- * Creates a new <code>PersistenceUnitGeneralComposite</code>.
- *
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various common widgets
- */
- public PersistenceUnitGeneralTab(PropertyValueModel<? extends PersistenceUnit> subjectHolder,
- Composite container,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, container, widgetFactory);
- }
-
- public String getHelpID() {
- return JpaHelpContextIds.PERSISTENCE_XML_GENERAL;
- }
-
- public ImageDescriptor getPageImageDescriptor() {
- return null;
- }
-
- public String getPageText() {
- return JptUiPersistenceMessages.PersistenceUnitGeneralComposite_general;
- }
-
- @Override
- protected Composite addComposite(Composite parent) {
- GridLayout layout = new GridLayout(2, true);//2 columns
- layout.marginHeight = 0;
- layout.marginWidth = 0;
-
- return this.addPane(parent, layout);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- Section generalSection = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR);
- generalSection.setText(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_general);
- Control generalComposite = this.buildGeneralComposite(generalSection);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.verticalAlignment = SWT.TOP;
- generalSection.setLayoutData(gridData);
- generalSection.setClient(generalComposite);
-
- Section mappingFilesSection = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
- mappingFilesSection.setText(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_jpaMappingDescriptors);
- mappingFilesSection.setDescription(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_jpaMappingDescriptors_description);
- Control mappingFilesComposite = this.buildMappingFilesComposite(mappingFilesSection);
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.verticalAlignment = SWT.TOP;
- mappingFilesSection.setLayoutData(gridData);
- mappingFilesSection.setClient(mappingFilesComposite);
-
- Section classesSection = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
- classesSection.setText(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_mappedClasses);
- classesSection.setDescription(JptUiPersistenceMessages.PersistenceUnitClassesComposite_description);
- gridData = new GridData(GridData.FILL_BOTH);
- gridData.verticalAlignment = SWT.TOP;
- classesSection.setLayoutData(gridData);
- Control classesComposite = this.buildClassesComposite(classesSection);
- classesSection.setClient(classesComposite);
-
- Section jarFilesSection = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR);
- jarFilesSection.setText(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_jarFiles);
- Control jarFilesComposite = this.buildJarFilesComposite(jarFilesSection);
- gridData = new GridData(GridData.FILL_BOTH);
- gridData.verticalAlignment = SWT.TOP;
- jarFilesSection.setLayoutData(gridData);
- jarFilesSection.setClient(jarFilesComposite);
- }
-
- protected Control buildGeneralComposite(Composite parent) {
- return new PersistenceUnitGeneralComposite(this, parent).getControl();
- }
-
- protected Control buildClassesComposite(Composite parent) {
- return new PersistenceUnitClassesComposite(this, parent).getControl();
- }
-
- protected Control buildMappingFilesComposite(Composite parent) {
- return new GenericPersistenceUnitMappingFilesComposite(this, parent).getControl();
- }
-
- protected Control buildJarFilesComposite(Composite parent) {
- return new GenericPersistenceUnitJarFilesComposite(this, parent).getControl();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
+
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.widgets.Pane;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+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;
+
+/**
+ * Here the layout of this pane:
+ * <pre>
+ * -----------------------------------------------------------------------------
+ * | |
+ * | - General --------------------------------------------------------------- |
+ * | ------------------------------------------------- |
+ * | Name: | I | |
+ * | ------------------------------------------------- |
+ * | ------------------------------------------------- |
+ * | Persistence Provider: | |v| |
+ * | ------------------------------------------------- |
+ * | |
+ * | |
+ * | - Mapped Classes -------------------------------------------------------- |
+ * | |
+ * | Description |
+ * | |
+ * | ----------------------------------------------------------------------- |
+ * | | | |
+ * | | PersistenceUnitMappedClassesComposite | |
+ * | | | |
+ * | ----------------------------------------------------------------------- |
+ * | |
+ * | |
+ * | - XML Mapping Files ----------------------------------------------------- |
+ * | |
+ * | Description |
+ * | |
+ * | ----------------------------------------------------------------------- |
+ * | | | |
+ * | | PersistenceUnitMappingFilesComposite | |
+ * | | | |
+ * | ----------------------------------------------------------------------- |
+ * | |
+ * | |
+ * | - JAR Files ------------------------------------------------------------- |
+ * | |
+ * | Description |
+ * | |
+ * | ----------------------------------------------------------------------- |
+ * | | | |
+ * | | PersistenceUnitJarFilesComposite | |
+ * | | | |
+ * | ----------------------------------------------------------------------- |
+ * -----------------------------------------------------------------------------</pre>
+ *
+ * @see PersistenceUnit
+ * @see PersistenceUnitMappedClassesComposite
+ * @see PersistenceUnitMappingFilesComposite
+ * @see PersistenceUnitJarFilesComposite
+ *
+ * @version 3.3
+ * @since 2.0
+ */
+public class PersistenceUnitGeneralEditorPage extends Pane<PersistenceUnit> {
+
+ public PersistenceUnitGeneralEditorPage(
+ PropertyValueModel<PersistenceUnit> subjectHolder,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ @Override
+ protected Composite addComposite(Composite parent) {
+ GridLayout layout = new GridLayout(2, true);//2 columns
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+
+ return this.addPane(parent, layout);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ Section generalSection = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR);
+ generalSection.setText(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_general);
+ Control generalComposite = this.buildGeneralComposite(generalSection);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.verticalAlignment = SWT.TOP;
+ generalSection.setLayoutData(gridData);
+ generalSection.setClient(generalComposite);
+
+ Section mappingFilesSection = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
+ mappingFilesSection.setText(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_jpaMappingDescriptors);
+ mappingFilesSection.setDescription(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_jpaMappingDescriptors_description);
+ Control mappingFilesComposite = this.buildMappingFilesComposite(mappingFilesSection);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.verticalAlignment = SWT.TOP;
+ mappingFilesSection.setLayoutData(gridData);
+ mappingFilesSection.setClient(mappingFilesComposite);
+
+ Section classesSection = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
+ classesSection.setText(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_mappedClasses);
+ classesSection.setDescription(JptUiPersistenceMessages.PersistenceUnitClassesComposite_description);
+ gridData = new GridData(GridData.FILL_BOTH);
+ gridData.verticalAlignment = SWT.TOP;
+ classesSection.setLayoutData(gridData);
+ Control classesComposite = this.buildClassesComposite(classesSection);
+ classesSection.setClient(classesComposite);
+
+ Section jarFilesSection = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR);
+ jarFilesSection.setText(JptUiPersistenceMessages.PersistenceUnitGeneralComposite_jarFiles);
+ Control jarFilesComposite = this.buildJarFilesComposite(jarFilesSection);
+ gridData = new GridData(GridData.FILL_BOTH);
+ gridData.verticalAlignment = SWT.TOP;
+ jarFilesSection.setLayoutData(gridData);
+ jarFilesSection.setClient(jarFilesComposite);
+ }
+
+ protected Control buildGeneralComposite(Composite parent) {
+ return new PersistenceUnitGeneralComposite(this, parent).getControl();
+ }
+
+ protected Control buildClassesComposite(Composite parent) {
+ return new PersistenceUnitClassesComposite(this, parent).getControl();
+ }
+
+ protected Control buildMappingFilesComposite(Composite parent) {
+ return new GenericPersistenceUnitMappingFilesComposite(this, parent).getControl();
+ }
+
+ protected Control buildJarFilesComposite(Composite parent) {
+ return new GenericPersistenceUnitJarFilesComposite(this, parent).getControl();
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralEditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralEditorPageDefinition.java
new file mode 100644
index 0000000000..8732e04807
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitGeneralEditorPageDefinition.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @version 3.3
+ * @since 2.0
+ */
+public class PersistenceUnitGeneralEditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new PersistenceUnitGeneralEditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private PersistenceUnitGeneralEditorPageDefinition() {
+ super();
+ }
+
+ public String getPageText() {
+ return JptUiPersistenceMessages.PersistenceUnitGeneralComposite_general;
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return null;
+ }
+
+ public String getHelpID() {
+ return JpaHelpContextIds.PERSISTENCE_XML_GENERAL;
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new PersistenceUnitGeneralEditorPage(this.buildPersistenceUnitModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitJarFilesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitJarFilesComposite.java
index be432dd29e..6ec196a69d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitJarFilesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitJarFilesComposite.java
@@ -48,7 +48,7 @@ import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
* -----------------------------------------------------------------------------</pre>
*
* @see PersistenceUnit
- * @see PersistenceUnitGeneralTab - The parent container
+ * @see PersistenceUnitGeneralEditorPageDefinition - The parent container
* @see AddRemoveListPane
*
* @version 2.0
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesTab.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesEditorPage.java
index 413d8f09c1..5dc0b08b8e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesTab.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesEditorPage.java
@@ -1,415 +1,390 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveTablePane;
-import org.eclipse.jpt.common.ui.internal.widgets.Pane;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.iterable.ListIterable;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
-import org.eclipse.jpt.jpa.ui.internal.details.java.BaseJavaUiFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-
-/**
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | - Properties ------------------------------------------------------------ |
- * | |
- * | Description |
- * | |
- * | ----------------------------------------------------------------------- |
- * | | | |
- * | | AddRemoveTablePane | |
- * | | | |
- * | ----------------------------------------------------------------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @see PersistenceUnit
- * @see BaseJavaUiFactory - The invoker
- * @see AddRemoveTablePane
- *
- * @version 2.3
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public class PersistenceUnitPropertiesTab extends Pane<PersistenceUnit>
- implements JpaPageComposite
-{
- private ModifiableCollectionValueModel<PersistenceUnit.Property> selectedPropertiesModel;
- private TablePane tablePane;
-
- /**
- * Creates a new <code>PersistenceUnitPropertiesComposite</code>.
- *
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various common widgets
- */
- public PersistenceUnitPropertiesTab(PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite container,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, container, widgetFactory);
- }
-
- public String getHelpID() {
- return JpaHelpContextIds.PERSISTENCE_XML_PROPERTIES;
- }
-
- public ImageDescriptor getPageImageDescriptor() {
- return null;
- }
-
- public String getPageText() {
- return JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_properties;
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.selectedPropertiesModel = new SimpleCollectionValueModel<PersistenceUnit.Property>();
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- this.addLabel(
- container,
- JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_properties_description
- );
-
- this.tablePane = new TablePane(container);
- }
-
- private ListValueModel<PersistenceUnit.Property> buildPropertiesListHolder() {
- return new ListAspectAdapter<PersistenceUnit, PersistenceUnit.Property>(getSubjectHolder(), PersistenceUnit.PROPERTIES_LIST) {
- @Override
- protected ListIterable<PersistenceUnit.Property> getListIterable() {
- return subject.getProperties();
- }
-
- @Override
- protected int size_() {
- return subject.getPropertiesSize();
- }
- };
- }
-
- private ITableLabelProvider buildPropertyLabelProvider() {
- return new TableLabelProvider();
- }
-
- private AddRemoveTablePane.Adapter<PersistenceUnit.Property> buildTableAdapter() {
- return new AddRemoveTablePane.AbstractAdapter<PersistenceUnit.Property>() {
- public PersistenceUnit.Property addNewItem() {
-
- PersistenceUnit.Property property = getSubject().addProperty();
-
- tablePane.getTableViewer().editElement(
- property,
- PropertyColumnAdapter.NAME_COLUMN
- );
- return property;
- }
-
- @Override
- public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<PersistenceUnit.Property> selectedItemsModel) {
- //enable the remove button only when 1 item is selected, same as the optional button
- return buildSingleSelectedItemEnabledModel(selectedItemsModel);
- }
-
- public void removeSelectedItems(CollectionValueModel<PersistenceUnit.Property> selectedItemsModel) {
- //assume only 1 item since remove button is disabled otherwise
- PersistenceUnit.Property property = selectedItemsModel.iterator().next();
- getSubject().removeProperty(property);
- }
- };
- }
-
- private static class PropertyColumnAdapter implements ColumnAdapter<PersistenceUnit.Property> {
-
- public static final int COLUMN_COUNT = 3;
- public static final int NAME_COLUMN = 1;
- public static final int SELECTION_COLUMN = 0;
- public static final int VALUE_COLUMN = 2;
-
- private ModifiablePropertyValueModel<String> buildNameHolder(PersistenceUnit.Property subject) {
- return new PropertyAspectAdapter<PersistenceUnit.Property, String>(PersistenceUnit.Property.NAME_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return subject.getName();
- }
-
- @Override
- protected void setValue_(String value) {
- subject.setName(value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<String> buildValueHolder(PersistenceUnit.Property subject) {
- return new PropertyAspectAdapter<PersistenceUnit.Property, String>(PersistenceUnit.Property.VALUE_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return subject.getValue();
- }
-
- @Override
- protected void setValue_(String value) {
- subject.setValue(value);
- }
- };
- }
-
- public ModifiablePropertyValueModel<?>[] cellModels(PersistenceUnit.Property subject) {
- ModifiablePropertyValueModel<?>[] holders = new ModifiablePropertyValueModel<?>[COLUMN_COUNT];
- holders[SELECTION_COLUMN] = new SimplePropertyValueModel<Object>();
- holders[NAME_COLUMN] = buildNameHolder(subject);
- holders[VALUE_COLUMN] = buildValueHolder(subject);
- return holders;
- }
-
- public int columnCount() {
- return COLUMN_COUNT;
- }
-
- public String columnName(int columnIndex) {
-
- switch (columnIndex) {
- case PropertyColumnAdapter.NAME_COLUMN: {
- return JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_nameColumn;
- }
-
- case PropertyColumnAdapter.VALUE_COLUMN: {
- return JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_valueColumn;
- }
-
- default: {
- return null;
- }
- }
- }
- }
-
- private class TableLabelProvider extends LabelProvider
- implements ITableLabelProvider {
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
-
- PersistenceUnit.Property property = (PersistenceUnit.Property) element;
- String value = null;
-
- switch (columnIndex) {
- case PropertyColumnAdapter.NAME_COLUMN: {
- value = property.getName();
- break;
- }
-
- case PropertyColumnAdapter.VALUE_COLUMN: {
- value = property.getValue();
- break;
- }
- }
-
- if (value == null) {
- value = "";
- }
-
- return value;
- }
- }
-
- private class TablePane extends AddRemoveTablePane<PersistenceUnit, PersistenceUnit.Property> {
-
- private final String SELECTION_COLUMN = "selection";
-
- private TableViewer tableViewer;
-
- private TablePane(Composite parent) {
- super(PersistenceUnitPropertiesTab.this,
- parent,
- buildTableAdapter(),
- buildPropertiesListHolder(),
- selectedPropertiesModel,
- buildPropertyLabelProvider());
- }
-
- private CellEditor[] buildCellEditors(Table table) {
- return new CellEditor[] {
- null,
- new TextCellEditor(table),
- new TextCellEditor(table)
- };
- }
-
- private ICellModifier buildCellModifier() {
- return new ICellModifier() {
-
- public boolean canModify(Object element, String property) {
- return !SELECTION_COLUMN.equals(property);
- }
-
- public Object getValue(Object element, String property) {
- PersistenceUnit.Property propertyModel = (PersistenceUnit.Property) element;
- String value = null;
-
- if (property == PersistenceUnit.Property.NAME_PROPERTY) {
- value = propertyModel.getName();
- }
- else if (property == PersistenceUnit.Property.VALUE_PROPERTY) {
- value = propertyModel.getValue();
- }
-
- if (value == null) {
- value = "";
- }
-
- return value;
- }
-
- public void modify(Object element, String property, Object value) {
- PersistenceUnit.Property propertyModel;
-
- if (element instanceof TableItem) {
- TableItem tableItem = (TableItem) element;
- propertyModel = (PersistenceUnit.Property) tableItem.getData();
- }
- else {
- propertyModel = (PersistenceUnit.Property) element;
- }
-
- if (property == PersistenceUnit.Property.NAME_PROPERTY) {
- propertyModel.setName(value.toString());
- }
- else if (property == PersistenceUnit.Property.VALUE_PROPERTY) {
- propertyModel.setValue(value.toString());
- }
- }
- };
- }
-
- @Override
- protected ColumnAdapter<PersistenceUnit.Property> buildColumnAdapter() {
- return new PropertyColumnAdapter();
- }
-
- private String[] buildColumnProperties() {
- return new String[] {
- SELECTION_COLUMN,
- PersistenceUnit.Property.NAME_PROPERTY,
- PersistenceUnit.Property.VALUE_PROPERTY
- };
- }
-
- TableViewer getTableViewer() {
- return tableViewer;
- }
-
- @Override
- protected void initializeMainComposite(Composite container,
- Adapter<PersistenceUnit.Property> adapter,
- ListValueModel<?> listHolder,
- ModifiableCollectionValueModel<PersistenceUnit.Property> selectedItemsHolder,
- IBaseLabelProvider labelProvider,
- String helpId) {
-
- super.initializeMainComposite(
- container,
- adapter,
- listHolder,
- selectedItemsHolder,
- labelProvider,
- helpId
- );
-
- Table table = getMainControl();
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // Make the selection column non-resizable since it's only used to
- // ease the selection of rows
- TableColumn selectionColumn = table.getColumn(PropertyColumnAdapter.SELECTION_COLUMN);
- selectionColumn.setResizable(false);
- selectionColumn.setWidth(20);
-
- // Install the editors
- tableViewer = new TableViewer(table);
- tableViewer.setCellEditors(buildCellEditors(table));
- tableViewer.setCellModifier(buildCellModifier());
- tableViewer.setColumnProperties(buildColumnProperties());
- }
-
- @Override
- protected void itemsAdded(ListAddEvent e) {
- super.itemsAdded(e);
- revalidateLayout();
- }
-
- @Override
- protected void itemsRemoved(ListRemoveEvent e) {
- super.itemsRemoved(e);
- revalidateLayout();
- }
-
- @Override
- protected void listChanged(ListChangeEvent e) {
- super.listChanged(e);
- revalidateLayout();
- }
-
- /**
- * Revalidates the table layout after the list of items has changed. The
- * layout has to be done in a new UI thread because our listener might be
- * notified before the table has been updated (table column added or removed).
- */
- private void revalidateLayout() {
- SWTUtil.asyncExec(new Runnable() { public void run() {
- Table table = getMainControl();
- if (!table.isDisposed()) {
- // We have to do a total relayout of the tab otherwise the
- // table might become cut off at the bottom
- SWTUtil.reflow(table);
- }
- }});
- }
- }
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter;
+import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveTablePane;
+import org.eclipse.jpt.common.ui.internal.widgets.Pane;
+import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
+import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
+import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
+import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
+import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
+import org.eclipse.jpt.common.utility.model.value.ListValueModel;
+import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
+import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+/**
+ * Here the layout of this pane:
+ * <pre>
+ * -----------------------------------------------------------------------------
+ * | - Properties ------------------------------------------------------------ |
+ * | |
+ * | Description |
+ * | |
+ * | ----------------------------------------------------------------------- |
+ * | | | |
+ * | | AddRemoveTablePane | |
+ * | | | |
+ * | ----------------------------------------------------------------------- |
+ * -----------------------------------------------------------------------------</pre>
+ *
+ * @see PersistenceUnit
+ *
+ * @version 3.3
+ * @since 2.0
+ */
+public class PersistenceUnitPropertiesEditorPage
+ extends Pane<PersistenceUnit>
+{
+ private ModifiableCollectionValueModel<PersistenceUnit.Property> selectedPropertiesModel;
+ private TablePane tablePane;
+
+ public PersistenceUnitPropertiesEditorPage(
+ PropertyValueModel<PersistenceUnit> subjectModel,
+ Composite parent,
+ WidgetFactory widgetFactory) {
+
+ super(subjectModel, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ this.selectedPropertiesModel = new SimpleCollectionValueModel<PersistenceUnit.Property>();
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ this.addLabel(
+ container,
+ JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_properties_description
+ );
+
+ this.tablePane = new TablePane(container);
+ }
+
+ private ListValueModel<PersistenceUnit.Property> buildPropertiesListModel() {
+ return new ListAspectAdapter<PersistenceUnit, PersistenceUnit.Property>(getSubjectHolder(), PersistenceUnit.PROPERTIES_LIST) {
+ @Override
+ protected ListIterable<PersistenceUnit.Property> getListIterable() {
+ return subject.getProperties();
+ }
+
+ @Override
+ protected int size_() {
+ return subject.getPropertiesSize();
+ }
+ };
+ }
+
+ private ITableLabelProvider buildPropertyLabelProvider() {
+ return new TableLabelProvider();
+ }
+
+ private AddRemoveTablePane.Adapter<PersistenceUnit.Property> buildTableAdapter() {
+ return new AddRemoveTablePane.AbstractAdapter<PersistenceUnit.Property>() {
+ public PersistenceUnit.Property addNewItem() {
+
+ PersistenceUnit.Property property = getSubject().addProperty();
+
+ tablePane.getTableViewer().editElement(
+ property,
+ PropertyColumnAdapter.NAME_COLUMN
+ );
+ return property;
+ }
+
+ @Override
+ public PropertyValueModel<Boolean> buildRemoveButtonEnabledModel(CollectionValueModel<PersistenceUnit.Property> selectedItemsModel) {
+ //enable the remove button only when 1 item is selected, same as the optional button
+ return buildSingleSelectedItemEnabledModel(selectedItemsModel);
+ }
+
+ public void removeSelectedItems(CollectionValueModel<PersistenceUnit.Property> selectedItemsModel) {
+ //assume only 1 item since remove button is disabled otherwise
+ PersistenceUnit.Property property = selectedItemsModel.iterator().next();
+ getSubject().removeProperty(property);
+ }
+ };
+ }
+
+ private static class PropertyColumnAdapter implements ColumnAdapter<PersistenceUnit.Property> {
+
+ public static final int COLUMN_COUNT = 3;
+ public static final int NAME_COLUMN = 1;
+ public static final int SELECTION_COLUMN = 0;
+ public static final int VALUE_COLUMN = 2;
+
+ private ModifiablePropertyValueModel<String> buildNameModel(PersistenceUnit.Property subject) {
+ return new PropertyAspectAdapter<PersistenceUnit.Property, String>(PersistenceUnit.Property.NAME_PROPERTY, subject) {
+ @Override
+ protected String buildValue_() {
+ return subject.getName();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ subject.setName(value);
+ }
+ };
+ }
+
+ private ModifiablePropertyValueModel<String> buildValueModel(PersistenceUnit.Property subject) {
+ return new PropertyAspectAdapter<PersistenceUnit.Property, String>(PersistenceUnit.Property.VALUE_PROPERTY, subject) {
+ @Override
+ protected String buildValue_() {
+ return subject.getValue();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ subject.setValue(value);
+ }
+ };
+ }
+
+ public ModifiablePropertyValueModel<?>[] cellModels(PersistenceUnit.Property subject) {
+ ModifiablePropertyValueModel<?>[] models = new ModifiablePropertyValueModel<?>[COLUMN_COUNT];
+ models[SELECTION_COLUMN] = new SimplePropertyValueModel<Object>();
+ models[NAME_COLUMN] = buildNameModel(subject);
+ models[VALUE_COLUMN] = buildValueModel(subject);
+ return models;
+ }
+
+ public int columnCount() {
+ return COLUMN_COUNT;
+ }
+
+ public String columnName(int columnIndex) {
+
+ switch (columnIndex) {
+ case PropertyColumnAdapter.NAME_COLUMN: {
+ return JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_nameColumn;
+ }
+
+ case PropertyColumnAdapter.VALUE_COLUMN: {
+ return JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_valueColumn;
+ }
+
+ default: {
+ return null;
+ }
+ }
+ }
+ }
+
+ private class TableLabelProvider extends LabelProvider
+ implements ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+
+ PersistenceUnit.Property property = (PersistenceUnit.Property) element;
+ String value = null;
+
+ switch (columnIndex) {
+ case PropertyColumnAdapter.NAME_COLUMN: {
+ value = property.getName();
+ break;
+ }
+
+ case PropertyColumnAdapter.VALUE_COLUMN: {
+ value = property.getValue();
+ break;
+ }
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ return value;
+ }
+ }
+
+ private class TablePane extends AddRemoveTablePane<PersistenceUnit, PersistenceUnit.Property> {
+
+ private final String SELECTION_COLUMN = "selection";
+
+ private TableViewer tableViewer;
+
+ private TablePane(Composite parent) {
+ super(PersistenceUnitPropertiesEditorPage.this,
+ parent,
+ buildTableAdapter(),
+ buildPropertiesListModel(),
+ selectedPropertiesModel,
+ buildPropertyLabelProvider());
+ }
+
+ private CellEditor[] buildCellEditors(Table table) {
+ return new CellEditor[] {
+ null,
+ new TextCellEditor(table),
+ new TextCellEditor(table)
+ };
+ }
+
+ private ICellModifier buildCellModifier() {
+ return new ICellModifier() {
+
+ public boolean canModify(Object element, String property) {
+ return !SELECTION_COLUMN.equals(property);
+ }
+
+ public Object getValue(Object element, String property) {
+ PersistenceUnit.Property propertyModel = (PersistenceUnit.Property) element;
+ String value = null;
+
+ if (property == PersistenceUnit.Property.NAME_PROPERTY) {
+ value = propertyModel.getName();
+ }
+ else if (property == PersistenceUnit.Property.VALUE_PROPERTY) {
+ value = propertyModel.getValue();
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ return value;
+ }
+
+ public void modify(Object element, String property, Object value) {
+ PersistenceUnit.Property propertyModel;
+
+ if (element instanceof TableItem) {
+ TableItem tableItem = (TableItem) element;
+ propertyModel = (PersistenceUnit.Property) tableItem.getData();
+ }
+ else {
+ propertyModel = (PersistenceUnit.Property) element;
+ }
+
+ if (property == PersistenceUnit.Property.NAME_PROPERTY) {
+ propertyModel.setName(value.toString());
+ }
+ else if (property == PersistenceUnit.Property.VALUE_PROPERTY) {
+ propertyModel.setValue(value.toString());
+ }
+ }
+ };
+ }
+
+ @Override
+ protected ColumnAdapter<PersistenceUnit.Property> buildColumnAdapter() {
+ return new PropertyColumnAdapter();
+ }
+
+ private String[] buildColumnProperties() {
+ return new String[] {
+ SELECTION_COLUMN,
+ PersistenceUnit.Property.NAME_PROPERTY,
+ PersistenceUnit.Property.VALUE_PROPERTY
+ };
+ }
+
+ TableViewer getTableViewer() {
+ return tableViewer;
+ }
+
+ @Override
+ protected void initializeMainComposite(Composite container,
+ Adapter<PersistenceUnit.Property> adapter,
+ ListValueModel<?> listHolder,
+ ModifiableCollectionValueModel<PersistenceUnit.Property> selectedItemsHolder,
+ IBaseLabelProvider labelProvider,
+ String helpId) {
+
+ super.initializeMainComposite(
+ container,
+ adapter,
+ listHolder,
+ selectedItemsHolder,
+ labelProvider,
+ helpId
+ );
+
+ Table table = getMainControl();
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ // Make the selection column non-resizable since it's only used to
+ // ease the selection of rows
+ TableColumn selectionColumn = table.getColumn(PropertyColumnAdapter.SELECTION_COLUMN);
+ selectionColumn.setResizable(false);
+ selectionColumn.setWidth(20);
+
+ // Install the editors
+ tableViewer = new TableViewer(table);
+ tableViewer.setCellEditors(buildCellEditors(table));
+ tableViewer.setCellModifier(buildCellModifier());
+ tableViewer.setColumnProperties(buildColumnProperties());
+ }
+
+ @Override
+ protected void itemsAdded(ListAddEvent e) {
+ super.itemsAdded(e);
+ revalidateLayout();
+ }
+
+ @Override
+ protected void itemsRemoved(ListRemoveEvent e) {
+ super.itemsRemoved(e);
+ revalidateLayout();
+ }
+
+ @Override
+ protected void listChanged(ListChangeEvent e) {
+ super.listChanged(e);
+ revalidateLayout();
+ }
+
+ /**
+ * Revalidates the table layout after the list of items has changed. The
+ * layout has to be done in a new UI thread because our listener might be
+ * notified before the table has been updated (table column added or removed).
+ */
+ private void revalidateLayout() {
+ SWTUtil.asyncExec(new Runnable() { public void run() {
+ Table table = getMainControl();
+ if (!table.isDisposed()) {
+ // We have to do a total relayout of the tab otherwise the
+ // table might become cut off at the bottom
+ SWTUtil.reflow(table);
+ }
+ }});
+ }
+ }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesEditorPageDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesEditorPageDefinition.java
new file mode 100644
index 0000000000..3b9220e812
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitPropertiesEditorPageDefinition.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 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.jpa.ui.internal.persistence;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitEditorPageDefinition;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @version 3.3
+ * @since 2.0
+ */
+public class PersistenceUnitPropertiesEditorPageDefinition
+ extends PersistenceUnitEditorPageDefinition
+{
+ // singleton
+ private static final JpaEditorPageDefinition INSTANCE =
+ new PersistenceUnitPropertiesEditorPageDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JpaEditorPageDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ private PersistenceUnitPropertiesEditorPageDefinition() {
+ super();
+ }
+
+ public String getPageText() {
+ return JptUiPersistenceMessages.PersistenceUnitPropertiesComposite_properties;
+ }
+
+ public ImageDescriptor getPageImageDescriptor() {
+ return null;
+ }
+
+ public String getHelpID() {
+ return JpaHelpContextIds.PERSISTENCE_XML_PROPERTIES;
+ }
+
+ @Override
+ public void buildEditorPageContent(Composite parent, WidgetFactory widgetFactory, PropertyValueModel<JpaStructureNode> jpaRootStructureNodeModel) {
+ new PersistenceUnitPropertiesEditorPage(this.buildPersistenceUnitModel(jpaRootStructureNodeModel), parent, widgetFactory);
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java
index 249e2aa6dd..d36d36e854 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java
@@ -9,16 +9,19 @@
******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal.persistence;
+import java.util.List;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.ui.internal.jface.SimpleItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXmlDefinition;
import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.AbstractResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.structure.PersistenceStructureItemContentProviderFactory;
import org.eclipse.jpt.jpa.ui.internal.structure.PersistenceStructureItemLabelProviderFactory;
public class PersistenceXmlUiDefinition
- extends AbstractPersistenceXmlResourceUiDefinition
+ extends AbstractResourceUiDefinition
{
// singleton
private static final ResourceUiDefinition INSTANCE = new PersistenceXmlUiDefinition();
@@ -38,13 +41,14 @@ public class PersistenceXmlUiDefinition
private PersistenceXmlUiDefinition() {
super();
}
-
-
+
@Override
- protected PersistenceXmlUiFactory buildPersistenceXmlUiFactory() {
- return new GenericPersistenceXmlUiFactory();
+ protected void addEditorPageDefinitionsTo(List<JpaEditorPageDefinition> definitions) {
+ definitions.add(PersistenceUnitGeneralEditorPageDefinition.instance());
+ definitions.add(PersistenceUnitConnectionEditorPageDefinition.instance());
+ definitions.add(PersistenceUnitPropertiesEditorPageDefinition.instance());
}
-
+
public boolean providesUi(JptResourceType resourceType) {
return resourceType.equals(GenericPersistenceXmlDefinition.instance().getResourceType());
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiFactory.java
deleted file mode 100644
index a8142d9da8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 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.jpa.ui.internal.persistence;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.editors.JpaPageComposite;
-import org.eclipse.swt.widgets.Composite;
-
-public interface PersistenceXmlUiFactory
-{
- // **************** persistence unit composites ****************************
-
- /**
- * Creates the list of <code>JpaComposite</code>s used to edit a
- * <code>PersistenceUnit</code>. The properties can be regrouped into
- * sections that will be shown in the editor as pages.
- *
- * @param subjectHolder The holder of the pertistence unit
- * @param parent The parent container
- * @param widgetFactory The factory used to create the widgets
- * @return A new <code>JpaComposite</code>
- */
- ListIterator<JpaPageComposite> createPersistenceUnitComposites(
- PropertyValueModel<PersistenceUnit> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory);
-
-} \ No newline at end of file

Back to the top