use of org.kie.workbench.common.widgets.client.widget.BindingTextBox in project drools-wb by kiegroup.
the class PopupCreator method doBindingEditor.
/**
* This adds in (optionally) the editor for changing the bound variable
* name. If its a bindable pattern, it will show the editor, if it is
* already bound, and the name is used, it should not be editable.
*/
private void doBindingEditor(final FormStylePopup popup) {
if (bindable || !(modeller.getModel().isBoundFactUsed(pattern.getBoundName()))) {
HorizontalPanel varName = new HorizontalPanel();
final TextBox varTxt = new BindingTextBox();
if (pattern.getBoundName() == null) {
varTxt.setText("");
} else {
varTxt.setText(pattern.getBoundName());
}
((InputElement) varTxt.getElement().cast()).setSize(6);
varName.add(varTxt);
Button bindVar = new Button(HumanReadableConstants.INSTANCE.Set());
bindVar.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String var = varTxt.getText();
if (modeller.isVariableNameUsed(var)) {
Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
return;
}
pattern.setBoundName(varTxt.getText());
modeller.refreshWidget();
popup.hide();
}
});
varName.add(bindVar);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.VariableName(), varName);
}
}
use of org.kie.workbench.common.widgets.client.widget.BindingTextBox in project drools-wb by kiegroup.
the class FieldPage method newBindingTextBox.
TextBox newBindingTextBox() {
final BindingTextBox bindingTextBox = GWT.create(BindingTextBox.class);
bindingTextBox.setText(plugin().getBinding());
bindingTextBox.addKeyUpHandler(event -> {
plugin().setBinding(bindingTextBox.getText());
});
return bindingTextBox;
}
use of org.kie.workbench.common.widgets.client.widget.BindingTextBox in project drools-wb by kiegroup.
the class PopupCreator method showBindFieldPopup.
/**
* Display a little editor for field bindings.
*/
public void showBindFieldPopup(final FactPattern fp, final SingleFieldConstraint con, final ModelField[] fields, final PopupCreator popupCreator) {
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.AddAField());
// popup.setWidth( 500 + "px" );
// popup.setHeight( 100 + "px" );
final HorizontalPanel vn = new HorizontalPanel();
final TextBox varName = new BindingTextBox();
if (con.getFieldBinding() != null) {
varName.setText(con.getFieldBinding());
}
final Button ok = new Button(HumanReadableConstants.INSTANCE.Set());
vn.add(varName);
vn.add(ok);
ok.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String var = varName.getText();
if (modeller.isVariableNameUsed(var)) {
Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
return;
}
con.setFieldBinding(var);
modeller.refreshWidget();
popup.hide();
}
});
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BindTheFieldCalled0ToAVariable(con.getFieldName()), vn);
// Show the sub-field selector is there are applicable sub-fields
if (hasApplicableFields(fields)) {
Button sub = new Button(GuidedRuleEditorResources.CONSTANTS.ShowSubFields());
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ApplyAConstraintToASubFieldOf0(con.getFieldName()), sub);
sub.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
popup.hide();
popupCreator.showPatternPopup(fp, con, true);
}
});
}
popup.show();
}
Aggregations