181811- Table Generator Name entry problems
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratedValueComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratedValueComposite.java
index 8f8e0fb..9bdc7da 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratedValueComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/GeneratedValueComposite.java
@@ -152,14 +152,13 @@
protected void generatedValueChanged(Notification notification) {
if (notification.getFeatureID(IGeneratedValue.class) == JpaCoreMappingsPackage.IGENERATED_VALUE__STRATEGY) {
- final GenerationType strategy = (GenerationType) notification.getNewValue();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (getControl().isDisposed()) {
return;
}
- if (selectedStrategy() != strategy) {
- strategyComboViewer.setSelection(new StructuredSelection(strategy));
+ if (selectedStrategy() != generatedValue.getStrategy()) {
+ strategyComboViewer.setSelection(new StructuredSelection(generatedValue.getStrategy()));
}
}
});
@@ -187,6 +186,7 @@
}
if (this.generatedValue == null) {
this.strategyComboViewer.getCombo().deselectAll();
+ this.generatorNameCombo.setText("");
this.populating = false;
return;
}
@@ -226,7 +226,7 @@
private void populateGeneratorName() {
String generatorName = this.generatedValue.getGenerator();
if (generatorName == null || generatorName.equals("")) {
- this.generatorNameCombo.clearSelection();
+ this.generatorNameCombo.setText("");
}
else if (!this.generatorNameCombo.getText().equals(generatorName)) {
this.generatorNameCombo.setText(generatorName);
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 85cf93c..a9f0227 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
@@ -14,18 +14,15 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.TextViewer;
import org.eclipse.jpt.core.internal.mappings.IGenerator;
import org.eclipse.jpt.core.internal.mappings.IId;
import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
import org.eclipse.jpt.ui.internal.details.BaseJpaComposite;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
/**
@@ -37,7 +34,7 @@
private E generator;
private Adapter generatorListener;
- protected ITextViewer nameViewer;
+ protected Text nameTextWidget;
public GeneratorComposite(Composite parent, CommandStack commandStack, TabbedPropertySheetWidgetFactory widgetFactory) {
super(parent, SWT.NULL, commandStack, widgetFactory);
@@ -58,16 +55,15 @@
* @param parent
* @return
*/
- protected ITextViewer buildNameViewer(Composite parent) {
- final TextViewer textViewer = new TextViewer(parent, SWT.SINGLE | SWT.BORDER);
- textViewer.setDocument(new Document());
- textViewer.addTextListener(new ITextListener() {
- public void textChanged(TextEvent event) {
+ protected Text buildNameText(Composite parent) {
+ final Text text = getWidgetFactory().createText(parent, null);
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(org.eclipse.swt.events.ModifyEvent e) {
if (isPopulating()) {
return;
}
- String name = textViewer.getDocument().get();
+ String name = text.getText();
if (name.equals("")) { //$NON-NLS-1$
if (getGenerator().getName() == null) {
return;
@@ -81,7 +77,7 @@
generator.setName(name);
}
});
- return textViewer;
+ return text;
}
protected abstract E createGenerator();
@@ -127,18 +123,17 @@
protected void generatorChanged(Notification notification) {
if (notification.getFeatureID(IGenerator.class) == JpaCoreMappingsPackage.IGENERATOR__NAME) {
- final String name = notification.getNewStringValue();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (getControl().isDisposed()) {
return;
}
- if (nameViewer.getDocument().get() == null || !nameViewer.getDocument().get().equals(name)) {
- if (name == null) {
+ if (nameTextWidget.getText() == null || !nameTextWidget.getText().equals(getGenerator().getName())) {
+ if (getGenerator().getName() == null) {
clearNameViewer();
}
else {
- nameViewer.getDocument().set(name);
+ nameTextWidget.setText(getGenerator().getName());
}
}
}
@@ -149,8 +144,8 @@
private void populateNameViewer() {
String name = this.getGenerator().getName();
if (name != null) {
- if (!this.nameViewer.getDocument().get().equals(name)) {
- this.nameViewer.getDocument().set(name);
+ if (!this.nameTextWidget.getText().equals(name)) {
+ this.nameTextWidget.setText(name);
}
}
else {
@@ -167,11 +162,6 @@
}
protected void clearNameViewer() {
- this.nameViewer.getDocument().set(""); //$NON-NLS-1$
- }
-
- public void dispose() {
- disengageListeners();
- super.dispose();
+ this.nameTextWidget.setText(""); //$NON-NLS-1$
}
}
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 288f974..a84b671 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
@@ -64,12 +64,12 @@
composite.setLayout(layout);
getWidgetFactory().createLabel(composite, JptUiMappingsMessages.SequenceGeneratorComposite_name);
- this.nameViewer = buildNameViewer(composite);
+ this.nameTextWidget = buildNameText(composite);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
- this.nameViewer.getTextWidget().setLayoutData(gridData);
- helpSystem.setHelp(nameViewer.getTextWidget(), IJpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_NAME);
+ this.nameTextWidget.setLayoutData(gridData);
+ helpSystem.setHelp(this.nameTextWidget, IJpaHelpContextIds.MAPPING_SEQUENCE_GENERATOR_NAME);
getWidgetFactory().createLabel(composite, JptUiMappingsMessages.SequenceGeneratorComposite_sequence);
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 5a61503..b4874f5 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
@@ -73,12 +73,12 @@
getWidgetFactory().createLabel(composite, JptUiMappingsMessages.TableGeneratorComposite_name);
- this.nameViewer = buildNameViewer(composite);
+ this.nameTextWidget = buildNameText(composite);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
- this.nameViewer.getTextWidget().setLayoutData(gridData);
- helpSystem.setHelp(this.nameViewer.getTextWidget(), IJpaHelpContextIds.MAPPING_TABLE_GENERATOR_NAME);
+ this.nameTextWidget.setLayoutData(gridData);
+ helpSystem.setHelp(this.nameTextWidget, IJpaHelpContextIds.MAPPING_TABLE_GENERATOR_NAME);
getWidgetFactory().createLabel(composite, JptUiMappingsMessages.TableGeneratorComposite_table);