use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.
the class PopupCreator method showPatternPopupForComposite.
/**
* This shows a popup for adding fields to a composite
*/
public void showPatternPopupForComposite(final HasConstraints hasConstraints) {
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddFieldsToThisConstraint());
final ListBox box = new ListBox();
box.addItem("...");
this.oracle.getFieldCompletions(this.pattern.getFactType(), new Callback<ModelField[]>() {
@Override
public void callback(final ModelField[] fields) {
for (int i = 0; i < fields.length; i++) {
final String fieldName = fields[i].getName();
box.addItem(fieldName);
}
}
});
box.setSelectedIndex(0);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String factType = pattern.getFactType();
String fieldName = box.getItemText(box.getSelectedIndex());
String fieldType = getDataModelOracle().getFieldType(factType, fieldName);
hasConstraints.addConstraint(new SingleFieldConstraint(factType, fieldName, fieldType, null));
modeller.refreshWidget();
popup.hide();
}
});
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddARestrictionOnAField(), box);
final ListBox composites = new ListBox();
// NON-NLS
composites.addItem("...");
composites.addItem(GuidedRuleEditorResources.CONSTANTS.AllOfAnd(), CompositeFieldConstraint.COMPOSITE_TYPE_AND);
composites.addItem(GuidedRuleEditorResources.CONSTANTS.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR);
composites.setSelectedIndex(0);
composites.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
CompositeFieldConstraint comp = new CompositeFieldConstraint();
comp.setCompositeJunctionType(composites.getValue(composites.getSelectedIndex()));
hasConstraints.addConstraint(comp);
modeller.refreshWidget();
popup.hide();
}
});
InfoPopup infoComp = new InfoPopup(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraints(), GuidedRuleEditorResources.CONSTANTS.MultipleConstraintsTip());
HorizontalPanel horiz = new HorizontalPanel();
horiz.add(composites);
horiz.add(infoComp);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraint(), horiz);
// Include Expression Editor
popup.addRow(new SmallLabel("<i>" + GuidedRuleEditorResources.CONSTANTS.AdvancedOptionsColon() + "</i>"));
Button predicate = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
predicate.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
SingleFieldConstraint con = new SingleFieldConstraint();
con.setConstraintValueType(SingleFieldConstraint.TYPE_PREDICATE);
hasConstraints.addConstraint(con);
modeller.refreshWidget();
popup.hide();
}
});
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddANewFormulaStyleExpression(), predicate);
final Button expressionEditorButton = makeExpressionEditorButton(hasConstraints, popup);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), expressionEditorButton);
popup.show();
}
use of org.gwtbootstrap3.client.ui.Button 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.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.
the class ActionInsertFactWidget method showAddFieldPopup.
protected void showAddFieldPopup(Widget w) {
final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddAField());
final ListBox box = new ListBox();
box.addItem("...");
final ModelField[] availableFieldCompletions = ModelFieldUtil.getAvailableFieldCompletions(fieldCompletions, model);
final boolean isEnabled = !isReadOnly() && availableFieldCompletions.length > 0;
if (availableFieldCompletions.length > 0) {
for (int i = 0; i < availableFieldCompletions.length; i++) {
box.addItem(availableFieldCompletions[i].getName());
}
}
box.setSelectedIndex(0);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddField(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String fieldName = box.getItemText(box.getSelectedIndex());
String fieldType = oracle.getFieldType(model.getFactType(), fieldName);
model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
/*
* Propose a textBox to the user to make him set a variable name
*/
final HorizontalPanel vn = new HorizontalPanel();
final TextBox varName = new TextBox();
if (this.model.getBoundName() != null) {
varName.setText(this.model.getBoundName());
}
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 (getModeller().isVariableNameUsed(var) && ((model.getBoundName() != null && model.getBoundName().equals(var) == false) || model.getBoundName() == null)) {
Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
return;
}
model.setBoundName(var);
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable(), vn);
box.setEnabled(isEnabled);
varName.setEnabled(isEnabled);
ok.setEnabled(isEnabled);
popup.show();
}
use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.
the class ExpressionBuilder method showBindingPopUp.
private void showBindingPopUp() {
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor());
final TextBox varName = new TextBox();
if (expression.isBound()) {
varName.setText(expression.getBinding());
}
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BindTheExpressionToAVariable(), new InputGroup() {
{
add(varName);
add(new InputGroupButton() {
{
add(new Button(HumanReadableConstants.INSTANCE.Set()) {
{
addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String var = varName.getText();
if (getModeller().isVariableNameUsed(var)) {
Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
return;
}
expression.setBinding(var);
getModeller().refreshWidget();
popup.hide();
}
});
}
});
}
});
}
});
popup.show();
}
use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.
the class GuidedScoreCardEditor method getCharacteristics.
private Widget getCharacteristics() {
characteristicsPanel = new VerticalPanel();
characteristicsTables = new ArrayList<FlexTable>();
final HorizontalPanel toolbar = new HorizontalPanel();
btnAddCharacteristic = new Button(GuidedScoreCardConstants.INSTANCE.addCharacteristic(), new ClickHandler() {
public void onClick(ClickEvent event) {
addCharacteristic(null);
}
});
toolbar.add(btnAddCharacteristic);
toolbar.setHeight("24");
characteristicsPanel.add(toolbar);
final SimplePanel gapPanel = new SimplePanel();
gapPanel.add(new HTML("<br/>"));
characteristicsPanel.add(gapPanel);
return characteristicsPanel;
}
Aggregations