Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2008-01-30 18:07:55 +0000
committerkmoore2008-01-30 18:07:55 +0000
commit157a60908a2a3492eeb95c4422cff3e38938b724 (patch)
treee5d63c0ef57afe72a32576dc1c740fb352ae29bf
parent4c03e3e1472a7427a97f7e102af0ba8352704a23 (diff)
downloadwebtools.dali-157a60908a2a3492eeb95c4422cff3e38938b724.tar.gz
webtools.dali-157a60908a2a3492eeb95c4422cff3e38938b724.tar.xz
webtools.dali-157a60908a2a3492eeb95c4422cff3e38938b724.zip
213467 - bug fixing patch from Pascal
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/.options8
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/Tracing.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java237
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentTypeDetailsPage.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/AbstractDatabaseObjectCombo.java214
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/CatalogCombo.java68
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/ColumnCombo.java113
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SchemaCombo.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SequenceCombo.java69
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/TableCombo.java95
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/CatalogCombo.java263
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java78
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityComposite.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedSuperclassComposite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OverridesComposite.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsComposite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SchemaCombo.java258
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SecondaryTablesComposite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java193
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableCombo.java269
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableComposite.java170
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/IJpaSelection.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/JpaSelection.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/LabeledTableItem.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AbstractPane.java135
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/TriStateCheckBox.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlJavaAttributeChooser.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java109
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentTypeDetailsPage.java2
34 files changed, 1105 insertions, 1570 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/.options b/jpa/plugins/org.eclipse.jpt.ui/.options
index 061a77825f..f5b5e7c9e3 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/.options
+++ b/jpa/plugins/org.eclipse.jpt.ui/.options
@@ -3,5 +3,11 @@
# Turn on debugging for the org.eclipse.jpt.ui plugin.
org.eclipse.jpt.ui/debug=false
+# Turn on debugging for unit-tests
+org.eclipse.jpt.ui/debug/unit-tests=false
+
# Turn on debugging for events occurring in the UI panes
-org.eclipse.jpt.ui/debug/layout=false
+org.eclipse.jpt.ui/debug/ui/layout=false
+
+# Turn on debugging for events coming from ConnectionProfile
+org.eclipse.jpt.ui/debug/ui/db=false
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/Tracing.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/Tracing.java
index da0563718b..326b8b5c6b 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/Tracing.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/Tracing.java
@@ -28,9 +28,14 @@ public final class Tracing
public static final String DEBUG = "/debug";
/**
- * A constant used to retrieve the value associated with "/debug/layout".
+ * A constant used to retrieve the value associated with "/debug/ui/db".
*/
- public static final String DEBUG_LAYOUT = "/debug/layout";
+ public static final String UI_DB = "/debug/ui/db";
+
+ /**
+ * A constant used to retrieve the value associated with "/debug/ui/layout".
+ */
+ public static final String UI_LAYOUT = "/debug/ui/layout";
/**
* A constant used to retrieve the value associated with "/unit-tests".
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java
index 0483778ecb..c7055284e1 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentAttributeDetailsPage.java
@@ -50,11 +50,11 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
@SuppressWarnings("nls")
public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage<IPersistentAttribute>
{
+ private IJpaComposite<IAttributeMapping> currentMappingComposite;
private String currentMappingKey;
private ComboViewer mappingCombo;
private Map<String, IJpaComposite<IAttributeMapping>> mappingComposites;
protected PageBook mappingPageBook;
- private IJpaComposite<IAttributeMapping> currentMappingComposite;
/**
* Creates a new <code>PersistentAttributeDetailsPage</code>.
@@ -70,29 +70,6 @@ public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage<
super(subjectHolder, parent, widgetFactory);
}
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initialize() {
- super.initialize();
- this.mappingComposites = new HashMap<String, IJpaComposite<IAttributeMapping>>();
- }
-
- protected IJpaPlatformUi jpaPlatformUi() {
- String platformId = subject().jpaProject().jpaPlatform().getId();
- return JpaPlatformUiRegistry.instance().jpaPlatform(platformId);
- }
-
- protected IJpaUiFactory jpaUiFactory() {
- // TODO: Remove the type cast, used for testing
- return ((BaseJpaPlatformUi) jpaPlatformUi()).getJpaUiFactory();
- }
-
- protected abstract ListIterator<IAttributeMappingUiProvider<? extends IAttributeMapping>> attributeMappingUiProviders();
-
- protected abstract ListIterator<IAttributeMappingUiProvider<? extends IAttributeMapping>> defaultAttributeMappingUiProviders();
-
protected IAttributeMappingUiProvider<? extends IAttributeMapping> attributeMappingUiProvider(String key) {
for (ListIterator<IAttributeMappingUiProvider<? extends IAttributeMapping>> i = attributeMappingUiProviders(); i.hasNext(); ) {
IAttributeMappingUiProvider<? extends IAttributeMapping> provider = i.next();
@@ -103,23 +80,11 @@ public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage<
throw new IllegalArgumentException("Unsupported attribute mapping UI provider key: ");
}
- protected abstract IAttributeMappingUiProvider<? extends IAttributeMapping> defaultAttributeMappingUiProvider(String key);
+ protected abstract ListIterator<IAttributeMappingUiProvider<? extends IAttributeMapping>>
+ attributeMappingUiProviders();
- protected Label buildMappingLabel(Composite parent) {
- return buildLabel(parent, JptUiMessages.PersistentAttributePage_mapAs);
- }
-
- protected ComboViewer buildMappingCombo(Composite parent) {
-
- this.mappingCombo = buildComboViewer(parent, buildLabelProvider());
- this.mappingCombo.setContentProvider(buildContentProvider());
- this.mappingCombo.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- mappingChanged(event);
- }
- });
- return this.mappingCombo;
- }
+ protected abstract IAttributeMappingUiProvider<? extends IAttributeMapping>[]
+ attributeMappingUiProvidersFor(IPersistentAttribute persistentAttribute);
private IContentProvider buildContentProvider() {
return new IStructuredContentProvider() {
@@ -140,8 +105,6 @@ public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage<
};
}
- protected abstract IAttributeMappingUiProvider<? extends IAttributeMapping>[] attributeMappingUiProvidersFor(IPersistentAttribute persistentAttribute);
-
private IBaseLabelProvider buildLabelProvider() {
return new LabelProvider() {
@Override
@@ -151,16 +114,19 @@ public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage<
};
}
- protected PageBook buildMappingPageBook(Composite parent) {
- this.mappingPageBook = new PageBook(parent, SWT.NONE);
- return this.mappingPageBook;
+ protected ComboViewer buildMappingCombo(Composite parent) {
+
+ this.mappingCombo = buildComboViewer(parent, buildLabelProvider());
+ this.mappingCombo.getCCombo().setVisibleItemCount(Integer.MAX_VALUE);
+ this.mappingCombo.setContentProvider(buildContentProvider());
+ this.mappingCombo.addSelectionChangedListener(buildMappingComboModifyListener());
+ return this.mappingCombo;
}
- private PropertyValueModel<IAttributeMapping> buildMappingHolder(final String key) {
- return new TransformationPropertyValueModel<IPersistentAttribute, IAttributeMapping>(getSubjectHolder()) {
- @Override
- protected IAttributeMapping transform_(IPersistentAttribute value) {
- return key.equals(value.mappingKey()) ? value.getMapping() : null;
+ private ISelectionChangedListener buildMappingComboModifyListener() {
+ return new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent e) {
+ mappingChanged(e);
}
};
}
@@ -179,23 +145,42 @@ public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage<
);
}
- private IAttributeMappingUiProvider<? extends IAttributeMapping> mappingUIProvider(String key) {
-
- if (this.subject().getMapping() == null ||
- this.subject().getMapping().isDefault()) {
+ private PropertyValueModel<IAttributeMapping> buildMappingHolder(final String key) {
+ return new TransformationPropertyValueModel<IPersistentAttribute, IAttributeMapping>(getSubjectHolder()) {
+ @Override
+ protected IAttributeMapping transform_(IPersistentAttribute value) {
+ return key.equals(value.mappingKey()) ? value.getMapping() : null;
+ }
+ };
+ }
- return defaultAttributeMappingUiProvider(key);
- }
+ protected Label buildMappingLabel(Composite parent) {
+ return buildLabel(parent, JptUiMessages.PersistentAttributePage_mapAs);
+ }
- return attributeMappingUiProvider(key);
+ protected PageBook buildMappingPageBook(Composite parent) {
+ this.mappingPageBook = new PageBook(parent, SWT.NONE);
+ return this.mappingPageBook;
}
- void mappingChanged(SelectionChangedEvent event) {
- if (event.getSelection() instanceof StructuredSelection) {
- IAttributeMappingUiProvider<?> provider = (IAttributeMappingUiProvider<?>) ((StructuredSelection) event.getSelection()).getFirstElement();
- String key = (CollectionTools.contains(defaultAttributeMappingUiProviders(), provider) ? null : provider.attributeMappingKey());
- this.subject().setSpecifiedMappingKey(key);
+ protected abstract IAttributeMappingUiProvider<? extends IAttributeMapping>
+ defaultAttributeMappingUiProvider(String key);
+
+ protected abstract ListIterator<IAttributeMappingUiProvider<? extends IAttributeMapping>>
+ defaultAttributeMappingUiProviders();
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ protected void doDispose() {
+ this.currentMappingComposite = null;
+
+ for (IJpaComposite<IAttributeMapping> composite : this.mappingComposites.values()) {
+ composite.dispose();
}
+
+ super.doDispose();
}
/*
@@ -207,40 +192,57 @@ public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage<
populateMappingComboAndPage();
}
- private void populateMappingComboAndPage() {
- populateMapAsCombo();
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ protected void initialize() {
+ super.initialize();
+ this.mappingComposites = new HashMap<String, IJpaComposite<IAttributeMapping>>();
+ }
- IAttributeMapping mapping = (this.subject() != null) ? this.subject().getMapping() : null;
- populateMappingPage(mapping == null ? null : mapping.getKey());
+ protected IJpaPlatformUi jpaPlatformUi() {
+ String platformId = subject().jpaProject().jpaPlatform().getId();
+ return JpaPlatformUiRegistry.instance().jpaPlatform(platformId);
}
- private void populateMappingPage(String mappingKey) {
- if (this.currentMappingComposite != null &&
- this.currentMappingKey == mappingKey) {
-
- this.currentMappingComposite.populate();
- return;
- }
-
- this.currentMappingKey = mappingKey;
-
- if (this.currentMappingKey != null) {
- this.currentMappingComposite = mappingCompositeFor(mappingKey);
-
- try {
- this.currentMappingComposite.populate();
- }
- finally {
- // Log or show error
- }
-
- this.mappingPageBook.showPage(this.currentMappingComposite.getControl());
- this.mappingPageBook.layout(true);
- }
- else {
- this.currentMappingComposite = null;
- this.mappingPageBook.showPage(new Label(this.mappingPageBook, SWT.NULL));
- }
+ protected IJpaUiFactory jpaUiFactory() {
+ // TODO: Remove the type cast, used for testing
+ return ((BaseJpaPlatformUi) jpaPlatformUi()).getJpaUiFactory();
+ }
+
+ void mappingChanged(SelectionChangedEvent event) {
+ if (event.getSelection() instanceof StructuredSelection) {
+ IAttributeMappingUiProvider<?> provider = (IAttributeMappingUiProvider<?>) ((StructuredSelection) event.getSelection()).getFirstElement();
+ String key = (CollectionTools.contains(defaultAttributeMappingUiProviders(), provider) ? null : provider.attributeMappingKey());
+ this.subject().setSpecifiedMappingKey(key);
+ }
+ }
+
+ private IJpaComposite<IAttributeMapping> mappingCompositeFor(String key) {
+ IJpaComposite<IAttributeMapping> composite = this.mappingComposites.get(key);
+ if (composite != null) {
+ return composite;
+ }
+
+ composite = buildMappingComposite(this.mappingPageBook, key);
+
+ if (composite != null) {
+ this.mappingComposites.put(key, composite);
+ }
+
+ return composite;
+ }
+
+ private IAttributeMappingUiProvider<? extends IAttributeMapping> mappingUIProvider(String key) {
+
+ if (this.subject().getMapping() == null ||
+ this.subject().getMapping().isDefault()) {
+
+ return defaultAttributeMappingUiProvider(key);
+ }
+
+ return attributeMappingUiProvider(key);
}
private void populateMapAsCombo() {
@@ -260,19 +262,11 @@ public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage<
}
}
- private IJpaComposite<IAttributeMapping> mappingCompositeFor(String key) {
- IJpaComposite<IAttributeMapping> composite = this.mappingComposites.get(key);
- if (composite != null) {
- return composite;
- }
-
- composite = buildMappingComposite(this.mappingPageBook, key);
-
- if (composite != null) {
- this.mappingComposites.put(key, composite);
- }
+ private void populateMappingComboAndPage() {
+ populateMapAsCombo();
- return composite;
+ IAttributeMapping mapping = (this.subject() != null) ? this.subject().getMapping() : null;
+ populateMappingPage(mapping == null ? null : mapping.getKey());
}
//TODO focus??
@@ -281,11 +275,34 @@ public abstract class PersistentAttributeDetailsPage extends BaseJpaDetailsPage<
// return mappingCombo.getCombo().setFocus();
// }
- @Override
- public void dispose() {
- for (IJpaComposite<IAttributeMapping> composite : this.mappingComposites.values()) {
- composite.dispose();
+ private void populateMappingPage(String mappingKey) {
+
+ if (this.currentMappingComposite != null) {
+ this.currentMappingComposite.dispose();
+
+ if (this.currentMappingKey == mappingKey) {
+ return;
+ }
+ }
+
+ this.currentMappingKey = mappingKey;
+
+ if (this.currentMappingKey != null) {
+ this.currentMappingComposite = mappingCompositeFor(mappingKey);
+
+ try {
+ this.currentMappingComposite.populate();
+ }
+ finally {
+ // Log or show error
+ }
+
+ this.mappingPageBook.showPage(this.currentMappingComposite.getControl());
+ this.mappingPageBook.layout(true);
+ }
+ else {
+ this.currentMappingComposite = null;
+ this.mappingPageBook.showPage(new Label(this.mappingPageBook, SWT.NULL));
}
- super.dispose();
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java
index 246eff796a..99945a8e20 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/PersistentTypeDetailsPage.java
@@ -48,10 +48,10 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
public abstract class PersistentTypeDetailsPage<T extends IPersistentType> extends BaseJpaDetailsPage<T>
{
private Map<String, IJpaComposite<ITypeMapping>> composites;
+ private IJpaComposite<ITypeMapping> currentMappingComposite;
private String currentMappingKey;
private ComboViewer typeMappingCombo;
private PageBook typeMappingPageBook;
- private IJpaComposite<ITypeMapping> visibleMappingComposite;
/**
* Creates a new <code>PersistentTypeDetailsPage</code>.
@@ -96,15 +96,6 @@ public abstract class PersistentTypeDetailsPage<T extends IPersistentType> exten
};
}
- private PropertyValueModel<ITypeMapping> buildMappingHolder(final String key) {
- return new TransformationPropertyValueModel<T, ITypeMapping>(getSubjectHolder()) {
- @Override
- protected ITypeMapping transform_(T value) {
- return key.equals(value.mappingKey()) ? value.getMapping() : null;
- }
- };
- }
-
@SuppressWarnings("unchecked")
protected IJpaComposite<ITypeMapping> buildMappingComposite(PageBook pageBook,
String key) {
@@ -119,9 +110,19 @@ public abstract class PersistentTypeDetailsPage<T extends IPersistentType> exten
);
}
+ private PropertyValueModel<ITypeMapping> buildMappingHolder(final String key) {
+ return new TransformationPropertyValueModel<T, ITypeMapping>(getSubjectHolder()) {
+ @Override
+ protected ITypeMapping transform_(T value) {
+ return key.equals(value.mappingKey()) ? value.getMapping() : null;
+ }
+ };
+ }
+
protected ComboViewer buildTypeMappingCombo(Composite parent) {
CCombo combo = buildCombo(parent);
this.typeMappingCombo = new ComboViewer(combo);
+ this.typeMappingCombo.getCCombo().setVisibleItemCount(Integer.MAX_VALUE);
this.typeMappingCombo.setContentProvider(buildContentProvider());
this.typeMappingCombo.setLabelProvider(buildLabelProvider());
this.typeMappingCombo.addSelectionChangedListener(new ISelectionChangedListener() {
@@ -145,11 +146,13 @@ public abstract class PersistentTypeDetailsPage<T extends IPersistentType> exten
* (non-Javadoc)
*/
@Override
- public void dispose() {
- for (Iterator<IJpaComposite<ITypeMapping>> i = this.composites.values().iterator(); i.hasNext(); ) {
- i.next().dispose();
+ protected void doDispose() {
+
+ for (Iterator<IJpaComposite<ITypeMapping>> iter = this.composites.values().iterator(); iter.hasNext(); ) {
+ iter.next().dispose();
}
- super.dispose();
+
+ super.doDispose();
}
/*
@@ -182,9 +185,9 @@ public abstract class PersistentTypeDetailsPage<T extends IPersistentType> exten
this.typeMappingCombo.setInput(null);
this.typeMappingCombo.setSelection(StructuredSelection.EMPTY);
- if (this.visibleMappingComposite != null) {
- this.visibleMappingComposite.populate();
- this.visibleMappingComposite = null;
+ if (this.currentMappingComposite != null) {
+ this.currentMappingComposite.populate();
+ this.currentMappingComposite = null;
}
return;
@@ -197,26 +200,32 @@ public abstract class PersistentTypeDetailsPage<T extends IPersistentType> exten
}
private void populateMappingPage(String mappingKey) {
- if (this.visibleMappingComposite != null) {
- if (mappingKey == this.currentMappingKey) {
- if (this.visibleMappingComposite != null) {
- this.visibleMappingComposite.populate();
- return;
- }
- }
- else {
- this.visibleMappingComposite.populate();
- // don't return
- }
+ if (this.currentMappingComposite != null &&
+ this.currentMappingKey == mappingKey) {
+
+ this.currentMappingComposite.populate();
+ return;
}
this.currentMappingKey = mappingKey;
- IJpaComposite<ITypeMapping> mappingComposite = mappingCompositeFor(mappingKey);
- this.typeMappingPageBook.showPage(mappingComposite.getControl());
+ if (this.currentMappingKey != null) {
+ this.currentMappingComposite = mappingCompositeFor(mappingKey);
- this.visibleMappingComposite = mappingComposite;
- this.visibleMappingComposite.populate();
+ try {
+ this.currentMappingComposite.populate();
+ }
+ finally {
+ // Log or show error
+ }
+
+ this.typeMappingPageBook.showPage(this.currentMappingComposite.getControl());
+ this.typeMappingPageBook.layout(true);
+ }
+ else {
+ this.currentMappingComposite = null;
+ this.typeMappingPageBook.showPage(new Label(this.typeMappingPageBook, SWT.NULL));
+ }
}
private void setComboData(String mappingKey) {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentTypeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentTypeDetailsPage.java
index d7cec9599a..a03f5244af 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentTypeDetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/java/details/JavaPersistentTypeDetailsPage.java
@@ -72,7 +72,7 @@ public class JavaPersistentTypeDetailsPage extends PersistentTypeDetailsPage<IJa
buildLabeledComposite(
container,
buildTypeMappingLabel(container),
- buildTypeMappingCombo(container).getControl()
+ buildTypeMappingCombo(container).getControl().getParent()
);
PageBook typeMappingPageBook = buildTypeMappingPageBook(container);
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/AbstractDatabaseObjectCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/AbstractDatabaseObjectCombo.java
index a1b0f38a90..fdf54a4b31 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/AbstractDatabaseObjectCombo.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/AbstractDatabaseObjectCombo.java
@@ -8,33 +8,51 @@
*******************************************************************************/
package org.eclipse.jpt.ui.internal.mappings.db;
+import java.util.Iterator;
import org.eclipse.jpt.core.internal.IJpaNode;
import org.eclipse.jpt.db.internal.ConnectionListener;
import org.eclipse.jpt.db.internal.ConnectionProfile;
import org.eclipse.jpt.db.internal.Database;
import org.eclipse.jpt.db.internal.Schema;
import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.jpt.ui.internal.Tracing;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.util.SWTUtil;
import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
/**
- * This is the abstract implementation that keeps a combo in sync with the
- * database objects when a connection is active.
+ * This abstract implementation keeps a combo in sync with the database objects
+ * when a connection is active.
+ *
+ * @see CatalogCombo
+ * @see ColumnCombo
+ * @see SchemaCombo
+ * @see TableCombo
*
* @version 2.0
* @since 2.0
*/
+@SuppressWarnings("nls")
public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends AbstractFormPane<T>
{
+ /**
+ * The main widget of this pane.
+ */
private CCombo combo;
+
+ /**
+ * The listener added to the <code>ConnectionProfile</code> responsible to
+ * keep the combo in sync with the database metadata.
+ */
private ConnectionListener connectionListener;
/**
@@ -58,27 +76,32 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
*/
protected AbstractDatabaseObjectCombo(PropertyValueModel<? extends T> subjectHolder,
Composite parent,
- TabbedPropertySheetWidgetFactory widgetFactory)
+ IWidgetFactory widgetFactory)
{
super(subjectHolder, parent, widgetFactory);
}
private void addConnectionListener(T column) {
if (column != null) {
- column.jpaProject().connectionProfile().addConnectionListener(this.connectionListener);
+ column.jpaProject().connectionProfile().addConnectionListener(connectionListener);
}
}
private ConnectionListener buildConnectionListener() {
+
return new ConnectionListener() {
public void aboutToClose(ConnectionProfile profile) {
+ log("aboutToClose");
}
public void closed(ConnectionProfile profile) {
+
SWTUtil.asyncExec(new Runnable() {
public void run() {
- if (!getControl().isDisposed()) {
+ log("closed");
+
+ if (!combo.isDisposed()) {
AbstractDatabaseObjectCombo.this.repopulate();
}
}
@@ -87,12 +110,16 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
public void databaseChanged(ConnectionProfile profile,
Database database) {
+
+ log("databaseChanged");
}
public void modified(ConnectionProfile profile) {
SWTUtil.asyncExec(new Runnable() {
public void run() {
- if (!getControl().isDisposed()) {
+ log("modified");
+
+ if (!combo.isDisposed()) {
AbstractDatabaseObjectCombo.this.repopulate();
}
}
@@ -100,13 +127,17 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
}
public boolean okToClose(ConnectionProfile profile) {
+ log("okToClose");
return true;
}
public void opened(ConnectionProfile profile) {
+
SWTUtil.asyncExec(new Runnable() {
public void run() {
- if (!getControl().isDisposed()) {
+ log("opened");
+
+ if (!combo.isDisposed()) {
AbstractDatabaseObjectCombo.this.repopulate();
}
}
@@ -118,7 +149,9 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
SWTUtil.asyncExec(new Runnable() {
public void run() {
- if (!getControl().isDisposed()) {
+ log("schemaChanged: " + schema.getName());
+
+ if (!combo.isDisposed()) {
AbstractDatabaseObjectCombo.this.schemaChanged(schema);
}
}
@@ -130,7 +163,9 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
SWTUtil.asyncExec(new Runnable() {
public void run() {
- if (!getControl().isDisposed()) {
+ log("tableChanged: " + table.getName());
+
+ if (!combo.isDisposed()) {
AbstractDatabaseObjectCombo.this.tableChanged(table);
}
}
@@ -142,16 +177,43 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
private ModifyListener buildModifyListener() {
return new ModifyListener() {
public void modifyText(ModifyEvent e) {
- CCombo combo = (CCombo) e.widget;
- AbstractDatabaseObjectCombo.this.valueChanged(combo.getText());
+ if (!isPopulating()) {
+ CCombo combo = (CCombo) e.widget;
+ valueChanged(combo.getText());
+ }
}
};
}
+ /**
+ * Returns the JPA project's connection profile, which is never
+ * <code>null</code>.
+ *
+ * @return The connection set in the project's properties or a <code>null</code>
+ * connection
+ */
protected final ConnectionProfile connectionProfile() {
- return this.subject().jpaProject().connectionProfile();
+ return subject().jpaProject().connectionProfile();
+ }
+
+ /**
+ * Returns the database associated with the active connection profile.
+ *
+ * @return The online database or a <code>null</code> instance if no
+ * connection profile was set or the
+ */
+ protected final Database database() {
+ return connectionProfile().getDatabase();
}
+ /**
+ * Returns the default value, or <code>null</code> if no default is
+ * specified.
+ *
+ * @return The value that represents the default when no value was specified
+ */
+ protected abstract String defaultValue();
+
/*
* (non-Javadoc)
*/
@@ -165,10 +227,24 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
* (non-Javadoc)
*/
@Override
+ protected void doPopulate() {
+
+ combo.removeAll();
+
+ if (subject() != null) {
+ populateCombo();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
public void enableWidgets(boolean enabled) {
+
super.enableWidgets(enabled);
- if (!this.combo.isDisposed()) {
+ if (!combo.isDisposed()) {
combo.setEnabled(enabled);
}
}
@@ -183,7 +259,7 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
}
public final CCombo getCombo() {
- return this.combo;
+ return combo;
}
/*
@@ -192,7 +268,7 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
@Override
protected void initialize() {
super.initialize();
- this.connectionListener = this.buildConnectionListener();
+ connectionListener = buildConnectionListener();
}
/*
@@ -201,18 +277,74 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
@Override
protected void initializeLayout(Composite container) {
- this.combo = this.buildCombo(container);
- this.combo.add(JptUiMappingsMessages.ColumnComposite_defaultEmpty);
- this.combo.addModifyListener(this.buildModifyListener());
+ combo = buildCombo(container);
+ combo.add(JptUiMappingsMessages.ColumnComposite_defaultEmpty);
+ combo.addModifyListener(buildModifyListener());
+ }
+
+ private void log(String message) {
+ if (Tracing.booleanDebugOption(Tracing.UI_DB)) {
+ Class<?> thisClass = getClass();
+ String className = ClassTools.shortNameFor(thisClass);
+
+ if (thisClass.isAnonymousClass()) {
+ className = className.substring(0, className.indexOf('$'));
+ className += "->" + ClassTools.shortNameFor(thisClass.getSuperclass());
+ }
+
+ Tracing.log(className + ": " + message);
+ }
+ }
+
+ /**
+ * Populates the combo's list by adding first the default value is available
+ * and then the possible choices.
+ */
+ private void populateCombo() {
+
+ populateDefaultValue();
+
+ if (connectionProfile().isConnected()) {
+
+ for (Iterator<String> iter = CollectionTools.sort(values()); iter.hasNext(); ) {
+ combo.add(iter.next());
+ }
+ }
+
+ updateSelectedItem();
+ }
+
+ /**
+ * Adds the default value to the combo if one exists.
+ */
+ private void populateDefaultValue() {
+
+ String defaultValue = defaultValue();
+
+ if (defaultValue != null) {
+ combo.add(NLS.bind(
+ JptUiMappingsMessages.ColumnComposite_defaultWithOneParam,
+ defaultValue
+ ));
+ }
+ else {
+ combo.add(JptUiMappingsMessages.ColumnComposite_defaultEmpty);
+ }
}
private void removeConnectionListener(T value) {
if (value != null) {
- value.jpaProject().connectionProfile().removeConnectionListener(this.connectionListener);
+ value.jpaProject().connectionProfile().removeConnectionListener(connectionListener);
}
}
- protected abstract void schemaChanged(Schema schema);
+ /**
+ * The
+ *
+ * @param schema
+ */
+ protected void schemaChanged(Schema schema) {
+ }
/**
* Sets the given value as the new value.
@@ -221,7 +353,36 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
*/
protected abstract void setValue(String value);
- protected abstract void tableChanged(Table table);
+ /**
+ * The
+ *
+ * @param catalog
+ */
+ protected void tableChanged(Table table) {
+ }
+
+ /**
+ * Updates the selected item by selected the current value, if not
+ * <code>null</code>, or select the default value if one is available,
+ * otherwise remove the selection.
+ */
+ private void updateSelectedItem() {
+ String value = value();
+
+ if (value != null) {
+ combo.setText(value);
+ }
+ else {
+ String defaultValue = defaultValue();
+
+ if (!combo.getText().equals(NLS.bind(JptUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultValue))) {
+ combo.select(0);
+ }
+ else {
+ combo.select(-1);
+ }
+ }
+ }
/**
* Requests the current value from the model object.
@@ -270,4 +431,13 @@ public abstract class AbstractDatabaseObjectCombo<T extends IJpaNode> extends Ab
setValue(value);
}
}
+
+ /**
+ * Retrieves the possible values, which will be added to the combo during
+ * population.
+ *
+ * @return A non-<code>null</code> <code>Iterator</code> of the possible
+ * choices to be added to the combo
+ */
+ protected abstract Iterator<String> values();
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/CatalogCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/CatalogCombo.java
new file mode 100644
index 0000000000..c5473562ac
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/CatalogCombo.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.db;
+
+import java.util.Iterator;
+import org.eclipse.jpt.core.internal.IJpaNode;
+import org.eclipse.jpt.db.internal.Database;
+import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This database object combo handles showing the database's catalogs.
+ *
+ * @version 2.0
+ * @since 2.0
+ */
+public abstract class CatalogCombo<T extends IJpaNode> extends AbstractDatabaseObjectCombo<T>
+{
+ /**
+ * Creates a new <code>CatalogCombo</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public CatalogCombo(AbstractFormPane<? extends T> parentPane,
+ Composite parent) {
+
+ super(parentPane, parent);
+ }
+
+ /**
+ * Creates a new <code>CatalogCombo</code>.
+ *
+ * @param subjectHolder The holder of the subject
+ * @param parent The parent container
+ * @param widgetFactory The factory used to create various common widgets
+ */
+ public CatalogCombo(PropertyValueModel<? extends T> subjectHolder,
+ Composite parent,
+ IWidgetFactory widgetFactory) {
+
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ protected Iterator<String> values() {
+
+ Database database = database();
+
+ if (database != null) {
+ return database.catalogNames();
+ }
+
+ return EmptyIterator.instance();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/ColumnCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/ColumnCombo.java
index e8f78a61f8..63d298356d 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/ColumnCombo.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/ColumnCombo.java
@@ -8,27 +8,21 @@
*******************************************************************************/
package org.eclipse.jpt.ui.internal.mappings.db;
-import java.util.List;
-import org.eclipse.jpt.core.internal.context.base.IColumn;
-import org.eclipse.jpt.db.internal.Schema;
+import java.util.Iterator;
+import org.eclipse.jpt.core.internal.IJpaNode;
import org.eclipse.jpt.db.internal.Table;
-import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
/**
- * This combo manages a table's columns.
- *
- * @see IColumn
+ * This database object combo handles showing a table's columns.
*
* @version 2.0
* @since 2.0
*/
-public class ColumnCombo extends AbstractDatabaseObjectCombo<IColumn>
+public abstract class ColumnCombo<T extends IJpaNode> extends AbstractDatabaseObjectCombo<T>
{
/**
* Creates a new <code>ColumnCombo</code>.
@@ -36,7 +30,7 @@ public class ColumnCombo extends AbstractDatabaseObjectCombo<IColumn>
* @param parentPane The parent container of this one
* @param parent The parent container
*/
- public ColumnCombo(AbstractFormPane<? extends IColumn> parentPane,
+ public ColumnCombo(AbstractFormPane<? extends T> parentPane,
Composite parent) {
super(parentPane, parent);
@@ -49,69 +43,24 @@ public class ColumnCombo extends AbstractDatabaseObjectCombo<IColumn>
* @param parent The parent container
* @param widgetFactory The factory used to create various common widgets
*/
- public ColumnCombo(PropertyValueModel<IColumn> subjectHolder,
+ public ColumnCombo(PropertyValueModel<? extends T> subjectHolder,
Composite parent,
- TabbedPropertySheetWidgetFactory widgetFactory)
- {
+ IWidgetFactory widgetFactory) {
+
super(subjectHolder, parent, widgetFactory);
}
+ protected abstract Table table();
+
/*
* (non-Javadoc)
*/
@Override
- protected void doPopulate() {
-
- this.getCombo().removeAll();
-
- if (subject() != null) {
-
- this.populateDefaultColumnName();
-
- if (this.connectionProfile().isConnected()) {
-
- Table table = table();
-
- if (table != null) {
-
- List<String> columnNames = CollectionTools.sort(CollectionTools.list(table.columnNames()));
-
- for (String columnName : columnNames) {
- this.getCombo().add(columnName);
- }
- }
- }
-
- populateCombo();
- }
- }
-
- private void populateCombo() {
- String specifiedColumnName = this.subject().getSpecifiedName();
- if (specifiedColumnName != null) {
- if (!this.getCombo().getText().equals(specifiedColumnName)) {
- this.getCombo().setText(specifiedColumnName);
- }
- }
- else {
- String defaultColumnName = this.subject().getDefaultName();
- if (!this.getCombo().getText().equals(NLS.bind(JptUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultColumnName))) {
- this.getCombo().select(0);
- }
- }
- }
-
- private void populateDefaultColumnName() {
- String defaultColumnName = subject().getDefaultName();
- int selectionIndex = getCombo().getSelectionIndex();
- getCombo().add(NLS.bind(JptUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultColumnName));
+ protected void tableChanged(Table table) {
+ super.tableChanged(table);
- if (selectionIndex == 0) {
- // Combo text does not update when switching between 2 mappings of the
- // same type that both have a default subject() name. clear the
- // selection and then set it again
- getCombo().clearSelection();
- getCombo().select(0);
+ if (table == table()) {
+ this.doPopulate();
}
}
@@ -119,36 +68,14 @@ public class ColumnCombo extends AbstractDatabaseObjectCombo<IColumn>
* (non-Javadoc)
*/
@Override
- protected void schemaChanged(Schema schema) {
- }
+ protected Iterator<String> values() {
- /*
- * (non-Javadoc)
- */
- @Override
- protected void setValue(String value) {
- subject().setSpecifiedName(value);
- }
-
- protected final Table table() {
- return this.subject().dbTable();
- }
+ Table table = table();
- /*
- * (non-Javadoc)
- */
- @Override
- protected void tableChanged(Table table) {
- if (table == table()) {
- this.doPopulate();
+ if (table != null) {
+ return table.columnNames();
}
- }
- /*
- * (non-Javadoc)
- */
- @Override
- protected String value() {
- return subject().getSpecifiedName();
+ return EmptyIterator.instance();
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SchemaCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SchemaCombo.java
index ed88532360..31924eab52 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SchemaCombo.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SchemaCombo.java
@@ -8,19 +8,21 @@
*******************************************************************************/
package org.eclipse.jpt.ui.internal.mappings.db;
+import java.util.Iterator;
import org.eclipse.jpt.core.internal.IJpaNode;
-import org.eclipse.jpt.db.internal.Schema;
-import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.jpt.db.internal.Database;
import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
/**
+ * This database object combo handles showing the database's schemas.
+ *
* @version 2.0
* @since 2.0
*/
-public abstract class SchemaCombo extends AbstractDatabaseObjectCombo<IJpaNode>
+public abstract class SchemaCombo<T extends IJpaNode> extends AbstractDatabaseObjectCombo<T>
{
/**
* Creates a new <code>SchemaCombo</code>.
@@ -28,7 +30,7 @@ public abstract class SchemaCombo extends AbstractDatabaseObjectCombo<IJpaNode>
* @param parentPane The parent container of this one
* @param parent The parent container
*/
- public SchemaCombo(AbstractFormPane<? extends IJpaNode> parentPane,
+ public SchemaCombo(AbstractFormPane<? extends T> parentPane,
Composite parent)
{
super(parentPane, parent);
@@ -41,9 +43,9 @@ public abstract class SchemaCombo extends AbstractDatabaseObjectCombo<IJpaNode>
* @param parent The parent container
* @param widgetFactory The factory used to create various common widgets
*/
- public SchemaCombo(PropertyValueModel<? extends IJpaNode> subjectHolder,
+ public SchemaCombo(PropertyValueModel<? extends T> subjectHolder,
Composite parent,
- TabbedPropertySheetWidgetFactory widgetFactory)
+ IWidgetFactory widgetFactory)
{
super(subjectHolder, parent, widgetFactory);
}
@@ -52,14 +54,14 @@ public abstract class SchemaCombo extends AbstractDatabaseObjectCombo<IJpaNode>
* (non-Javadoc)
*/
@Override
- protected void schemaChanged(Schema schema) {
-// connectionProfile().getDatabase().schemaNamed();
- }
+ protected Iterator<String> values() {
- /*
- * (non-Javadoc)
- */
- @Override
- protected void tableChanged(Table table) {
+ Database database = this.database();
+
+ if (database != null) {
+ return database.schemaNames();
+ }
+
+ return EmptyIterator.instance();
}
-}
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SequenceCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SequenceCombo.java
new file mode 100644
index 0000000000..3f5773bd9b
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/SequenceCombo.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.ui.internal.mappings.db;
+
+import java.util.Iterator;
+import org.eclipse.jpt.core.internal.IJpaNode;
+import org.eclipse.jpt.db.internal.Schema;
+import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This database object combo handles showing the database's sequences for a
+ * given <code>Schema</code>.
+ *
+ * @version 2.0
+ * @since 2.0
+ */
+public abstract class SequenceCombo<T extends IJpaNode> extends AbstractDatabaseObjectCombo<T>
+{
+ /**
+ * Creates a new <code>SequenceCombo</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public SequenceCombo(AbstractFormPane<? extends T> parentPane, Composite parent)
+ {
+ super(parentPane, parent);
+ }
+
+ /**
+ * Creates a new <code>SequenceCombo</code>.
+ *
+ * @param subjectHolder The holder of the subject
+ * @param parent The parent container
+ * @param widgetFactory The factory used to create various common widgets
+ */
+ public SequenceCombo(PropertyValueModel<? extends T> subjectHolder,
+ Composite parent,
+ IWidgetFactory widgetFactory)
+ {
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ protected abstract Schema schema();
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ protected Iterator<String> values() {
+ Schema schema = schema();
+
+ if (schema != null) {
+ return schema.sequenceNames();
+ }
+
+ return EmptyIterator.instance();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/TableCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/TableCombo.java
index 7b05be975f..d3a7a1bf2a 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/TableCombo.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/db/TableCombo.java
@@ -8,26 +8,19 @@
*******************************************************************************/
package org.eclipse.jpt.ui.internal.mappings.db;
-import java.util.Iterator;
-import org.eclipse.jpt.core.internal.context.base.IColumn;
-import org.eclipse.jpt.db.internal.Schema;
+import org.eclipse.jpt.core.internal.IJpaNode;
import org.eclipse.jpt.db.internal.Table;
-import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
/**
- * This composite handles the display of database tables.
- *
- * @see IColumn
+ * This database object combo handles showing the database's tables.
*
* @version 2.0
* @since 2.0
*/
-public class TableCombo extends AbstractDatabaseObjectCombo<IColumn>
+public abstract class TableCombo<T extends IJpaNode> extends AbstractDatabaseObjectCombo<T>
{
/**
* Creates a new <code>TableCombo</code>.
@@ -35,7 +28,7 @@ public class TableCombo extends AbstractDatabaseObjectCombo<IColumn>
* @param parentPane The parent container of this one
* @param parent The parent container
*/
- public TableCombo(AbstractFormPane<? extends IColumn> parentPane,
+ public TableCombo(AbstractFormPane<? extends T> parentPane,
Composite parent) {
super(parentPane, parent);
@@ -48,80 +41,14 @@ public class TableCombo extends AbstractDatabaseObjectCombo<IColumn>
* @param parent The parent container
* @param widgetFactory The factory used to create various common widgets
*/
- public TableCombo(PropertyValueModel<? extends IColumn> subjectHolder,
+ public TableCombo(PropertyValueModel<? extends T> subjectHolder,
Composite parent,
- TabbedPropertySheetWidgetFactory widgetFactory)
+ IWidgetFactory widgetFactory)
{
super(subjectHolder, parent, widgetFactory);
}
- /*
- * (non-Javadoc)
- */
- @Override
- protected void doPopulate() {
- this.getCombo().removeAll();
-
- if (this.subject() != null) {
- this.populateDefaultColumnTable();
-
- if (this.subject() != null) {
- for (Iterator<String> iter = this.subject().owner().typeMapping().associatedTableNamesIncludingInherited(); iter.hasNext(); ) {
- this.getCombo().add(iter.next());
- }
- }
-
- this.populateCombo();
- }
- }
-
- private void populateCombo() {
- String tableName = this.subject().getSpecifiedTable();
- String defaultTableName = this.subject().getDefaultTable();
- if (tableName != null) {
- if (!this.getCombo().getText().equals(tableName)) {
- this.getCombo().setText(tableName);
- }
- }
- else {
- if (!this.getCombo().getText().equals(NLS.bind(JptUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultTableName))) {
- this.getCombo().select(0);
- }
- }
- }
-
- private void populateDefaultColumnTable() {
- String defaultTableName = subject().getDefaultTable();
- int selectionIndex = getCombo().getSelectionIndex();
- getCombo().add(NLS.bind(JptUiMappingsMessages.ColumnComposite_defaultWithOneParam, defaultTableName));
-
- if (selectionIndex == 0) {
- // Combo text does not update when switching between 2 mappings of the
- // same type that both have a default subject() name. clear the
- // selection and then set it again
- getCombo().clearSelection();
- getCombo().select(0);
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void schemaChanged(Schema schema) {
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void setValue(String value) {
- subject().setSpecifiedTable(value);
- }
-
- protected final Table table() {
- return this.subject().dbTable();
- }
+ protected abstract Table table();
/*
* (non-Javadoc)
@@ -132,12 +59,4 @@ public class TableCombo extends AbstractDatabaseObjectCombo<IColumn>
this.doPopulate();
}
}
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected String value() {
- return subject().getSpecifiedTable();
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/CatalogCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/CatalogCombo.java
deleted file mode 100644
index 9e625e1604..0000000000
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/CatalogCombo.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.ui.internal.mappings.details;
-
-import java.util.Iterator;
-import org.eclipse.jpt.core.internal.context.base.ITable;
-import org.eclipse.jpt.db.internal.ConnectionListener;
-import org.eclipse.jpt.db.internal.ConnectionProfile;
-import org.eclipse.jpt.db.internal.Database;
-import org.eclipse.jpt.db.internal.Schema;
-import org.eclipse.jpt.db.internal.Table;
-import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-
-public class CatalogCombo extends AbstractFormPane<ITable>
-{
- private CCombo combo;
-
- private ConnectionListener connectionListener;
-
- /**
- * Caching the connectionProfile so we can remove the listener. If the
- * cached table object has been removed from the model then we no longer
- * have access to the parent and cannot find the connectionProfile
- */
- private ConnectionProfile connectionProfile;
-
- public CatalogCombo(AbstractFormPane<? extends ITable> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- public CatalogCombo(PropertyValueModel<? extends ITable> subjectHolder,
- Composite parent,
- TabbedPropertySheetWidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- this.connectionListener = this.buildConnectionListener();
- }
-
- private void addConnectionListener() {
- this.getConnectionProfile().addConnectionListener(this.connectionListener);
- }
-
- private ConnectionListener buildConnectionListener() {
- return new ConnectionListener() {
- public void aboutToClose(ConnectionProfile profile) {
- // not interested to this event.
- }
-
- public void closed(ConnectionProfile profile) {
- getCombo().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- CatalogCombo.this.populateCatalogCombo();
- }
- });
- }
-
- public void databaseChanged(ConnectionProfile profile, final Database database) {
- getControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (database == CatalogCombo.this.getDatabase()) {
- if (!getControl().isDisposed()) {
- CatalogCombo.this.populateCatalogCombo();
- }
- }
- }
- });
- }
-
- public void modified(ConnectionProfile profile) {
- getCombo().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- CatalogCombo.this.populateCatalogCombo();
- }
- });
- }
-
- public boolean okToClose(ConnectionProfile profile) {
- // not interested to this event.
- return true;
- }
-
- public void opened(ConnectionProfile profile) {
- getCombo().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- CatalogCombo.this.populateCatalogCombo();
- }
- });
- }
-
- public void schemaChanged(ConnectionProfile profile, final Schema schema) {
- // not interested to this event.
- }
-
- public void tableChanged(ConnectionProfile profile, final Table table) {
- // not interested to this event.
- }
- };
- }
-
- @Override
- protected void disengageListeners() {
- super.disengageListeners();
-// if (this.subject() != null) {
-// this.removeConnectionListener();
-// this.subject().eAdapters().remove(this.listener);
-// }
- }
-
- @Override
- public void doPopulate() {
- super.doPopulate();
- if (this.subject() != null) {
- this.populateCatalogCombo();
- }
- else {
- this.connectionProfile = null;
- }
- }
-
-// public void doPopulate() {
-// this.populateCatalogCombo();
-// }
-
- @Override
- protected void engageListeners() {
- super.engageListeners();
-// if (this.subject() != null) {
-// this.subject().eAdapters().add(this.listener);
-// this.addConnectionListener();
-// }
- }
-
- public CCombo getCombo() {
- return this.combo;
- }
-
- private ConnectionProfile getConnectionProfile() {
- if (this.connectionProfile == null) {
- this.connectionProfile = this.subject().jpaProject().connectionProfile();
- }
- return this.connectionProfile;
- }
-
- protected Database getDatabase() {
- return this.getConnectionProfile().getDatabase();
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- this.combo = buildCombo(container); // TODO: Was using SWT.READ_ONLY
- this.combo.add(JptUiMappingsMessages.TableComposite_defaultEmpty);
- this.combo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String catalogText = ((CCombo) e.getSource()).getText();
- if (catalogText.equals("")) { //$NON-NLS-1$
- catalogText = null;
- if (CatalogCombo.this.subject().getSpecifiedCatalog() == null || CatalogCombo.this.subject().getSpecifiedCatalog().equals("")) { //$NON-NLS-1$
- return;
- }
- }
- if (catalogText != null && combo.getItemCount() > 0 && catalogText.equals(combo.getItem(0))) {
- catalogText = null;
- }
- if (CatalogCombo.this.subject().getSpecifiedCatalog() == null && catalogText != null) {
- CatalogCombo.this.setSpecifiedCatalog(catalogText);
- }
- if (CatalogCombo.this.subject().getSpecifiedCatalog() != null && !CatalogCombo.this.subject().getSpecifiedCatalog().equals(catalogText)) {
- CatalogCombo.this.setSpecifiedCatalog(catalogText);
- }
- }
- });
- }
-
- private void populateCatalogCombo() {
- if (this.subject() == null) {
- return;
- }
- this.populateDefaultCatalogName();
- if (this.getConnectionProfile().isConnected()) {
- this.combo.remove(1, this.combo.getItemCount() - 1);
- Database database = this.getDatabase();
- if (database != null) {
- Iterator<String> catalogs = database.catalogNames();
- for (Iterator<String> stream = CollectionTools.sort(catalogs); stream.hasNext();) {
- this.combo.add(stream.next());
- }
- }
- }
- else {
- this.combo.remove(1, this.combo.getItemCount() - 1);
- }
- this.populateCatalogName();
- }
-
- protected void populateCatalogName() {
- if (this.subject() == null) {
- return;
- }
- String catalogName = this.subject().getSpecifiedCatalog();
- // String defaultCatalogName = this.subject().getDefaultCatalog(); //
- // DefaultCatalog cannot be initialized if DB not online
- String defaultCatalogName = this.getDatabase().getDefaultCatalogName(); // TOREVIEW
- if (!StringTools.stringIsEmpty(catalogName)) {
- if (!this.combo.getText().equals(catalogName)) {
- this.combo.setText(catalogName);
- }
- }
- else {
- if (!this.combo.getText().equals(NLS.bind(JptUiMappingsMessages.TableComposite_defaultWithOneParam, defaultCatalogName))) {
- this.combo.select(0);
- }
- }
- }
-
- protected void populateDefaultCatalogName() {
- // String defaultCatalogName = this.subject().getDefaultCatalog(); //
- // DefaultCatalog cannot be initialized if DB not online
- String defaultCatalogName = this.getDatabase().getDefaultCatalogName(); // TOREVIEW
- int selectionIndex = combo.getSelectionIndex();
- combo.setItem(0, NLS.bind(JptUiMappingsMessages.TableComposite_defaultWithOneParam, defaultCatalogName));
- if (selectionIndex == 0) {
- combo.clearSelection();
- combo.select(0);
- }
- }
-
- private void removeConnectionListener() {
- this.getConnectionProfile().removeConnectionListener(this.connectionListener);
- }
-
- private void setSpecifiedCatalog(String catalogName) {
- this.subject().setSpecifiedCatalog(catalogName);
- this.getConnectionProfile().setCatalogName(catalogName);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java
index 4b5d0fed59..46d470e433 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/ColumnComposite.java
@@ -8,7 +8,10 @@
******************************************************************************/
package org.eclipse.jpt.ui.internal.mappings.details;
+import java.util.Collection;
+import java.util.Iterator;
import org.eclipse.jpt.core.internal.context.base.IColumn;
+import org.eclipse.jpt.db.internal.Table;
import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.mappings.db.ColumnCombo;
@@ -89,6 +92,39 @@ public class ColumnComposite extends AbstractFormPane<IColumn>
super(subjectHolder, parent, widgetFactory);
}
+ private ColumnCombo<IColumn> buildColumnCombo(Composite container) {
+
+ return new ColumnCombo<IColumn>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(IColumn.DEFAULT_NAME_PROPERTY);
+ propertyNames.add(IColumn.SPECIFIED_NAME_PROPERTY);
+ }
+
+ @Override
+ protected String defaultValue() {
+ return subject().getDefaultName();
+ }
+
+ @Override
+ protected void setValue(String value) {
+ subject().setSpecifiedName(value);
+ }
+
+ @Override
+ protected Table table() {
+ return subject().dbTable();
+ }
+
+ @Override
+ protected String value() {
+ return subject().getSpecifiedName();
+ }
+ };
+ }
+
private WritablePropertyValueModel<Boolean> buildInsertableHolder() {
return new PropertyAspectAdapter<IColumn, Boolean>(
getSubjectHolder(),
@@ -135,6 +171,44 @@ public class ColumnComposite extends AbstractFormPane<IColumn>
};
}
+ private TableCombo<IColumn> buildTableCombo(Composite container) {
+
+ return new TableCombo<IColumn>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(IColumn.DEFAULT_TABLE_PROPERTY);
+ propertyNames.add(IColumn.SPECIFIED_TABLE_PROPERTY);
+ }
+
+ @Override
+ protected String defaultValue() {
+ return subject().getDefaultTable();
+ }
+
+ @Override
+ protected void setValue(String value) {
+ subject().setSpecifiedTable(value);
+ }
+
+ @Override
+ protected Table table() {
+ return subject().dbTable();
+ }
+
+ @Override
+ protected String value() {
+ return subject().getSpecifiedTable();
+ }
+
+ @Override
+ protected Iterator<String> values() {
+ return subject().owner().typeMapping().associatedTableNamesIncludingInherited();
+ }
+ };
+ }
+
private WritablePropertyValueModel<Boolean> buildUpdatableHolder() {
return new PropertyAspectAdapter<IColumn, Boolean>(
getSubjectHolder(),
@@ -204,7 +278,7 @@ public class ColumnComposite extends AbstractFormPane<IColumn>
);
// Column widgets
- ColumnCombo columnCombo = new ColumnCombo(this, container);
+ ColumnCombo<IColumn> columnCombo = buildColumnCombo(container);
buildLabeledComposite(
container,
@@ -214,7 +288,7 @@ public class ColumnComposite extends AbstractFormPane<IColumn>
);
// Table widgets
- TableCombo tableCombo = new TableCombo(this, container);
+ TableCombo<IColumn> tableCombo = buildTableCombo(container);
buildLabeledComposite(
container,
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityComposite.java
index d3cd27a471..8f3d63b076 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/EntityComposite.java
@@ -34,20 +34,22 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
* | | | |
* | ------------------------------------------------------------------------- |
* | |
- * | - Attribute Overrides --------------------------------------------------- |
+ * | - v Attribute Overrides ------------------------------------------------- |
+ * | ------------------------------------------------------------------------- |
* | | | |
* | | OverridesComposite | |
* | | | |
* | ------------------------------------------------------------------------- |
* | |
- * | - Secondary Tables ------------------------------------------------------ |
+ * | - v Secondary Tables ---------------------------------------------------- |
* | ------------------------------------------------------------------------- |
* | | | |
* | | SecondaryTablesComposite | |
* | | | |
* | ------------------------------------------------------------------------- |
* | |
- * | - Inheritance ----------------------------------------------------------- |
+ * | - v Inheritance --------------------------------------------------------- |
+ * | ------------------------------------------------------------------------- |
* | | | |
* | | InheritanceComposite | |
* | | | |
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java
index d5c402131c..24a5b63df9 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratorComposite.java
@@ -144,9 +144,6 @@ public abstract class GeneratorComposite<T extends IGenerator> extends AbstractF
return text;
}
- protected void clear() {
- }
-
protected void clearNameViewer() {
this.nameText.setText("");
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java
index f6970d5aa6..9bbe104cf8 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java
@@ -9,14 +9,20 @@
******************************************************************************/
package org.eclipse.jpt.ui.internal.mappings.details;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.ListIterator;
import org.eclipse.jpt.core.internal.context.base.IJoinColumn;
import org.eclipse.jpt.core.internal.context.base.IJoinTable;
+import org.eclipse.jpt.db.internal.Schema;
+import org.eclipse.jpt.db.internal.Table;
import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.db.TableCombo;
import org.eclipse.jpt.ui.internal.mappings.details.JoinColumnsComposite.IJoinColumnsEditor;
import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
import org.eclipse.jpt.ui.internal.widgets.PostExecution;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.WritablePropertyValueModel;
@@ -229,6 +235,54 @@ public class JoinTableComposite extends AbstractFormPane<IJoinTable>
}
+ private TableCombo<IJoinTable> buildTableCombo(Composite container) {
+
+ return new TableCombo<IJoinTable>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(IJoinTable.DEFAULT_NAME_PROPERTY);
+ propertyNames.add(IJoinTable.SPECIFIED_NAME_PROPERTY);
+ }
+
+ @Override
+ protected String defaultValue() {
+ return subject().getDefaultName();
+ }
+
+ @Override
+ protected void setValue(String value) {
+ subject().setSpecifiedName(value);
+ }
+
+ @Override
+ protected Table table() {
+ return subject().dbTable();
+ }
+
+ private Schema tableSchema() {
+ return database().schemaNamed(subject().getSchema());
+ }
+
+ @Override
+ protected String value() {
+ return subject().getSpecifiedName();
+ }
+
+ @Override
+ protected Iterator<String> values() {
+ Schema schema = tableSchema();
+
+ if (schema != null) {
+ return schema.tableNames();
+ }
+
+ return EmptyIterator.instance();
+ }
+ };
+ }
+
private void editInverseJoinColumn(IJoinColumn joinColumn) {
InverseJoinColumnDialog dialog =
@@ -283,7 +337,7 @@ public class JoinTableComposite extends AbstractFormPane<IJoinTable>
int groupBoxMargin = groupBoxMargin();
// Name widgets
- TableCombo tableCombo = new TableCombo(this, container);
+ TableCombo<IJoinTable> tableCombo = buildTableCombo(container);
buildLabeledComposite(
buildPane(container, groupBoxMargin),
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedSuperclassComposite.java
index 426ae9e937..24ec4f562e 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedSuperclassComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedSuperclassComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved. This
+ * Copyright (c) 2005, 2008 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
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OverridesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OverridesComposite.java
index 441daa0032..6e11bd46ff 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OverridesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/OverridesComposite.java
@@ -47,24 +47,21 @@ import org.eclipse.ui.part.PageBook;
* Here the layout of this pane:
* <pre>
* -----------------------------------------------------------------------------
- * | --------------------------------------------------------------- |
- * | Name: | |v| |
- * | --------------------------------------------------------------- |
* | |
- * | x Override Default Join Columns |
- * | |
- * | ------------------------------------------------------------------------- |
+ * | - Attribute Overrides --------------------------------------------------- |
+ * | | --------------------------------------------------------------------- | |
+ * | | | | | |
+ * | | | | | |
+ * | | | | | |
+ * | | --------------------------------------------------------------------- | |
* | | | |
- * | | JoinColumnsComposite | |
- * | | | |
- * | ------------------------------------------------------------------------- |
- * | |
- * | x Override Default Inverse Join Columns |
- * | |
- * | ------------------------------------------------------------------------- |
- * | | | |
- * | | JoinColumnsComposite | |
+ * | | x Override Default | |
* | | | |
+ * | | --------------------------------------------------------------------- | |
+ * | | | | | |
+ * | | | JoinColumnsComposite | | |
+ * | | | | | |
+ * | | --------------------------------------------------------------------- | |
* | ------------------------------------------------------------------------- |
* -----------------------------------------------------------------------------</pre>
*
@@ -319,7 +316,7 @@ public class OverridesComposite extends AbstractFormPane<IEntity>
// Override Default check box
Button overrideDefaultButton = buildCheckBox(
- container,
+ container,
JptUiMappingsMessages.AttributeOverridesComposite_overrideDefault,
buildOverrideDefaultHolder()
);
@@ -329,14 +326,16 @@ public class OverridesComposite extends AbstractFormPane<IEntity>
);
// Override sub-pane
- PageBook overridePane = buildOverridePageBook(container);
+// PageBook overridePane = buildOverridePageBook(container);
// Join Columns widgets
Group joinColumnGroupPane = buildTitledPane(
- overridePane,
+ container,
JptUiMappingsMessages.OverridesComposite_joinColumn
);
+// overridePane.showPage(joinColumnGroupPane);
+
JoinColumnsComposite<IAssociationOverride> joinColumnsComposite =
new JoinColumnsComposite<IAssociationOverride>(
this,
@@ -349,10 +348,10 @@ public class OverridesComposite extends AbstractFormPane<IEntity>
new ColumnComposite(
this,
buildColumnHolder(),
- overridePane
+ joinColumnGroupPane
);
- overridePane.showPage(joinColumnsComposite.getControl());
+// overridePane.showPage(joinColumnsComposite.getControl());
}
private void overrideDefaultButtonSelected(boolean selected) {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsComposite.java
index acc1c87873..d307c8559f 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2008 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.
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java
index 4f0db36518..17266c904c 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2008 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.
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SchemaCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SchemaCombo.java
deleted file mode 100644
index be7b05ab65..0000000000
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SchemaCombo.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.ui.internal.mappings.details;
-
-import java.util.Iterator;
-import org.eclipse.jpt.core.internal.context.base.ITable;
-import org.eclipse.jpt.db.internal.ConnectionListener;
-import org.eclipse.jpt.db.internal.ConnectionProfile;
-import org.eclipse.jpt.db.internal.Database;
-import org.eclipse.jpt.db.internal.Schema;
-import org.eclipse.jpt.db.internal.Table;
-import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Composite;
-
-public class SchemaCombo extends AbstractFormPane<ITable>
-{
- /**
- * Caching the connectionProfile so we can remove the listener. If the
- * cached table object has been removed from the model then we no longer
- * have access to the parent and cannot find the connectionProfile
- */
- private ConnectionProfile connectionProfile;
-
- private ConnectionListener connectionListener;
-
- private CCombo combo;
-
- /**
- * Creates a new <code>SchemaCombo</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- */
- public SchemaCombo(AbstractFormPane<? extends ITable> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private ConnectionListener buildConnectionListener() {
- return new ConnectionListener() {
- public void aboutToClose(ConnectionProfile profile) {
- // not interested to this event.
- }
-
- public void closed(ConnectionProfile profile) {
- getCombo().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- SchemaCombo.this.populateShemaCombo();
- }
- });
- }
-
- public void modified(ConnectionProfile profile) {
- getCombo().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- SchemaCombo.this.populateShemaCombo();
- }
- });
- }
-
- public boolean okToClose(ConnectionProfile profile) {
- // not interested to this event.
- return true;
- }
-
- public void opened(ConnectionProfile profile) {
- getCombo().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- SchemaCombo.this.populateShemaCombo();
- }
- });
- }
-
- public void databaseChanged(ConnectionProfile profile, final Database database) {
- getControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (database == SchemaCombo.this.getDatabase()) {
- if (!getControl().isDisposed()) {
- SchemaCombo.this.populateShemaCombo();
- }
- }
- }
- });
- }
-
- public void schemaChanged(ConnectionProfile profile, final Schema schema) {
- getControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (schema == SchemaCombo.this.getTableSchema()) {
- if (!getControl().isDisposed()) {
- SchemaCombo.this.populateShemaCombo();
- }
- }
- }
- });
- }
-
- public void tableChanged(ConnectionProfile profile, final Table table) {
- // not interested to this event.
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- this.combo = buildCombo(container);
- this.combo.add(JptUiMappingsMessages.TableComposite_defaultEmpty);
- this.combo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String schemaText = ((CCombo) e.getSource()).getText();
- if (schemaText.equals("")) { //$NON-NLS-1$
- schemaText = null;
- if (SchemaCombo.this.subject().getSpecifiedSchema() == null || SchemaCombo.this.subject().getSpecifiedSchema().equals("")) { //$NON-NLS-1$
- return;
- }
- }
- if (schemaText != null && combo.getItemCount() > 0 && schemaText.equals(combo.getItem(0))) {
- schemaText = null;
- }
- if (SchemaCombo.this.subject().getSpecifiedSchema() == null && schemaText != null) {
- SchemaCombo.this.subject().setSpecifiedSchema(schemaText);
- }
- if (SchemaCombo.this.subject().getSpecifiedSchema() != null && !SchemaCombo.this.subject().getSpecifiedSchema().equals(schemaText)) {
- SchemaCombo.this.subject().setSpecifiedSchema(schemaText);
- }
- }
- });
- }
-
- @Override
- public void doPopulate() {
- super.doPopulate();
- if (this.subject() != null) {
- this.populateShemaCombo();
- }
- else {
- this.connectionProfile = null;
- }
- }
-
- protected Database getDatabase() {
- return this.getConnectionProfile().getDatabase();
- }
-
- private ConnectionProfile getConnectionProfile() {
- if (this.connectionProfile == null) {
- this.connectionProfile = this.subject().jpaProject().connectionProfile();
- }
- return this.connectionProfile;
- }
-
- private void populateShemaCombo() {
- if (this.subject() == null) {
- return;
- }
- this.populateDefaultSchemaName();
- if (this.getConnectionProfile().isConnected()) {
- this.combo.remove(1, this.combo.getItemCount() - 1);
- Database database = this.getDatabase();
- if (database != null) {
- Iterator<String> schemata = database.schemaNames();
- for (Iterator<String> stream = CollectionTools.sort(schemata); stream.hasNext();) {
- this.combo.add(stream.next());
- }
- }
- }
- else {
- this.combo.remove(1, this.combo.getItemCount() - 1);
- }
- this.populateSchemaName();
- }
-
- protected void populateDefaultSchemaName() {
- String defaultSchemaName = this.subject().getDefaultSchema();
- int selectionIndex = combo.getSelectionIndex();
- combo.setItem(0, NLS.bind(JptUiMappingsMessages.TableComposite_defaultWithOneParam, defaultSchemaName));
- if (selectionIndex == 0) {
- combo.clearSelection();
- combo.select(0);
- }
- }
-
- protected void populateSchemaName() {
- if (this.subject() == null) {
- return;
- }
- String schemaName = this.subject().getSpecifiedSchema();
- String defaultSchemaName = this.subject().getDefaultSchema();
- if (!StringTools.stringIsEmpty(schemaName)) {
- if (!this.combo.getText().equals(schemaName)) {
- this.combo.setText(schemaName);
- }
- }
- else {
- if (!this.combo.getText().equals(NLS.bind(JptUiMappingsMessages.TableComposite_defaultWithOneParam, defaultSchemaName))) {
- this.combo.select(0);
- }
- }
- }
-
- public CCombo getCombo() {
- return this.combo;
- }
-
- protected Schema getTableSchema() {
- return this.getConnectionProfile().getDatabase().schemaNamed(subject().getSchema());
- }
-
- @Override
- protected void disengageListeners() {
- super.disengageListeners();
-// if (this.subject() != null) {
-// this.removeConnectionListener();
-// this.subject().eAdapters().remove(this.listener);
-// }
- }
-
- @Override
- protected void engageListeners() {
- super.engageListeners();
-// if (this.subject() != null) {
-// this.subject().eAdapters().add(this.listener);
-// this.addConnectionListener();
-// }
- }
-
- private void addConnectionListener() {
- this.getConnectionProfile().addConnectionListener(this.connectionListener);
- }
-
- private void removeConnectionListener() {
- this.getConnectionProfile().removeConnectionListener(this.connectionListener);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SecondaryTablesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SecondaryTablesComposite.java
index 36289ab65a..7cf03aa774 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SecondaryTablesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SecondaryTablesComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2008 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.
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java
index 4804916fa7..64a8a83400 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/SequenceGeneratorComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2008 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.
@@ -9,21 +9,14 @@
******************************************************************************/
package org.eclipse.jpt.ui.internal.mappings.details;
+import org.eclipse.jpt.core.internal.IJpaNode;
import org.eclipse.jpt.core.internal.context.base.IIdMapping;
import org.eclipse.jpt.core.internal.context.base.ISequenceGenerator;
import org.eclipse.jpt.db.internal.Schema;
-import org.eclipse.jpt.db.internal.Table;
import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
-import org.eclipse.jpt.ui.internal.mappings.db.AbstractDatabaseObjectCombo;
-import org.eclipse.jpt.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.ui.internal.mappings.db.SequenceCombo;
import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.internal.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
@@ -35,22 +28,20 @@ import org.eclipse.swt.widgets.Text;
* | Name: | I | |
* | ----------------------------------------------------- |
* | ----------------------------------------------------- |
- * | Sequence Generator: | I |v| |
+ * | Sequence Generator: | SequenceCombo | |
* | ----------------------------------------------------- |
* -----------------------------------------------------------------------------</pre>
*
* @see IIdMapping
* @see ISequenceGenerator
* @see GenerationComposite - The parent container
+ * @see SequenceCombo
*
* @version 2.0
* @since 1.0
*/
public class SequenceGeneratorComposite extends GeneratorComposite<ISequenceGenerator>
{
- private AbstractDatabaseObjectCombo<IIdMapping> sequenceNameCombo;
- private PropertyChangeListener sequenceNamePropertyChangeListener;
-
/**
* Creates a new <code>SequenceGeneratorComposite</code>.
*
@@ -71,97 +62,55 @@ public class SequenceGeneratorComposite extends GeneratorComposite<ISequenceGene
return subject().addSequenceGenerator();
}
- private AbstractDatabaseObjectCombo<IIdMapping> buildSequenceNameCombo(Composite parent) {
- return new AbstractDatabaseObjectCombo<IIdMapping>(this, parent) {
- @Override
- protected void initializeLayout(Composite container) {
- super.initializeLayout(container);
- getCombo().add(JptUiMappingsMessages.SequenceGeneratorComposite_default);
- getCombo().addModifyListener(buildSequenceNameListener());
- }
+ private SequenceCombo<IJpaNode> buildSequenceNameCombo(Composite parent) {
- @Override
- protected void schemaChanged(Schema schema) {
- }
+ return new SequenceCombo<IJpaNode>(this, parent) {
@Override
- protected void setValue(String value) {
- // TODO
+ protected String defaultValue() {
+ return JptUiMappingsMessages.SequenceGeneratorComposite_default;
}
@Override
- protected void tableChanged(Table table) {
+ protected Schema schema() {
+ return null;
+ // TODO
+// return database().schemaNamed(subject().jpaProject().getSchemaName());
}
@Override
- protected String value() {
- return ""; // TODO
- }
- };
- }
-
- private ModifyListener buildSequenceNameListener() {
- return new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (isPopulating()) {
- return;
- }
-
- String text = ((CCombo) e.getSource()).getText();
-
- if (text != null && getSequenceCombo().getItemCount() > 0 && text.equals(getSequenceCombo().getItem(0))) {
- text = null;
- }
-
+ protected void setValue(String value) {
ISequenceGenerator generator = getGenerator();
if (generator == null) {
generator = buildGenerator();
}
- generator.setSpecifiedSequenceName(text);
+ generator.setSpecifiedSequenceName(value);
}
- };
- }
- private PropertyChangeListener buildSequenceNamePropertyChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- if (isPopulating()) {
- return;
+ @Override
+ protected IJpaNode subject() {
+ IJpaNode subject = super.subject();
+
+ if (subject == null) {
+ subject = SequenceGeneratorComposite.this.subject();
}
- SWTUtil.asyncExec(new Runnable() {
- public void run() {
- setPopulating(true);
- try {
- SequenceGeneratorComposite.this.populateSequenceNameCombo();
- }
- finally {
- setPopulating(false);
- }
- }
- });
+ return subject;
}
- };
- }
- /*
- * (non-Javadoc)
- */
- @Override
- protected void clear() {
- super.clear();
- this.getSequenceCombo().select(0);
- }
+ @Override
+ protected String value() {
+ ISequenceGenerator generator = getGenerator();
- /*
- * (non-Javadoc)
- */
- @Override
- protected void doPopulate() {
- super.doPopulate();
- this.populateSequenceNameCombo();
+ if (generator != null) {
+ return generator.getSpecifiedSequenceName();
+ }
+
+ return null;
+ }
+ };
}
/*
@@ -172,20 +121,6 @@ public class SequenceGeneratorComposite extends GeneratorComposite<ISequenceGene
return (subject() != null) ? subject().getSequenceGenerator() : null;
}
- private CCombo getSequenceCombo() {
- return this.sequenceNameCombo.getCombo();
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initialize() {
- super.initialize();
-
- sequenceNamePropertyChangeListener = buildSequenceNamePropertyChangeListener();
- }
-
/*
* (non-Javadoc)
*/
@@ -193,10 +128,10 @@ public class SequenceGeneratorComposite extends GeneratorComposite<ISequenceGene
protected void initializeLayout(Composite container) {
// Name widgets
- Text nameText = this.buildNameText(shell());
- this.setNameText(nameText);
+ Text nameText = buildNameText(shell());
+ setNameText(nameText);
- this.buildLabeledComposite(
+ buildLabeledComposite(
container,
JptUiMappingsMessages.SequenceGeneratorComposite_name,
nameText,
@@ -204,12 +139,13 @@ public class SequenceGeneratorComposite extends GeneratorComposite<ISequenceGene
);
// Sequence Generator widgets
- this.sequenceNameCombo = this.buildSequenceNameCombo(shell());
+ SequenceCombo<IJpaNode> sequenceNameCombo =
+ buildSequenceNameCombo(container);
- this.buildLabeledComposite(
+ buildLabeledComposite(
container,
JptUiMappingsMessages.SequenceGeneratorComposite_sequence,
- this.sequenceNameCombo.getCombo().getParent(),
+ sequenceNameCombo.getCombo().getParent(),
IJpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_SEQUENCE
);
}
@@ -218,58 +154,7 @@ public class SequenceGeneratorComposite extends GeneratorComposite<ISequenceGene
* (non-Javadoc)
*/
@Override
- protected void installListeners(ISequenceGenerator generator) {
- super.installListeners(generator);
-
- if (generator != null) {
- generator.addPropertyChangeListener(PropertyValueModel.VALUE, sequenceNamePropertyChangeListener);;
- }
- }
-
- private void populateSequenceNameCombo() {
-
- this.getSequenceCombo().removeAll();//(1, this.getSequenceCombo().getItemCount());
-
-// if (this.getConnectionProfile().isConnected()) {
-// this.sequenceNameCombo.remove(1, this.sequenceNameCombo.getItemCount() - 1);
-// Schema schema = getConnectionProfile().getDatabase().schemaNamed(getGenerator().getJpaProject().getSchemaName());
-// if (schema != null) {
-// for (Iterator stream = CollectionTools.sort(schema.sequenceNames()); stream.hasNext();) {
-// this.sequenceNameCombo.add((String) stream.next());
-// }
-// }
-// }
- if (this.getGenerator() != null) {
- String sequenceName = this.getGenerator().getSpecifiedSequenceName();
-
- if (sequenceName != null) {
- if (!this.getSequenceCombo().getText().equals(sequenceName)) {
- this.getSequenceCombo().setText(sequenceName);
- }
- }
- else {
- this.getSequenceCombo().select(0);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
protected String propertyName() {
return IIdMapping.SEQUENCE_GENERATOR_PROPERTY;
}
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void uninstallListeners(ISequenceGenerator generator) {
- super.uninstallListeners(generator);
-
- if (generator != null) {
- generator.removePropertyChangeListener(PropertyValueModel.VALUE, sequenceNamePropertyChangeListener);;
- }
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableCombo.java
deleted file mode 100644
index 80df4c3afe..0000000000
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableCombo.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Oracle. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.ui.internal.mappings.details;
-
-import java.util.Iterator;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.jpt.core.internal.context.base.ITable;
-import org.eclipse.jpt.db.internal.ConnectionListener;
-import org.eclipse.jpt.db.internal.ConnectionProfile;
-import org.eclipse.jpt.db.internal.Database;
-import org.eclipse.jpt.db.internal.Schema;
-import org.eclipse.jpt.db.internal.Table;
-import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
-import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Composite;
-
-public class TableCombo extends AbstractFormPane<ITable>
-{
- private Adapter listener;
-
- /**
- * Caching the connectionProfile so we can remove the listener. If the
- * cached table object has been removed from the model then we no longer
- * have access to parent and cannot find the connectionProfile
- */
- private ConnectionProfile connectionProfile;
-
- private ConnectionListener connectionListener;
-
- private CCombo combo;
-
- public TableCombo(PropertyValueModel<? extends ITable> subjectHolder,
- Composite parent,
- IWidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- public TableCombo(AbstractFormPane<? extends ITable> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- private ConnectionListener buildConnectionListener() {
- return new ConnectionListener() {
- public void aboutToClose(ConnectionProfile profile) {
- // not interested to this event.
- }
-
- public void closed(ConnectionProfile profile) {
- getCombo().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- TableCombo.this.populateTableCombo();
- }
- });
- }
-
- public void modified(ConnectionProfile profile) {
- getCombo().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- TableCombo.this.populateTableCombo();
- }
- });
- }
-
- public boolean okToClose(ConnectionProfile profile) {
- // not interested to this event.
- return true;
- }
-
- public void opened(ConnectionProfile profile) {
- getCombo().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- TableCombo.this.populateTableCombo();
- }
- });
- }
-
- public void databaseChanged(ConnectionProfile profile, final Database database) {
- getControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (database == TableCombo.this.getDatabase()) {
- if (!getControl().isDisposed()) {
- TableCombo.this.populateTableCombo();
- }
- }
- }
- });
- }
-
- public void schemaChanged(ConnectionProfile profile, final Schema schema) {
- getControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (schema == TableCombo.this.getTableSchema()) {
- if (!getControl().isDisposed()) {
- TableCombo.this.populateTableCombo();
- }
- }
- }
- });
- }
-
- public void tableChanged(ConnectionProfile profile, final Table table) {
- // not interested to this event.
- }
- };
- }
-
- @Override
- protected void initializeLayout(Composite container) {
- this.combo = buildCombo(container);
- this.combo.add(JptUiMappingsMessages.TableComposite_defaultEmpty);
- this.combo.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- String tableText = ((CCombo) e.getSource()).getText();
- if (tableText.equals("")) { //$NON-NLS-1$
- tableText = null;
- if (subject().getSpecifiedName() == null || subject().getSpecifiedName().equals("")) { //$NON-NLS-1$
- return;
- }
- }
- if (tableText != null && combo.getItemCount() > 0 && tableText.equals(combo.getItem(0))) {
- tableText = null;
- }
- if (subject().getSpecifiedName() == null && tableText != null) {
- subject().setSpecifiedName(tableText);
- }
- if (subject().getSpecifiedName() != null && !subject().getSpecifiedName().equals(tableText)) {
- subject().setSpecifiedName(tableText);
- }
- }
- });
- }
-
- @Override
- public void doPopulate() {
- if (this.subject() != null) {
- populateTableCombo();
- }
- else {
- this.connectionProfile = null;
- }
- }
-
- protected Database getDatabase() {
- return getConnectionProfile().getDatabase();
- }
-
- protected Schema getTableSchema() {
- return getConnectionProfile().getDatabase().schemaNamed(subject().getSchema());
- }
-
- private ConnectionProfile getConnectionProfile() {
- if (this.connectionProfile == null) {
- this.connectionProfile = this.subject().jpaProject().connectionProfile();
- }
- return this.connectionProfile;
- }
-
- private void populateTableCombo() {
- if (this.subject() == null) {
- return;
- }
- // TODO don't do instanceof check here - check on Table, or isRoot check
- // on Entity
- // this.tableCombo.setEnabled(!(this.table instanceof
- // SingleTableInheritanceChildTableImpl));
- populateDefaultTableName();
- if (getConnectionProfile().isConnected()) {
- this.combo.remove(1, this.combo.getItemCount() - 1);
- Schema schema = this.getTableSchema();
- if (schema != null) {
- Iterator<String> tables = schema.tableNames();
- for (Iterator<String> stream = CollectionTools.sort(tables); stream.hasNext();) {
- this.combo.add(stream.next());
- }
- }
- }
- else {
- this.combo.remove(1, this.combo.getItemCount() - 1);
- }
- populateTableName();
- }
-
- protected void populateDefaultTableName() {
- if (this.subject() == null) {
- return;
- }
- String defaultTableName = subject().getDefaultName();
- int selectionIndex = combo.getSelectionIndex();
- combo.setItem(0, NLS.bind(JptUiMappingsMessages.TableComposite_defaultWithOneParam, defaultTableName));
- if (selectionIndex == 0) {
- // combo text does not update when switching between 2 mappings of
- // the same type
- // that both have a default column name. clear the selection and
- // then set it again
- combo.clearSelection();
- combo.select(0);
- }
- }
-
- protected void populateTableName() {
- if (this.subject() == null) {
- return;
- }
- String tableName = this.subject().getSpecifiedName();
- String defaultTableName = this.subject().getDefaultName();
- if (tableName != null) {
- if (!this.combo.getText().equals(tableName)) {
- this.combo.setText(tableName);
- }
- }
- else {
- if (!this.combo.getText().equals(NLS.bind(JptUiMappingsMessages.TableComposite_defaultWithOneParam, defaultTableName))) {
- this.combo.select(0);
- }
- }
- }
-
- public CCombo getCombo() {
- return this.combo;
- }
-
- @Override
- protected void disengageListeners() {
- if (this.subject() != null) {
- this.removeConnectionListener();
-// this.subject().eAdapters().remove(this.listener);
- }
- }
-
- @Override
- protected void engageListeners() {
- if (this.subject() != null) {
-// this.subject().eAdapters().add(this.listener);
- this.addConnectionListener();
- }
- }
-
- private void addConnectionListener() {
- this.getConnectionProfile().addConnectionListener(this.connectionListener);
- }
-
- private void removeConnectionListener() {
- this.getConnectionProfile().removeConnectionListener(this.connectionListener);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableComposite.java
index da24fb0cc6..0718203988 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableComposite.java
@@ -8,10 +8,18 @@
******************************************************************************/
package org.eclipse.jpt.ui.internal.mappings.details;
+import java.util.Collection;
+import java.util.Iterator;
import org.eclipse.jpt.core.internal.context.base.ITable;
+import org.eclipse.jpt.db.internal.Schema;
+import org.eclipse.jpt.db.internal.Table;
import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.mappings.db.CatalogCombo;
+import org.eclipse.jpt.ui.internal.mappings.db.SchemaCombo;
+import org.eclipse.jpt.ui.internal.mappings.db.TableCombo;
import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
@@ -20,15 +28,18 @@ import org.eclipse.swt.widgets.Group;
* Here the layout of this pane:
* <pre>
* -----------------------------------------------------------------------------
- * | ---------------------------------------------------------------- |
- * | Table: | TableCombo | |
- * | ---------------------------------------------------------------- |
- * | ---------------------------------------------------------------- |
- * | Catalog: | CatalogCombo | |
- * | ---------------------------------------------------------------- |
- * | ---------------------------------------------------------------- |
- * | Schema: | SchemaCombo | |
- * | ---------------------------------------------------------------- |
+ * | |
+ * | - Table ----------------------------------------------------------------- |
+ * | | ------------------------------------------------------------ | |
+ * | | Table: | TableCombo | | |
+ * | | ------------------------------------------------------------ | |
+ * | | ------------------------------------------------------------ | |
+ * | | Catalog: | CatalogCombo | | |
+ * | | ------------------------------------------------------------ | |
+ * | | ------------------------------------------------------------ | |
+ * | | Schema: | SchemaCombo | | |
+ * | | ------------------------------------------------------------ | |
+ * | ------------------------------------------------------------------------- |
* -----------------------------------------------------------------------------</pre>
*
* @see IBasicMapping
@@ -47,6 +58,20 @@ public class TableComposite extends AbstractFormPane<ITable>
/**
* Creates a new <code>TableComposite</code>.
*
+ * @param parentPane The parent container of this one
+ * @param subjectHolder The holder of the subject
+ * @param parent The parent container
+ */
+ public TableComposite(AbstractFormPane<?> parentPane,
+ PropertyValueModel<? extends ITable> subjectHolder,
+ Composite parent) {
+
+ super(parentPane, subjectHolder, parent);
+ }
+
+ /**
+ * Creates a new <code>TableComposite</code>.
+ *
* @param subjectHolder The holder of the subject <code>ITable</code>
* @param parent The parent container
* @param widgetFactory The factory used to create various common widgets
@@ -58,18 +83,108 @@ public class TableComposite extends AbstractFormPane<ITable>
super(subjectHolder, parent, widgetFactory);
}
- /**
- * Creates a new <code>TableComposite</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of the subject
- * @param parent The parent container
- */
- public TableComposite(AbstractFormPane<?> parentPane,
- PropertyValueModel<? extends ITable> subjectHolder,
- Composite parent) {
+ private CatalogCombo<ITable> buildCatalogCombo(Composite container) {
- super(parentPane, subjectHolder, parent);
+ return new CatalogCombo<ITable>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(ITable.DEFAULT_CATALOG_PROPERTY);
+ propertyNames.add(ITable.SPECIFIED_CATALOG_PROPERTY);
+ }
+
+ @Override
+ protected String defaultValue() {
+ return subject().getDefaultCatalog();
+ }
+
+ @Override
+ protected void setValue(String value) {
+ subject().setSpecifiedCatalog(value);
+ }
+
+ @Override
+ protected String value() {
+ return subject().getSpecifiedCatalog();
+ }
+ };
+ }
+
+ private SchemaCombo<ITable> buildSchemaCombo(Composite container) {
+
+ return new SchemaCombo<ITable>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(ITable.DEFAULT_SCHEMA_PROPERTY);
+ propertyNames.add(ITable.SPECIFIED_SCHEMA_PROPERTY);
+ }
+
+ @Override
+ protected String defaultValue() {
+ return subject().getDefaultSchema();
+ }
+
+ @Override
+ protected void setValue(String value) {
+ subject().setSpecifiedSchema(value);
+ }
+
+ @Override
+ protected String value() {
+ return subject().getSpecifiedSchema();
+ }
+ };
+ }
+
+ private TableCombo<ITable> buildTableCombo(Composite container) {
+
+ return new TableCombo<ITable>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(ITable.DEFAULT_NAME_PROPERTY);
+ propertyNames.add(ITable.SPECIFIED_NAME_PROPERTY);
+ }
+
+ @Override
+ protected String defaultValue() {
+ return subject().getDefaultName();
+ }
+
+ @Override
+ protected void setValue(String value) {
+ subject().setSpecifiedName(value);
+ }
+
+ @Override
+ protected Table table() {
+ return subject().dbTable();
+ }
+
+ private Schema tableSchema() {
+ return database().schemaNamed(subject().getSchema());
+ }
+
+ @Override
+ protected String value() {
+ return subject().getSpecifiedName();
+ }
+
+ @Override
+ protected Iterator<String> values() {
+ Schema schema = tableSchema();
+
+ if (schema != null) {
+ return schema.tableNames();
+ }
+
+ return EmptyIterator.instance();
+ }
+ };
}
/*
@@ -78,36 +193,37 @@ public class TableComposite extends AbstractFormPane<ITable>
@Override
protected void initializeLayout(Composite container) {
- Group columnGroup = buildTitledPane(
+ // Table group pane
+ Group tableGroupPane = buildTitledPane(
container,
JptUiMappingsMessages.TableComposite_tableSection
);
// Table widgets
- TableCombo tableCombo = new TableCombo(this, columnGroup);
+ TableCombo<ITable> tableCombo = buildTableCombo(tableGroupPane);
buildLabeledComposite(
- columnGroup,
+ tableGroupPane,
JptUiMappingsMessages.TableChooser_label,
tableCombo.getControl(),
IJpaHelpContextIds.ENTITY_TABLE
);
// Catalog widgets
- CatalogCombo catalogCombo = new CatalogCombo(this, columnGroup);
+ CatalogCombo<ITable> catalogCombo = buildCatalogCombo(tableGroupPane);
buildLabeledComposite(
- columnGroup,
+ tableGroupPane,
JptUiMappingsMessages.CatalogChooser_label,
catalogCombo.getControl(),
IJpaHelpContextIds.ENTITY_CATALOG
);
// Schema widgets
- SchemaCombo schemaCombo = new SchemaCombo(this, columnGroup);
+ SchemaCombo<ITable> schemaCombo = buildSchemaCombo(tableGroupPane);
buildLabeledComposite(
- columnGroup,
+ tableGroupPane,
JptUiMappingsMessages.SchemaChooser_label,
schemaCombo.getControl(),
IJpaHelpContextIds.ENTITY_SCHEMA
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java
index 6c06b5b7f2..36eb275a23 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/TableGeneratorComposite.java
@@ -11,11 +11,7 @@ package org.eclipse.jpt.ui.internal.mappings.details;
import org.eclipse.jpt.core.internal.context.base.IIdMapping;
import org.eclipse.jpt.core.internal.context.base.ITableGenerator;
-import org.eclipse.jpt.db.internal.ConnectionListener;
-import org.eclipse.jpt.db.internal.ConnectionProfile;
-import org.eclipse.jpt.db.internal.Database;
import org.eclipse.jpt.db.internal.Schema;
-import org.eclipse.jpt.db.internal.Table;
import org.eclipse.jpt.ui.internal.IJpaHelpContextIds;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.widgets.AbstractFormPane;
@@ -72,56 +68,6 @@ public class TableGeneratorComposite extends GeneratorComposite<ITableGenerator>
super(parentPane, parent);
}
- private ConnectionListener buildConnectionListener() {
- return new ConnectionListener() {
- public void aboutToClose(ConnectionProfile profile) {
- // not interested to this event.
- }
-
- public void closed(ConnectionProfile profile) {
- populate();
- }
-
- public void databaseChanged(ConnectionProfile profile, final Database database) {
- populate();
- }
-
- public void modified(ConnectionProfile profile) {
- populate();
- }
-
- public boolean okToClose(ConnectionProfile profile) {
- // not interested to this event.
- return true;
- }
-
- public void opened(ConnectionProfile profile) {
- populate();
- }
-
- private void populate() {
- getControl().getDisplay().asyncExec( new Runnable() {
- public void run() {
- if (getControl().isDisposed()) {
- return;
- }
- populateTableNameCombo();
- populatePkColumnChoices();
- populateValueColumnNameCombo();
- }
- });
- }
-
- public void schemaChanged(ConnectionProfile profile, final Schema schema) {
- populate();
- }
-
- public void tableChanged(ConnectionProfile profile, final Table table) {
- // not interested to this event.
- }
- };
- }
-
/*
* (non-Javadoc)
*/
@@ -230,18 +176,6 @@ public class TableGeneratorComposite extends GeneratorComposite<ITableGenerator>
* (non-Javadoc)
*/
@Override
- protected void clear() {
- super.clear();
- this.tableNameCombo.select(0);
- this.pkColumnNameCombo.select(0);
- this.pkColumnValueCombo.select(0);
- this.valueColumnNameCombo.select(0);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
protected void disengageListeners() {
super.disengageListeners();
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/IJpaSelection.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/IJpaSelection.java
index fff369e7e6..3c0770a964 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/IJpaSelection.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/IJpaSelection.java
@@ -1,11 +1,11 @@
/*******************************************************************************
- * Copyright (c) 2007 Oracle.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
+ * Copyright (c) 2007 Oracle.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* Oracle - initial API and implementation
*******************************************************************************/
package org.eclipse.jpt.ui.internal.selection;
@@ -13,24 +13,25 @@ package org.eclipse.jpt.ui.internal.selection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jpt.core.internal.context.base.IJpaContextNode;
+@SuppressWarnings("nls")
public interface IJpaSelection extends ISelection
{
- static IJpaSelection NULL_SELECTION =
+ static IJpaSelection NULL_SELECTION =
new IJpaSelection() {
public IJpaContextNode getSelectedNode() {
return null;
}
-
+
public boolean isEmpty() {
return true;
}
-
+
@Override
public String toString() {
return "NULL SELECTION";
}
};
-
-
+
+
IJpaContextNode getSelectedNode();
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/JpaSelection.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/JpaSelection.java
index a58e113589..a4e12ea25c 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/JpaSelection.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/selection/JpaSelection.java
@@ -3,7 +3,7 @@
* 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
******************************************************************************/
@@ -11,39 +11,39 @@ package org.eclipse.jpt.ui.internal.selection;
import org.eclipse.jpt.core.internal.context.base.IJpaContextNode;
-
+@SuppressWarnings("nls")
public class JpaSelection
implements IJpaSelection
{
private IJpaContextNode selectedNode;
-
-
+
+
public JpaSelection(IJpaContextNode selectedNode) {
if (selectedNode == null) {
throw new NullPointerException("A 'selectedNode' is required; otherwise use NULL_SELECTION.");
}
this.selectedNode = selectedNode;
}
-
+
public IJpaContextNode getSelectedNode() {
return selectedNode;
}
-
+
public boolean isEmpty() {
// by definition, this selection is never empty
// use IJpaSelection.NULL_SELECTION for empty selections
return false;
}
-
+
@Override
public boolean equals(Object obj) {
if (! (obj instanceof JpaSelection)) {
return false;
}
-
+
return this.selectedNode.equals(((JpaSelection) obj).selectedNode);
}
-
+
@Override
public int hashCode() {
return this.selectedNode.hashCode();
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/LabeledTableItem.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/LabeledTableItem.java
index 7e8ce6843e..352dd4aa94 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/LabeledTableItem.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/util/LabeledTableItem.java
@@ -25,7 +25,7 @@ import org.eclipse.swt.widgets.TableItem;
public final class LabeledTableItem implements LabeledControl
{
/**
- * The label to be updated with a different icon and text.
+ * The table cell to be updated with a different icon and text.
*/
private TableItem tableItem;
@@ -37,6 +37,7 @@ public final class LabeledTableItem implements LabeledControl
*/
public LabeledTableItem(TableItem tableItem) {
super();
+
Assert.isNotNull(tableItem, "The TableItem cannot be null");
this.tableItem = tableItem;
}
@@ -46,6 +47,10 @@ public final class LabeledTableItem implements LabeledControl
*/
public void setIcon(final Image image) {
+ if (tableItem.isDisposed()) {
+ return;
+ }
+
SWTUtil.asyncExec(new Runnable() {
public void run() {
updateTableItem(tableItem.getText(), image);
@@ -58,6 +63,10 @@ public final class LabeledTableItem implements LabeledControl
*/
public void setText(final String text) {
+ if (tableItem.isDisposed()) {
+ return;
+ }
+
SWTUtil.asyncExec(new Runnable() {
public void run() {
updateTableItem(text, tableItem.getImage());
@@ -67,8 +76,16 @@ public final class LabeledTableItem implements LabeledControl
private void updateTableItem(String text, Image image) {
+ if (text == null) {
+ text = "";
+ }
+
Table table = tableItem.getParent();
- table.getParent().setRedraw(false);
+ table.setRedraw(false);
+
+ boolean checked = tableItem.getChecked();
+ boolean grayed = tableItem.getGrayed();
+ boolean hasFocus = table.isFocusControl();
int index = table.indexOf(tableItem);
table.remove(index);
@@ -76,8 +93,15 @@ public final class LabeledTableItem implements LabeledControl
tableItem = new TableItem(table, SWT.CHECK, index);
tableItem.setText(text);
tableItem.setImage(image);
+ tableItem.setChecked(checked);
+ tableItem.setGrayed(grayed);
+
+ table.layout(true, true);
+ table.getParent().getParent().layout(true, true);
+ table.setRedraw(true);
- table.getParent().pack(true);
- table.getParent().setRedraw(true);
+ if (hasFocus) {
+ table.forceFocus();
+ }
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AbstractPane.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AbstractPane.java
index dd821f6c65..4a8d3aab27 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AbstractPane.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/AbstractPane.java
@@ -109,7 +109,7 @@ public abstract class AbstractPane<T extends Model>
private PropertyChangeListener subjectChangeListener;
/**
- * The subject of this controller.
+ * The subject of this pane.
*/
private PropertyValueModel<T> subjectHolder;
@@ -138,7 +138,7 @@ public abstract class AbstractPane<T extends Model>
/**
* Creates a new <code>AbstractSubjectPane</code>.
*
- * @param parentPane The parent controller of this one
+ * @param parentPane The parent pane of this one
* @param parent The parent container
*
* @category Constructor
@@ -156,7 +156,7 @@ public abstract class AbstractPane<T extends Model>
* @param parent The parent container
* @param widgetFactory The factory used to create various widgets
* @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent controller;
+ * this pane aligned with the widgets of the given parent pane;
* <code>false</code> to not align them
*
* @category Constructor
@@ -195,7 +195,7 @@ public abstract class AbstractPane<T extends Model>
* @param parent The parent container
* @param widgetFactory The factory used to create various widgets
* @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent controller;
+ * this pane aligned with the widgets of the given parent pane;
* <code>false</code> to not align them
*
* @category Constructor
@@ -241,12 +241,12 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Adds the given controller's widgets (those that were registered with its
- * left <code>ControlAligner</code>) to this controller's left
+ * Adds the given pane's widgets (those that were registered with its
+ * left <code>ControlAligner</code>) to this pane's left
* <code>ControlAligner</code> so that their width can be adjusted to have
* the width of the widest widget.
*
- * @param controller The controller containing the widgets to add
+ * @param pane The pane containing the widgets to add
*
* @category Layout
*/
@@ -259,7 +259,7 @@ public abstract class AbstractPane<T extends Model>
* adjust with the width of the widest widget. The left alignment is usually
* used for labels.
*
- * @param controller The controller to add
+ * @param pane The pane to add
*
* @category Layout
*/
@@ -268,12 +268,12 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Adds the given controller's widgets (those that were registered with its
- * right <code>ControlAligner</code>) to this controller's right
+ * Adds the given pane's widgets (those that were registered with its
+ * right <code>ControlAligner</code>) to this pane's right
* <code>ControlAligner</code> so that their width can be adjusted to have
* the width of the widest widget.
*
- * @param controller The controller containing the widgets to add
+ * @param pane The pane containing the widgets to add
*
* @category Layout
*/
@@ -286,7 +286,7 @@ public abstract class AbstractPane<T extends Model>
* adjust with the width of the widest widget. The left alignment is usually
* used for buttons.
*
- * @param controller The controller to add
+ * @param pane The pane to add
*
* @category Layout
*/
@@ -295,10 +295,10 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Adds the given controller's controls (those that were registered for
- * alignment) from this controller.
+ * Adds the given pane's controls (those that were registered for
+ * alignment) from this pane.
*
- * @param controller The controller containing the widgets to add for
+ * @param pane The pane containing the widgets to add for
* alignment
*
* @category Layout
@@ -322,7 +322,7 @@ public abstract class AbstractPane<T extends Model>
return new PropertyChangeListener() {
public void propertyChanged(PropertyChangeEvent e) {
- if (getControl().isDisposed()) {
+ if (container.isDisposed()) {
return;
}
@@ -1540,7 +1540,7 @@ public abstract class AbstractPane<T extends Model>
/**
* Uninstalls any listeners from the subject in order to stop being notified
- * for changes made outside of this controllers.
+ * for changes made outside of this panes.
*
* @category Populate
*/
@@ -1578,23 +1578,29 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Notifies this controller is should dispose itself.
+ * Notifies this pane is should dispose itself.
*
* @category Populate
*/
- public void dispose() {
- if (!this.getControl().isDisposed()) {
+ public final void dispose() {
+ if (!container.isDisposed()) {
this.log("dispose()");
+ this.performDispose();
this.disengageListeners();
-
- for (AbstractPane<?> subPane : this.subPanes) {
- subPane.dispose();
- }
}
}
/**
- * Requests this controller to populate its widgets with the subject's values.
+ * Requests this pane to dispose itself.
+ *
+ * @category Populate
+ */
+ protected void doDispose() {
+ this.log(" ->doDispose()");
+ }
+
+ /**
+ * Requests this pane to populate its widgets with the subject's values.
*
* @category Populate
*/
@@ -1618,7 +1624,7 @@ public abstract class AbstractPane<T extends Model>
/**
* Installs the listeners on the subject in order to be notified from changes
- * made outside of this controllers.
+ * made outside of this panes.
*
* @category Populate
*/
@@ -1681,7 +1687,7 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Returns the subject holder used by this controller.
+ * Returns the subject holder used by this pane.
*
* @return The holder of the subject
*
@@ -1739,11 +1745,11 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Registers this controller with the parent controller.
+ * Registers this pane with the parent pane.
*
- * @param parentPane The parent controller
+ * @param parentPane The parent pane
* @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent controller;
+ * this pane aligned with the widgets of the given parent pane;
* <code>false</code> to not align them
*
* @category Initialization
@@ -1757,7 +1763,7 @@ public abstract class AbstractPane<T extends Model>
parentPane.registerSubPane(this);
// Align the left and right controls with the controls from the parent
- // controller
+ // pane
if (automaticallyAlignWidgets) {
parentPane.leftControlAligner .add(leftControlAligner);
parentPane.rightControlAligner.add(rightControlAligner);
@@ -1767,7 +1773,7 @@ public abstract class AbstractPane<T extends Model>
/**
* Initializes this <code>AbstractSubjectPane</code>.
*
- * @param subjectHolder The holder of this controller's subject
+ * @param subjectHolder The holder of this pane's subject
* @param widgetFactory The factory used to create various widgets
*
* @category Initialization
@@ -1816,7 +1822,7 @@ public abstract class AbstractPane<T extends Model>
*/
private void log(String message) {
- if (Tracing.booleanDebugOption(Tracing.DEBUG_LAYOUT)) {
+ if (Tracing.booleanDebugOption(Tracing.UI_LAYOUT)) {
Class<?> thisClass = getClass();
String className = ClassTools.shortNameFor(thisClass);
@@ -1831,12 +1837,29 @@ public abstract class AbstractPane<T extends Model>
}
/**
+ * Notifies this pane is should dispose itself.
+ *
+ * @category Populate
+ */
+ protected void performDispose() {
+ this.log(" ->performDispose()");
+
+ // Dispose this pane
+ doDispose();
+
+ // Ask the sub-panes to perform the dispose themselves
+ for (AbstractPane<?> subPane : this.subPanes) {
+ subPane.performDispose();
+ }
+ }
+
+ /**
* Notifies this pane to populate itself using the subject's information.
*
* @category Populate
*/
public final void populate() {
- if (!getControl().isDisposed()) {
+ if (!container.isDisposed()) {
this.log("populate()");
this.repopulate();
this.engageListeners();
@@ -1882,17 +1905,17 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Removes the given controller's widgets (those that were registered with
- * its left <code>ControlAligner</code>) from this controller's left
+ * Removes the given pane's widgets (those that were registered with
+ * its left <code>ControlAligner</code>) from this pane's left
* <code>ControlAligner</code> so that their width will no longer be adjusted
* with the width of the widest widget.
*
- * @param controller The controller containing the widgets to remove
+ * @param pane The pane containing the widgets to remove
*
* @category Layout
*/
- protected final void removeAlignLeft(AbstractPane<?> controller) {
- leftControlAligner.remove(controller.leftControlAligner);
+ protected final void removeAlignLeft(AbstractPane<?> pane) {
+ leftControlAligner.remove(pane.leftControlAligner);
}
/**
@@ -1900,7 +1923,7 @@ public abstract class AbstractPane<T extends Model>
* to have the same width when they are shown to the left side of the 3
* widget colums.
*
- * @param controller The controller to remove, its width will no longer be
+ * @param pane The pane to remove, its width will no longer be
* ajusted to be the width of the longest widget
*
* @category Layout
@@ -1910,17 +1933,17 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Removes the given controller's widgets (those that were registered with
- * its right <code>ControlAligner</code>) from this controller's right
+ * Removes the given pane's widgets (those that were registered with
+ * its right <code>ControlAligner</code>) from this pane's right
* <code>ControlAligner</code> so that their width will no longer be adjusted
* with the width of the widest widget.
*
- * @param controller The controller containing the widgets to remove
+ * @param pane The pane containing the widgets to remove
*
* @category Layout
*/
- protected final void removeAlignRight(AbstractPane<?> controller) {
- rightControlAligner.remove(controller.rightControlAligner);
+ protected final void removeAlignRight(AbstractPane<?> pane) {
+ rightControlAligner.remove(pane.rightControlAligner);
}
/**
@@ -1928,7 +1951,7 @@ public abstract class AbstractPane<T extends Model>
* to have the same width when they are shown to the right side of the 3
* widget colums.
*
- * @param controller The controller to remove, its width will no longer be
+ * @param pane The pane to remove, its width will no longer be
* ajusted to be the width of the longest widget
*
* @category Layout
@@ -1938,17 +1961,17 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Removes the given controller's controls (those that were registered for
- * alignment) from this controller.
+ * Removes the given pane's controls (those that were registered for
+ * alignment) from this pane.
*
- * @param controller The controller containing the widgets that no longer
+ * @param pane The pane containing the widgets that no longer
* requires their width adjusted with the width of the longest widget
*
* @category Layout
*/
- protected final void removePaneForAlignment(AbstractPane<?> controller) {
- removeAlignLeft(controller);
- removeAlignRight(controller);
+ protected final void removePaneForAlignment(AbstractPane<?> pane) {
+ removeAlignLeft(pane);
+ removeAlignRight(pane);
}
/**
@@ -1970,9 +1993,9 @@ public abstract class AbstractPane<T extends Model>
setPopulating(false);
}
- // Ask the sub-panes to populate themselves
+ // Ask the sub-panes to repopulate themselves
for (AbstractPane<?> subPane : this.subPanes) {
- subPane.populate();
+ subPane.repopulate();
}
}
@@ -1998,9 +2021,9 @@ public abstract class AbstractPane<T extends Model>
}
/**
- * Returns the subject of this controller.
+ * Returns the subject of this pane.
*
- * @return The subject if this controller was not disposed; <code>null</code>
+ * @return The subject if this pane was not disposed; <code>null</code>
* if it was
*
* @category Populate
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/TriStateCheckBox.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/TriStateCheckBox.java
index 847a7e3d40..3f3abb236a 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/TriStateCheckBox.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/TriStateCheckBox.java
@@ -183,7 +183,7 @@ public final class TriStateCheckBox {
parent = new Composite(parent, SWT.NULL);
parent.setLayout(this.buildTableLayout());
- this.table = new Table(parent, SWT.FLAT | SWT.CHECK | SWT.SINGLE);
+ this.table = new Table(parent, SWT.FLAT | SWT.CHECK | SWT.SINGLE | SWT.NO_BACKGROUND);
this.table.addMouseListener(buildMouseListener());
this.table.addSelectionListener(buildSelectionListener());
this.table.getHorizontalBar().setVisible(false);
@@ -304,8 +304,12 @@ public final class TriStateCheckBox {
* checked and unchecked; or <code>null</code> for partially selected
*/
public void setSelection(Boolean selection) {
+ TriState oldState = this.state;
this.state = this.buildState(selection);
- this.updateCheckBox();
+
+ if (oldState != state) {
+ this.updateCheckBox();
+ }
}
/**
@@ -324,7 +328,6 @@ public final class TriStateCheckBox {
* value.
*/
private void updateCheckBox() {
-
TableItem checkBox = this.getCheckBox();
if (state == TriState.PARTIALLY_CHECKED) {
@@ -338,7 +341,7 @@ public final class TriStateCheckBox {
}
/**
- * An enum used to keep track of the current tri-state selected.
+ * An enum containing the possible selection.
*/
public enum TriState {
CHECKED,
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlJavaAttributeChooser.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlJavaAttributeChooser.java
index d63cc5f287..e5889faed3 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlJavaAttributeChooser.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlJavaAttributeChooser.java
@@ -17,13 +17,13 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
/**
*
* @version 2.0
* @since 2.0
*/
+@SuppressWarnings("nls")
public class XmlJavaAttributeChooser extends AbstractFormPane<XmlAttributeMapping<? extends AttributeMapping>>
{
private Text text;
@@ -31,15 +31,15 @@ public class XmlJavaAttributeChooser extends AbstractFormPane<XmlAttributeMappin
/**
* Creates a new <code>XmlJavaAttributeChooser</code>.
*
+ * @param parentPane The parent container of this one
* @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 XmlJavaAttributeChooser(PropertyValueModel<? extends XmlAttributeMapping<? extends AttributeMapping>> subjectHolder,
- Composite parent,
- TabbedPropertySheetWidgetFactory widgetFactory) {
+ public XmlJavaAttributeChooser(AbstractFormPane<?> parentPane,
+ PropertyValueModel<? extends XmlAttributeMapping<? extends AttributeMapping>> subjectHolder,
+ Composite parent) {
- super(subjectHolder, parent, widgetFactory);
+ super(parentPane, subjectHolder, parent);
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java
index c847d434c1..972e72ea64 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentAttributeDetailsPage.java
@@ -15,7 +15,9 @@ import java.util.List;
import java.util.ListIterator;
import org.eclipse.jpt.core.internal.context.base.IAttributeMapping;
import org.eclipse.jpt.core.internal.context.base.IPersistentAttribute;
+import org.eclipse.jpt.core.internal.context.orm.XmlAttributeMapping;
import org.eclipse.jpt.core.internal.context.orm.XmlPersistentAttribute;
+import org.eclipse.jpt.core.internal.resource.orm.AttributeMapping;
import org.eclipse.jpt.ui.internal.details.PersistentAttributeDetailsPage;
import org.eclipse.jpt.ui.internal.java.details.IAttributeMappingUiProvider;
import org.eclipse.jpt.ui.internal.java.mappings.properties.BasicMappingUiProvider;
@@ -34,6 +36,7 @@ import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -53,8 +56,8 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
@SuppressWarnings("nls")
public class XmlPersistentAttributeDetailsPage extends PersistentAttributeDetailsPage
{
- private XmlJavaAttributeChooser javaAttributeChooser;
private List<IAttributeMappingUiProvider<? extends IAttributeMapping>> attributeMappingUiProviders;
+ private XmlJavaAttributeChooser javaAttributeChooser;
/**
* Creates a new <code>XmlPersistentAttributeDetailsPage</code>.
@@ -70,6 +73,19 @@ public class XmlPersistentAttributeDetailsPage extends PersistentAttributeDetail
super(subjectHolder, parent, widgetFactory);
}
+ protected void addAttributeMappingUiProvidersTo(List<IAttributeMappingUiProvider<? extends IAttributeMapping>> providers) {
+ providers.add(BasicMappingUiProvider.instance());
+ providers.add(EmbeddedMappingUiProvider.instance());
+ providers.add(EmbeddedIdMappingUiProvider.instance());
+ providers.add(IdMappingUiProvider.instance());
+ providers.add(ManyToManyMappingUiProvider.instance());
+ providers.add(ManyToOneMappingUiProvider.instance());
+ providers.add(OneToManyMappingUiProvider.instance());
+ providers.add(OneToOneMappingUiProvider.instance());
+ providers.add(TransientMappingUiProvider.instance());
+ providers.add(VersionMappingUiProvider.instance());
+ }
+
/*
* (non-Javadoc)
*/
@@ -85,17 +101,22 @@ public class XmlPersistentAttributeDetailsPage extends PersistentAttributeDetail
);
}
- protected void addAttributeMappingUiProvidersTo(List<IAttributeMappingUiProvider<? extends IAttributeMapping>> providers) {
- providers.add(BasicMappingUiProvider.instance());
- providers.add(EmbeddedMappingUiProvider.instance());
- providers.add(EmbeddedIdMappingUiProvider.instance());
- providers.add(IdMappingUiProvider.instance());
- providers.add(ManyToManyMappingUiProvider.instance());
- providers.add(ManyToOneMappingUiProvider.instance());
- providers.add(OneToManyMappingUiProvider.instance());
- providers.add(OneToOneMappingUiProvider.instance());
- providers.add(TransientMappingUiProvider.instance());
- providers.add(VersionMappingUiProvider.instance());
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ protected IAttributeMappingUiProvider<? extends IAttributeMapping>[] attributeMappingUiProvidersFor(IPersistentAttribute persistentAttribute) {
+ //bug 192035 - no default mapping option in xml
+ return CollectionTools.array(attributeMappingUiProviders(), new IAttributeMappingUiProvider[CollectionTools.size(attributeMappingUiProviders())]);
+ }
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ protected IAttributeMappingUiProvider<IAttributeMapping> defaultAttributeMappingUiProvider(String key) {
+ throw new UnsupportedOperationException("Xml attributeMappings should not be default");
}
/*
@@ -110,18 +131,29 @@ public class XmlPersistentAttributeDetailsPage extends PersistentAttributeDetail
* (non-Javadoc)
*/
@Override
- protected IAttributeMappingUiProvider<IAttributeMapping> defaultAttributeMappingUiProvider(String key) {
- throw new UnsupportedOperationException("Xml attributeMappings should not be default");
+ public void doDispose() {
+ this.javaAttributeChooser.dispose();
+ super.doDispose();
}
/*
* (non-Javadoc)
*/
@Override
- @SuppressWarnings("unchecked")
- protected IAttributeMappingUiProvider<? extends IAttributeMapping>[] attributeMappingUiProvidersFor(IPersistentAttribute persistentAttribute) {
- //bug 192035 - no default mapping option in xml
- return CollectionTools.array(attributeMappingUiProviders(), new IAttributeMappingUiProvider[CollectionTools.size(attributeMappingUiProviders())]);
+ protected void doPopulate() {
+ super.doPopulate();
+ this.javaAttributeChooser.populate();
+ updateEnbabledState();
+ }
+
+ private PropertyValueModel<XmlAttributeMapping<? extends AttributeMapping>> getMappingHolder() {
+ return new TransformationPropertyValueModel<IPersistentAttribute, XmlAttributeMapping<? extends AttributeMapping>>(getSubjectHolder()) {
+ @Override
+ @SuppressWarnings("unchecked")
+ protected XmlAttributeMapping<? extends AttributeMapping> transform_(IPersistentAttribute value) {
+ return (XmlAttributeMapping<? extends AttributeMapping>) value.getMapping();
+ }
+ };
}
/*
@@ -130,12 +162,20 @@ public class XmlPersistentAttributeDetailsPage extends PersistentAttributeDetail
@Override
protected void initializeLayout(Composite container) {
+ javaAttributeChooser = new XmlJavaAttributeChooser(
+ this,
+ getMappingHolder(),
+ container
+ );
+
+ // Entity type widgets
buildLabeledComposite(
container,
JptUiXmlMessages.PersistentAttributePage_javaAttributeLabel,
buildMappingCombo(container).getControl()
);
+ // Properties pane
PageBook attributePane = buildMappingPageBook(container);
GridData gridData = new GridData();
@@ -147,23 +187,13 @@ public class XmlPersistentAttributeDetailsPage extends PersistentAttributeDetail
attributePane.setLayoutData(gridData);
}
- /*
- * (non-Javadoc)
- */
- @Override
- protected void doPopulate() {
- super.doPopulate();
- this.javaAttributeChooser.populate();
- updateEnbabledState();
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public void dispose() {
- this.javaAttributeChooser.dispose();
- super.dispose();
+ public void updateEnabledState(boolean enabled, Control control) {
+ control.setEnabled(enabled);
+ if (control instanceof Composite) {
+ for (Iterator<Control> i = new ArrayIterator<Control>(((Composite) control).getChildren()); i.hasNext(); ) {
+ updateEnabledState(enabled, i.next());
+ }
+ }
}
public void updateEnbabledState() {
@@ -173,13 +203,4 @@ public class XmlPersistentAttributeDetailsPage extends PersistentAttributeDetail
boolean enabled = !((XmlPersistentAttribute) subject()).isVirtual();
updateEnabledState(enabled, getControl());
}
-
- public void updateEnabledState(boolean enabled, Control control) {
- control.setEnabled(enabled);
- if (control instanceof Composite) {
- for (Iterator<Control> i = new ArrayIterator<Control>(((Composite) control).getChildren()); i.hasNext(); ) {
- updateEnabledState(enabled, i.next());
- }
- }
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentTypeDetailsPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentTypeDetailsPage.java
index 78b2bd158d..eadd2efeec 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentTypeDetailsPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/xml/details/XmlPersistentTypeDetailsPage.java
@@ -101,7 +101,7 @@ public class XmlPersistentTypeDetailsPage extends PersistentTypeDetailsPage<XmlP
buildLabeledComposite(
container,
JptUiMessages.PersistentTypePage_mapAs,
- typeMappingCombo.getControl()
+ typeMappingCombo.getControl().getParent()
);
// Metadata complete widget

Back to the top