private Widget checkBoxEditor(final RuleAttribute at, final boolean isReadOnly) { final CheckBox box = new CheckBox(); box.setEnabled(!isReadOnly); if (at.getValue() == null || at.getValue().isEmpty()) { box.setValue(false); at.setValue(FALSE_VALUE); } else { box.setValue((at.getValue().equals(TRUE_VALUE))); } box.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { at.setValue((box.getValue()) ? TRUE_VALUE : FALSE_VALUE); } }); return box; }
private String getRuleDialect() { final RuleModel model = getModeller().getModel(); for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; if (attr.getAttributeName().equals("dialect")) { return attr.getValue(); } } return DRLConstraintValueBuilder.DEFAULT_DIALECT; }
private Widget checkBoxEditor(final RuleAttribute at, final boolean isReadOnly) { final CheckBox box = new CheckBox(); box.setEnabled(!isReadOnly); if (at.getValue() == null || at.getValue().isEmpty()) { box.setValue(false); at.setValue(FALSE_VALUE); } else { box.setValue((at.getValue().equals(TRUE_VALUE))); } box.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { at.setValue((box.getValue()) ? TRUE_VALUE : FALSE_VALUE); } }); return box; }
private String getRuleDialect() { final RuleModel model = getModeller().getModel(); for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; if (attr.getAttributeName().equals("dialect")) { return attr.getValue(); } } return DRLConstraintValueBuilder.DEFAULT_DIALECT; }
/** * Marshal model attributes * @param buf * @param model */ protected void marshalAttributes(final StringBuilder buf, final RuleModel model) { boolean hasDialect = false; for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; buf.append("\t"); buf.append(attr); buf.append("\n"); if (attr.getAttributeName().equals("dialect")) { constraintValueBuilder = DRLConstraintValueBuilder.getBuilder(attr.getValue()); hasDialect = true; } } // Un comment below for mvel if (!hasDialect) { RuleAttribute attr = new RuleAttribute("dialect", DRLConstraintValueBuilder.DEFAULT_DIALECT); buf.append("\t"); buf.append(attr); buf.append("\n"); } }
private RuleAttribute visitRuleAttribute(RuleAttribute attr) { RuleAttribute clone = new RuleAttribute(); clone.setAttributeName(attr.getAttributeName()); clone.setValue(attr.getValue()); return clone; }
private RuleAttribute visitRuleAttribute(RuleAttribute attr) { RuleAttribute clone = new RuleAttribute(); clone.setAttributeName(attr.getAttributeName()); clone.setValue(attr.getValue()); return clone; }
@Test public void testInitDatePickerByRuleAttribute() { final DatePicker datePicker = mock(DatePicker.class); final String attributeValue = "31-May-2018"; doReturn(attributeValue).when(ruleAttribute).getValue(); factory.initDatePickerByRuleAttribute(datePicker, ruleAttribute); // not robust verifications because of Date formatting / parsing is mocked by GwtMockito verify(datePicker).setFormat(any()); verify(datePicker).setValue(notNull(Date.class)); }
@Test public void testInitTextBoxByRuleAttribute() { final TextBox textBox = mock(TextBox.class); final String attributeValue = "123"; doReturn(attributeValue).when(ruleAttribute).getValue(); factory.initTextBoxByRuleAttribute(textBox, ruleAttribute); verify(textBox).setEnabled(!isReadOnly); verify(textBox).setValue(attributeValue); }
protected void initTextBoxByRuleAttribute(final TextBox textBox, final RuleAttribute ruleAttribute) { textBox.setEnabled(!isReadOnly); if (!isReadOnly) { textBox.addValueChangeHandler(event -> ruleAttribute.setValue(textBox.getValue())); } textBox.setValue(ruleAttribute.getValue()); }
private void visitRuleAttribute(final RuleAttribute attr) { PartType type = PartType.getPartTypeFromAttribueDescrName(attr.getAttributeName()); switch (type) { case AGENDA_GROUP: case ACTIVATION_GROUP: case RULEFLOW_GROUP: case ENTRY_POINT: SharedPart sharedRef = new SharedPart(attr.getValue(), type); builder.addGenerator(sharedRef); break; // OCRAM: finish default: // logger.info("Not processing attribute: " + descr.getName()); } }
@Test public void testInitDatePickerByRuleAttribute() { final DatePicker datePicker = mock(DatePicker.class); final String attributeValue = "31-May-2018"; doReturn(attributeValue).when(ruleAttribute).getValue(); factory.initDatePickerByRuleAttribute(datePicker, ruleAttribute); // not robust verifications because of Date formatting / parsing is mocked by GwtMockito verify(datePicker).setFormat(any()); verify(datePicker).setValue(notNull(Date.class)); }
@Test public void testInitTextBoxByRuleAttribute() { final TextBox textBox = mock(TextBox.class); final String attributeValue = "123"; doReturn(attributeValue).when(ruleAttribute).getValue(); factory.initTextBoxByRuleAttribute(textBox, ruleAttribute); verify(textBox).setEnabled(!isReadOnly); verify(textBox).setValue(attributeValue); }
private void visitRuleAttribute(final RuleAttribute attr) { PartType type = PartType.getPartTypeFromAttribueDescrName(attr.getAttributeName()); switch (type) { case AGENDA_GROUP: case ACTIVATION_GROUP: case RULEFLOW_GROUP: case ENTRY_POINT: SharedPart sharedRef = new SharedPart(attr.getValue(), type); builder.addGenerator(sharedRef); break; // OCRAM: finish default: // logger.info("Not processing attribute: " + descr.getName()); } }
protected void initTextBoxByRuleAttribute(final TextBox textBox, final RuleAttribute ruleAttribute) { textBox.setEnabled(!isReadOnly); if (!isReadOnly) { textBox.addValueChangeHandler(event -> ruleAttribute.setValue(textBox.getValue())); } textBox.setValue(ruleAttribute.getValue()); }
@Test public void testRoundTrip() { final TemplateModel m = getComplexModel(); final String xml = RuleTemplateModelXMLPersistenceImpl.getInstance().marshal(m); final TemplateModel m2 = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(xml); assertNotNull(m2); assertEquals(m.name, m2.name); assertEquals(m.lhs.length, m2.lhs.length); assertEquals(m.rhs.length, m2.rhs.length); assertEquals(1, m.attributes.length); final RuleAttribute at = m.attributes[0]; assertEquals("no-loop", at.getAttributeName()); assertEquals("true", at.getValue()); final String newXML = RuleTemplateModelXMLPersistenceImpl.getInstance().marshal(m2); assertEquals(xml, newXML); }