Author: scabanovich
Date: 2009-09-14 13:21:34 -0400 (Mon, 14 Sep 2009)
New Revision: 17555
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/form/Hibernate3FormLayoutData.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2607
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/form/Hibernate3FormLayoutData.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/form/Hibernate3FormLayoutData.java 2009-09-14
17:21:07 UTC (rev 17554)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/form/Hibernate3FormLayoutData.java 2009-09-14
17:21:34 UTC (rev 17555)
@@ -10,14 +10,19 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.xml.form;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
+import org.jboss.tools.common.meta.XModelEntity;
+import org.jboss.tools.common.meta.impl.XModelMetaDataImpl;
import org.jboss.tools.common.model.ui.forms.ArrayToMap;
import org.jboss.tools.common.model.ui.forms.FormAttributeData;
import org.jboss.tools.common.model.ui.forms.FormData;
import org.jboss.tools.common.model.ui.forms.IFormData;
import org.jboss.tools.common.model.ui.forms.IFormLayoutData;
+import org.jboss.tools.common.model.ui.forms.ModelFormLayoutData;
import org.jboss.tools.common.model.util.ClassLoaderUtil;
public class Hibernate3FormLayoutData implements IFormLayoutData {
@@ -146,7 +151,7 @@
};
- private static Map FORM_LAYOUT_DEFINITION_MAP = Collections.unmodifiableMap(new
ArrayToMap(FORM_LAYOUT_DEFINITIONS));
+ private static Map FORM_LAYOUT_DEFINITION_MAP = Collections.synchronizedMap(new
ArrayToMap(FORM_LAYOUT_DEFINITIONS));
static Hibernate3FormLayoutData INSTANCE = new Hibernate3FormLayoutData();
@@ -157,7 +162,36 @@
public Hibernate3FormLayoutData() {}
public IFormData getFormData(String entityName) {
- return (IFormData)FORM_LAYOUT_DEFINITION_MAP.get(entityName);
+ IFormData data = (IFormData)FORM_LAYOUT_DEFINITION_MAP.get(entityName);
+ if(data == null) {
+ data = generateDefaultFormData(entityName);
+ }
+ return data;
}
+
+ private IFormData generateDefaultFormData(String entityName) {
+ IFormData data = null;
+ XModelEntity entity = XModelMetaDataImpl.getInstance().getEntity(entityName);
+ if(entity != null) {
+ data = generateDefaultFormData(entity);
+ }
+ if(data != null) {
+ FORM_LAYOUT_DEFINITION_MAP.put(entityName, data);
+ }
+ return data;
+ }
+
+ private IFormData generateDefaultFormData(XModelEntity entity) {
+ String entityName = entity.getName();
+ List<IFormData> list = new ArrayList<IFormData>();
+ IFormData g = ModelFormLayoutData.createGeneralFormData(entity);
+ if(g != null) list.add(g);
+ IFormData a = ModelFormLayoutData.createAdvancedFormData(entityName);
+ if(a != null) list.add(a);
+ IFormData[] ds = list.toArray(new IFormData[0]);
+ IFormData data = new FormData(entityName, new String[]{null}, ds);
+ return data;
+ }
+
}