Author: scabanovich
Date: 2010-01-13 11:53:22 -0500 (Wed, 13 Jan 2010)
New Revision: 19739
Modified:
trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb-actions.meta
trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/AddContentBasedRouterSupport.java
trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/impl/ContentBasedRouter.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5653
Modified: trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb-actions.meta
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb-actions.meta 2010-01-13
16:47:05 UTC (rev 19738)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb-actions.meta 2010-01-13
16:53:22 UTC (rev 19739)
@@ -3529,12 +3529,13 @@
<AttributeData AttributeName="rule reload"
Mandatory="no"/>
</EntityData>
</XActionItem>
- <XActionItem HandlerClassName="%Create%"
ICON="action.empty"
- PROPERTIES="validator.add=true" WizardClassName="%Default%"
+ <XActionItem HandlerClassName="%SpecialWizard%"
+ ICON="action.empty"
+
PROPERTIES="validator.add=true;support=org.jboss.tools.esb.core.model.handlers.AddContentBasedRouterSupport"
displayName="Content Based Router (Generic)..." kind="action"
name="AddContentBasedRouter">
<EntityData EntityName="ESBPreActionContentBasedRouter120">
<AttributeData AttributeName="name"/>
- <AttributeData AttributeName="cbr alias"
Mandatory="no"/>
+ <AttributeData AttributeName="cbr alias"/>
<AttributeData AttributeName="process"
Mandatory="no"/>
<AttributeData AttributeName="rule set"
Mandatory="no"/>
<AttributeData AttributeName="rule language"
Mandatory="no"/>
Modified:
trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/AddContentBasedRouterSupport.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/AddContentBasedRouterSupport.java 2010-01-13
16:47:05 UTC (rev 19738)
+++
trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/AddContentBasedRouterSupport.java 2010-01-13
16:53:22 UTC (rev 19739)
@@ -2,11 +2,14 @@
import java.util.Properties;
+import org.jboss.tools.common.meta.action.impl.DefaultWizardDataValidator;
+import org.jboss.tools.common.meta.action.impl.WizardDataValidator;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateSupport;
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
+import org.jboss.tools.esb.core.model.impl.ContentBasedRouter;
public class AddContentBasedRouterSupport extends DefaultCreateSupport {
@@ -17,10 +20,57 @@
Properties p = extractStepData(0);
String cbrAlias = action.getProperty("cbrAlias");
if(cbrAlias != null) {
- p.setProperty("cbr alias", cbrAlias);
+ p.setProperty(ContentBasedRouter.ATTR_CBR_ALIAS, cbrAlias);
}
+ String ruleSet = p.getProperty(ContentBasedRouter.ATTR_RULE_SET);
+ if(ruleSet == null || ruleSet.length() == 0) {
+ p.remove(ContentBasedRouter.ATTR_RULE_RELOAD);
+ }
XModelObject action = XModelObjectLoaderUtil.createValidObject(getTarget().getModel(),
entity, p);
DefaultCreateHandler.addCreatedObject(getTarget(), action, getProperties());
}
+ public boolean isFieldEditorEnabled(int stepId, String name, Properties values) {
+ if(ContentBasedRouter.ATTR_RULE_RELOAD.equals(name)) {
+ String ruleSet = values.getProperty(ContentBasedRouter.ATTR_RULE_SET);
+ if(ruleSet == null || ruleSet.trim().length() == 0) {
+ return false;
+ }
+ } else if(ContentBasedRouter.ATTR_RULE_LANGUAGE.equals(name)) {
+ String alias = values.getProperty(ContentBasedRouter.ATTR_CBR_ALIAS);
+ if(alias == null) alias = action.getProperty("cbrAlias");
+ if(isRegexOrXPathOrEmpty(alias)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean isRegexOrXPathOrEmpty(String alias) {
+ return (alias == null || alias.length() == 0 ||
"Regex".equalsIgnoreCase(alias) || "Xpath".equalsIgnoreCase(alias));
+ }
+
+ protected DefaultWizardDataValidator cbrValidator = new CBRValidator();
+
+ public WizardDataValidator getValidator(int step) {
+ cbrValidator.setSupport(this, step);
+ return cbrValidator;
+ }
+
+ class CBRValidator extends DefaultWizardDataValidator {
+ public void validate(Properties data) {
+ message = null;
+ super.validate(data);
+ if(message != null) return;
+ String alias = data.getProperty(ContentBasedRouter.ATTR_CBR_ALIAS);
+ if("Drools".equalsIgnoreCase(alias)) {
+ String ruleSet = data.getProperty(ContentBasedRouter.ATTR_RULE_SET);
+ if(ruleSet == null || ruleSet.length() == 0) {
+ message = "Rule Set must be set for Drools Router";
+ return;
+ }
+ }
+ }
+ }
+
}
Modified:
trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/impl/ContentBasedRouter.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/impl/ContentBasedRouter.java 2010-01-13
16:47:05 UTC (rev 19738)
+++
trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/impl/ContentBasedRouter.java 2010-01-13
16:53:22 UTC (rev 19739)
@@ -18,8 +18,10 @@
*/
public class ContentBasedRouter extends ESBCustomizedObjectImpl {
private static final long serialVersionUID = 1L;
- static String ATTR_CBR_ALIAS = "cbr alias";
- static String ATTR_RULE_LANGUAGE = "rule language";
+ public static String ATTR_CBR_ALIAS = "cbr alias";
+ public static String ATTR_RULE_LANGUAGE = "rule language";
+ public static String ATTR_RULE_SET = "rule set";
+ public static String ATTR_RULE_RELOAD = "rule reload";
public ContentBasedRouter() {}
@@ -30,6 +32,11 @@
if(isRegexOrXPath(alias)) {
return false;
}
+ } else if(ATTR_RULE_RELOAD.equals(name)) {
+ String ruleSet = getAttributeValue(ATTR_RULE_SET);
+ if(ruleSet == null || ruleSet.length() == 0) {
+ return false;
+ }
}
return super.isAttributeEditable(name);
}
@@ -45,6 +52,10 @@
if(isRegexOrXPath(newValue)) {
setAttributeValue(ATTR_RULE_LANGUAGE, "");
}
+ } else if(ATTR_RULE_SET.equals(name)) {
+ if(newValue == null || newValue.length() == 0) {
+ setAttributeValue(ATTR_RULE_RELOAD,
getModelEntity().getAttribute(ATTR_RULE_RELOAD).getDefaultValue());
+ }
}
}