Author: scabanovich
Date: 2010-06-02 10:35:25 -0400 (Wed, 02 Jun 2010)
New Revision: 22480
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibConfig3CompoundEditor.java
Log:
https://jira.jboss.org/browse/JBIDE-6374
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibConfig3CompoundEditor.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibConfig3CompoundEditor.java 2010-06-02
14:35:00 UTC (rev 22479)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibConfig3CompoundEditor.java 2010-06-02
14:35:25 UTC (rev 22480)
@@ -11,9 +11,11 @@
package org.jboss.tools.hibernate.ui.xml.editor;
import org.jboss.tools.common.editor.TreeFormPage;
+import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.ui.editor.EditorDescriptor;
import org.jboss.tools.common.model.ui.editors.multipage.DefaultMultipageEditor;
import org.jboss.tools.common.model.ui.texteditors.XMLTextEditorComponent;
+import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.hibernate.ui.xml.HibernateUIXMLPlugin;
import org.jboss.tools.hibernate.ui.xml.Messages;
import org.jboss.tools.hibernate.xml.model.FileHibernateFilteredTreeConstraint;
@@ -31,14 +33,14 @@
sessionFactory.setLabel(Messages.HibConfig3CompoundEditor_SessionFactoryLabel);
sessionFactory.setTitle(Messages.HibConfig3CompoundEditor_SessionFactoryTitle);
((TreeFormPage)sessionFactory).addFilter(new FileHibernateFilteredTreeConstraint());
- sessionFactory.initialize(object.getChildByPath("Session Factory"));
//$NON-NLS-1$
+ sessionFactory.initialize(getSessionFactoryObject());
addFormPage(sessionFactory, "sessionFactoryEditor"); //$NON-NLS-1$
security = createTreeFormPage();
security.setLabel(Messages.HibConfig3CompoundEditor_SecurityLabel);
security.setTitle(Messages.HibConfig3CompoundEditor_SecurityTitle);
((TreeFormPage)security).addFilter(new FileHibernateFilteredTreeConstraint());
- security.initialize(object.getChildByPath("Security")); //$NON-NLS-1$
+ security.initialize(getSecurityObject());
addFormPage(security, "securityEditor"); //$NON-NLS-1$
}
@@ -64,9 +66,9 @@
protected void setNormalMode() {
if (treeFormPage!=null) { // AU added
- sessionFactory.initialize(getModelObject().getChildByPath("Session
Factory")); // AU added //$NON-NLS-1$
+ sessionFactory.initialize(getSessionFactoryObject());
sessionFactory.setErrorMode(isErrorMode());
- security.initialize(getModelObject().getChildByPath("Security")); // AU
added //$NON-NLS-1$
+ security.initialize(getSecurityObject());
security.setErrorMode(isErrorMode());
} // AU added
if (selectionProvider!=null) {
@@ -77,11 +79,27 @@
}
}
+ XModelObject getSessionFactoryObject() {
+ XModelObject o = getModelObject().getChildByPath("Session Factory");
//$NON-NLS-1$
+ if(o == null) {
+ o = XModelObjectLoaderUtil.createValidObject(object.getModel(),
"HibConfig3SessionFactory"); //$NON-NLS-1$
+ }
+ return o;
+ }
+
+ XModelObject getSecurityObject() {
+ XModelObject o = getModelObject().getChildByPath("Security"); //$NON-NLS-1$
+ if(o == null) {
+ o = XModelObjectLoaderUtil.createValidObject(object.getModel(),
"HibConfig3Security"); //$NON-NLS-1$
+ }
+ return o;
+ }
+
protected void setErrorMode() {
if (treeFormPage!=null) { // AU added
- sessionFactory.initialize(getModelObject().getChildByPath("Session
Factory")); // AU added //$NON-NLS-1$
+ sessionFactory.initialize(getSessionFactoryObject());
sessionFactory.setErrorMode(isErrorMode());
- security.initialize(getModelObject().getChildByPath("Security")); // AU
added //$NON-NLS-1$
+ security.initialize(getSecurityObject());
security.setErrorMode(isErrorMode());
} // AU added
if (treeEditor!=null) {
@@ -100,4 +118,4 @@
return new XMLTextEditorComponent(false);
}
-}
+}
\ No newline at end of file