Author: dgeraskov
Date: 2009-07-30 09:56:05 -0400 (Thu, 30 Jul 2009)
New Revision: 16899
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateDiscriminatorColumnComposite.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4665
fixed source-to-composite updates
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateDiscriminatorColumnComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateDiscriminatorColumnComposite.java 2009-07-30
13:31:41 UTC (rev 16898)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateDiscriminatorColumnComposite.java 2009-07-30
13:56:05 UTC (rev 16899)
@@ -75,6 +75,8 @@
* @since 2.0
*/
public class HibernateDiscriminatorColumnComposite <T extends HibernateEntity>
extends FormPane<T> {
+
+ private WritablePropertyValueModel<DiscriminatorFormula>
discriminatorFormulaHolder;
/**
* Creates a new <code>InheritanceComposite</code>.
@@ -87,6 +89,12 @@
super(parentPane, parent, false);
}
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ discriminatorFormulaHolder = new
SimplePropertyValueModel<DiscriminatorFormula>();
+ }
@Override
protected void initializeLayout(Composite container) {
@@ -128,13 +136,12 @@
JptUiMappingsMessages.InheritanceComposite_detailsGroupBox,
new SimplePropertyValueModel<Boolean>(Boolean.FALSE)
);
-
+
new DetailsComposite(this, discriminatorColumnHolder, addSubPane(container, 0, 16));
-
+
new PaneEnabler(buildDiscriminatorColumnEnabledHolder(), this);
}
-
private ColumnCombo<DiscriminatorColumn> addDiscriminatorColumnCombo(
Composite container,
PropertyValueModel<DiscriminatorColumn> discriminatorColumnHolder) {
@@ -171,14 +178,13 @@
protected String getValue() {
return getSubject().getSpecifiedName();
}
-
+
@Override
protected String buildNullDefaultValueEntry() {
return JptUiMappingsMessages.NoneSelected;
}
};
- }
-
+ }
private PropertyValueModel<DiscriminatorColumn> buildDiscriminatorColumnHolder()
{
return new PropertyAspectAdapter<Entity, DiscriminatorColumn>(getSubjectHolder())
{
@@ -189,30 +195,39 @@
};
}
-
private WritablePropertyValueModel<String> buildDiscriminatorFormulaHolder() {
- return new PropertyAspectAdapter<HibernateEntity, String>(getSubjectHolder(),
DiscriminatorFormula.VALUE_PROPERTY) {
+ return new PropertyAspectAdapter<DiscriminatorFormula,
String>(discriminatorFormulaHolder, DiscriminatorFormula.VALUE_PROPERTY) {
@Override
protected String buildValue_() {
- DiscriminatorFormula df = this.subject.getDiscriminatorFormula();
- return df == null ? null : df.getValue();
+ return subject == null ? null : subject.getValue();
}
@Override
+ public void setValue(String value) {
+ if (value != null && !"".equals(value)) { //$NON-NLS-1$
+ DiscriminatorFormula discriminatorFormula = (getSubject().getDiscriminatorFormula()
!= null
+ ? getSubject().getDiscriminatorFormula()
+ : getSubject().addDiscriminatorFormula());
+ discriminatorFormula.setValue(value);
+ discriminatorFormulaHolder.setValue(discriminatorFormula);
+ }
+ setValue_(value);
+ }
+
+ @Override
protected void setValue_(String value) {
- if ("".equals(value)) value = null; //$NON-NLS-1$
- DiscriminatorFormula df = this.subject.getDiscriminatorFormula();
- if (value == null && df != null){
- this.subject.removeDiscriminatorFormula();
+ if ("".equals(value)) {//$NON-NLS-1$
+ value = null;
+ }
+ if (value == null && subject != null){
+ getSubject().removeDiscriminatorFormula();
+ return;
} else {
- if (df == null){
- df = this.subject.addDiscriminatorFormula();
- }
- df.setValue(value);
+ subject.setValue(value);
}
}
};
- }
+ }
private EnumFormComboViewer<DiscriminatorColumn, DiscriminatorType>
addDiscriminatorTypeCombo(
Composite container,