use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class FromCompositeFactPatternWidget method showFactTypeSelector.
/**
* Pops up the fact selector.
*/
protected void showFactTypeSelector() {
AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
final ListBox box = new ListBox();
String[] facts = oracle.getFactTypes();
box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
for (int i = 0; i < facts.length; i++) {
box.addItem(facts[i]);
}
box.setSelectedIndex(0);
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.show();
}
use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class PopupCreatorTest method testOnExpressionEditorButtonClick.
@Test
public void testOnExpressionEditorButtonClick() {
final String factType = "factType";
final FactPattern factPattern = mock(FactPattern.class);
final HasConstraints hasConstraints = mock(HasConstraints.class);
final FormStylePopup popup = mock(FormStylePopup.class);
final SingleFieldConstraintEBLeftSide constraint = mock(SingleFieldConstraintEBLeftSide.class);
final RuleModeller ruleModeller = mock(RuleModeller.class);
final ClickEvent clickEvent = mock(ClickEvent.class);
doReturn(factType).when(factPattern).getFactType();
doReturn(constraint).when(popupCreator).makeSingleFieldConstraintEBLeftSide(factType);
doReturn(ruleModeller).when(popupCreator).getModeller();
doReturn(factPattern).when(popupCreator).getPattern();
final ClickHandler clickHandler = popupCreator.onExpressionEditorButtonClick(hasConstraints, popup);
clickHandler.onClick(clickEvent);
verify(hasConstraints).addConstraint(constraint);
verify(ruleModeller).refreshWidget();
verify(popup).hide();
}
use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidget method showSourcePatternSelector.
/**
* Pops up the fact selector.
*/
protected void showSourcePatternSelector() {
final ListBox box = new ListBox();
AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
String[] facts = oracle.getFactTypes();
box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
for (int i = 0; i < facts.length; i++) {
box.addItem(facts[i]);
}
box.setSelectedIndex(0);
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
getFromAccumulatePattern().setSourcePattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
final Button fromBtn = new Button(HumanReadableConstants.INSTANCE.From());
final Button fromAccumulateBtn = new Button(HumanReadableConstants.INSTANCE.FromAccumulate());
final Button fromCollectBtn = new Button(HumanReadableConstants.INSTANCE.FromCollect());
final Button fromEntryPointBtn = new Button(HumanReadableConstants.INSTANCE.FromEntryPoint());
ClickHandler btnsClickHandler = new ClickHandler() {
public void onClick(ClickEvent event) {
Widget sender = (Widget) event.getSource();
if (sender == fromBtn) {
getFromAccumulatePattern().setSourcePattern(new FromCompositeFactPattern());
} else if (sender == fromAccumulateBtn) {
getFromAccumulatePattern().setSourcePattern(new FromAccumulateCompositeFactPattern());
} else if (sender == fromCollectBtn) {
getFromAccumulatePattern().setSourcePattern(new FromCollectCompositeFactPattern());
} else if (sender == fromEntryPointBtn) {
getFromAccumulatePattern().setSourcePattern(new FromEntryPointFactPattern());
} else {
throw new IllegalArgumentException("Unknown sender: " + sender);
}
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
};
fromBtn.addClickHandler(btnsClickHandler);
fromAccumulateBtn.addClickHandler(btnsClickHandler);
fromCollectBtn.addClickHandler(btnsClickHandler);
fromEntryPointBtn.addClickHandler(btnsClickHandler);
popup.addAttribute("", fromBtn);
popup.addAttribute("", fromAccumulateBtn);
popup.addAttribute("", fromCollectBtn);
popup.addAttribute("", fromEntryPointBtn);
popup.show();
}
use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidget method showFactTypeSelector.
/**
* Pops up the fact selector.
*/
@Override
protected void showFactTypeSelector() {
final ListBox box = GWT.create(ListBox.class);
AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
String[] facts = oracle.getFactTypes();
box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
for (int i = 0; i < facts.length; i++) {
box.addItem(facts[i]);
}
box.setSelectedIndex(0);
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.show();
}
use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class ActionValueEditor method showTypeChoice.
protected void showTypeChoice() {
final FormStylePopup form = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.FieldValue());
Button lit = new Button(GuidedRuleEditorResources.CONSTANTS.LiteralValue());
lit.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
value.setNature(FieldNatureType.TYPE_LITERAL);
value.setValue("");
doTypeChosen(form);
}
});
form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.LiteralValue(), GuidedRuleEditorResources.CONSTANTS.Literal(), GuidedRuleEditorResources.CONSTANTS.ALiteralValueMeansTheValueAsTypedInIeItsNotACalculation(), lit);
if (modeller.isTemplate()) {
Button templateButton = new Button(GuidedRuleEditorResources.CONSTANTS.TemplateKey());
templateButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
value.setNature(FieldNatureType.TYPE_TEMPLATE);
value.setValue("");
doTypeChosen(form);
}
});
form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKeyTip(), templateButton);
}
form.addRow(new HTML("<hr/>"));
form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedSection()));
Button formula = new Button(GuidedRuleEditorResources.CONSTANTS.Formula());
formula.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
value.setNature(FieldNatureType.TYPE_FORMULA);
doTypeChosen(form);
}
});
// If there is a bound Facts or Fields that are of the same type as the current variable type, then show a button
List<String> bindings = getApplicableBindings();
if (bindings.size() > 0) {
Button variable = new Button(GuidedRuleEditorResources.CONSTANTS.BoundVariable());
form.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable() + ":", variable);
variable.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
value.setNature(FieldNatureType.TYPE_VARIABLE);
value.setValue("=");
doTypeChosen(form);
}
});
}
form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.Formula(), GuidedRuleEditorResources.CONSTANTS.Formula(), GuidedRuleEditorResources.CONSTANTS.FormulaTip(), formula);
form.show();
}
Aggregations