[jbosstools-commits] JBoss Tools SVN: r17551 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml: resources/meta and 2 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Sep 14 12:37:00 EDT 2009


Author: scabanovich
Date: 2009-09-14 12:37:00 -0400 (Mon, 14 Sep 2009)
New Revision: 17551

Added:
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/GrantActionsConstraint.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/handlers/AddPropertySupport.java
Modified:
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/plugin.xml
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/resources/meta/hibconfig3.meta
Log:
https://jira.jboss.org/jira/browse/JBIDE-2607

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/plugin.xml	2009-09-14 16:36:00 UTC (rev 17550)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/plugin.xml	2009-09-14 16:37:00 UTC (rev 17551)
@@ -101,6 +101,11 @@
 
 		<xclass id="org.jboss.tools.hibernate.xml.model.handlers.DeletePropertyHandler"
 			class="org.jboss.tools.hibernate.xml.model.handlers.DeletePropertyHandler"/>
+		<xclass id="org.jboss.tools.hibernate.xml.model.handlers.AddPropertySupport"
+			class="org.jboss.tools.hibernate.xml.model.handlers.AddPropertySupport"/>
+		
+		<xclass id="org.jboss.tools.hibernate.xml.model.GrantActionsConstraint"
+			class="org.jboss.tools.hibernate.xml.model.GrantActionsConstraint"/>
    </extension>
 
 </plugin>
\ No newline at end of file

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/resources/meta/hibconfig3.meta
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/resources/meta/hibconfig3.meta	2009-09-14 16:36:00 UTC (rev 17550)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/resources/meta/hibconfig3.meta	2009-09-14 16:37:00 UTC (rev 17551)
@@ -633,9 +633,21 @@
    <XModelAttribute PROPERTIES="save=always;id=true;category=general"
     name="role" xmlname="role"/>
    <XModelAttribute PROPERTIES="save=always;category=general"
-    name="entity-name" xmlname="entity-name"/>
-   <XModelAttribute PROPERTIES="save=always;category=general"
-    name="actions" xmlname="actions"/>
+    name="entity-name" xmlname="entity-name">
+    <Editor name="AccessibleJava"/>
+   </XModelAttribute>
+   <XModelAttribute
+    PROPERTIES="save=always;category=general;separator=comma;greedy=always"
+    name="actions" xmlname="actions">
+    <Constraint loader="org.jboss.tools.hibernate.xml.model.GrantActionsConstraint">
+     <value name="*"/>
+     <value name="read"/>
+     <value name="insert"/>
+     <value name="update"/>
+     <value name="delete"/>
+    </Constraint>
+    <Editor name="ListAdd"/>
+   </XModelAttribute>
    <XModelAttribute TRIM="no" name="comment" visibility="false" xmlname="#comment">
     <Editor name="Note"/>
    </XModelAttribute>
@@ -1097,7 +1109,12 @@
    <XModelAttribute
     PROPERTIES="category=general;h_property=hibernate.connection.password" name="password"/>
    <XModelAttribute
-    PROPERTIES="category=general;h_property=hibernate.connection.pool_size" name="pool size"/>
+    PROPERTIES="category=general;h_property=hibernate.connection.pool_size" name="pool size">
+    <Constraint loader="Int">
+     <value name="mandatory=false"/>
+    </Constraint>
+    <Editor name="Int"/>
+   </XModelAttribute>
    <XModelAttribute
     PROPERTIES="category=general;h_property=hibernate.connection.provider_class" name="provider class">
     <Editor name="AccessibleJava"/>
@@ -1148,13 +1165,23 @@
     <Editor name="Uneditable"/>
    </XModelAttribute>
    <XModelAttribute
-    PROPERTIES="category=general;h_property=hibernate.jdbc.batch_size" name="batch size"/>
+    PROPERTIES="category=general;h_property=hibernate.jdbc.batch_size" name="batch size">
+    <Constraint loader="Int">
+     <value name="mandatory=false"/>
+    </Constraint>
+    <Editor name="Int"/>
+   </XModelAttribute>
    <XModelAttribute
     PROPERTIES="category=general;h_property=hibernate.jdbc.batch_versioned_data" name="batch versioned data"/>
    <XModelAttribute
     PROPERTIES="category=general;h_property=hibernate.jdbc.factory_class" name="factory class"/>
    <XModelAttribute
-    PROPERTIES="category=general;h_property=hibernate.jdbc.fetch_size" name="fetch size"/>
+    PROPERTIES="category=general;h_property=hibernate.jdbc.fetch_size" name="fetch size">
+    <Constraint loader="Int">
+     <value name="mandatory=false"/>
+    </Constraint>
+    <Editor name="Int"/>
+   </XModelAttribute>
    <XModelAttribute
     PROPERTIES="category=general;h_property=hibernate.jdbc.sql_exception_converter" name="sql exception converter"/>
    <XModelAttribute
@@ -1273,8 +1300,8 @@
   <XActionItem kind="list">
    <XActionItem ICON="action.empty" displayName="New" group="1"
     kind="list" name="CreateActions">
-    <XActionItem HandlerClassName="%Create%"
-     PROPERTIES="validator.add=true" WizardClassName="%Default%"
+    <XActionItem HandlerClassName="%SpecialWizard%"
+     PROPERTIES="validator.add=true;support=org.jboss.tools.hibernate.xml.model.handlers.AddPropertySupport"
      displayName="Property..." kind="action" name="AddProperty">
      <EntityData EntityName="HibConfig3Property">
       <AttributeData AttributeName="name"/>
@@ -1307,7 +1334,10 @@
     <Editor name="Uneditable"/>
    </XModelAttribute>
    <XModelAttribute PROPERTIES="save=always;id=true;category=general"
-    name="name" xmlname="name"/>
+    name="name" xmlname="name">
+    <Constraint loader="ListString"/>
+    <Editor name="HibernatePropertyList"/>
+   </XModelAttribute>
    <XModelAttribute name="value" xmlname="#text"/>
    <XModelAttribute TRIM="no" name="comment" visibility="false" xmlname="#comment">
     <Editor name="Note"/>

Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/GrantActionsConstraint.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/GrantActionsConstraint.java	                        (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/GrantActionsConstraint.java	2009-09-14 16:37:00 UTC (rev 17551)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ *     Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/ 
+package org.jboss.tools.hibernate.xml.model;
+
+import java.util.StringTokenizer;
+
+import org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintAList;
+
+public class GrantActionsConstraint extends XAttributeConstraintAList {
+	static String WILD_CARD = "*"; //$NON-NLS-1$
+	static String MESSAGE = "value must be * or combination of read,insert,update,delete"; //$NON-NLS-1$
+
+    public boolean accepts(String value) {
+    	if(value.indexOf(WILD_CARD) >= 0 && !value.equals(WILD_CARD)) {
+    		return false;
+    	}
+        StringTokenizer st = new StringTokenizer(value, ","); //$NON-NLS-1$
+        while(st.hasMoreTokens()) {
+            String t = st.nextToken().trim();
+            if(!values.contains(t)) return false;
+        }
+        return true;
+    }
+
+    public String getError(String value) {
+        return accepts(value) ? null : MESSAGE;
+    }
+
+}


Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/GrantActionsConstraint.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/handlers/AddPropertySupport.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/handlers/AddPropertySupport.java	                        (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/handlers/AddPropertySupport.java	2009-09-14 16:37:00 UTC (rev 17551)
@@ -0,0 +1,61 @@
+package org.jboss.tools.hibernate.xml.model.handlers;
+
+import java.util.Properties;
+
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.action.impl.DefaultWizardDataValidator;
+import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
+import org.jboss.tools.common.meta.action.impl.WizardDataValidator;
+import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.project.ext.store.XMLStoreConstants;
+import org.jboss.tools.hibernate.xml.model.impl.ComplexAttrUtil;
+
+public class AddPropertySupport extends SpecialWizardSupport {
+
+	public AddPropertySupport() {}
+
+	public void action(String name) throws XModelException {
+		if(FINISH.equals(name)) {
+			execute();
+			setFinished(true);
+		} else if(CANCEL.equals(name)) {
+			setFinished(true);
+		}
+	}
+	
+	public String[] getActionNames(int stepId) {
+		return new String[]{FINISH, CANCEL};
+	}
+
+	void execute() throws XModelException {
+		Properties p = extractStepData(0);
+		String entity = getEntityData()[0].getModelEntity().getName();
+		XModelObject o = getTarget().getModel().createModelObject(entity, p);
+		DefaultCreateHandler.addCreatedObject(getTarget(), o, getProperties());
+	}
+
+    public WizardDataValidator getValidator(int step) {
+    	validator.setSupport(this, step);
+    	return validator;
+    }
+
+    Validator validator = new Validator();
+
+	class Validator extends DefaultWizardDataValidator {
+		public void validate(Properties data) {
+			super.validate(data);
+			String name = data.getProperty(XMLStoreConstants.ATTR_NAME);
+			String value = data.getProperty(XMLStoreConstants.ATTR_VALUE);
+			XAttribute attr = ComplexAttrUtil.findComplexAttr(getTarget(), name);
+			if(attr != null) {
+				String error = DefaultCreateHandler.getConstraintMessage(name, value, attr.getConstraint());
+				if(error != null) {
+					message = error;
+				}
+			}
+		}
+	}
+
+}


Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/src/org/jboss/tools/hibernate/xml/model/handlers/AddPropertySupport.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list