use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class FromEntryPointFactPatternWidget method getCompositeLabel.
@Override
protected Widget getCompositeLabel() {
ClickHandler click = new ClickHandler() {
public void onClick(ClickEvent event) {
showFactTypeSelector();
}
};
String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from entry-point") + "</div>";
FlexTable panel = new FlexTable();
int r = 0;
if (pattern.getFactPattern() == null) {
panel.setWidget(r, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", click, !this.readOnly));
r++;
}
panel.setWidget(r, 0, new HTML(lbl));
this.txtEntryPoint = new TextBox();
this.txtEntryPoint.setText(getFromEntryPointPattern().getEntryPointName());
this.txtEntryPoint.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
getFromEntryPointPattern().setEntryPointName(txtEntryPoint.getText());
setModified(true);
}
});
panel.setWidget(r, 1, this.txtEntryPoint);
return panel;
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class ExpressionBuilder method createWidgetForExpression.
// Render Widgets for the Expression. ExpressionMethodParameter and ExpressionText parts
// are represented by a TextBox to allow the User to edit the values, Updates are
// reflected in the model.
private Widget createWidgetForExpression() {
final HorizontalPanel container = new HorizontalPanel();
container.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
container.setStylePrimaryName(GuidedRuleEditorResources.INSTANCE.css().container());
for (ExpressionPart expressionPart : expression.getParts()) {
if (expressionPart instanceof ExpressionUnboundFact) {
continue;
} else if (this.readOnly) {
container.add(new Label(expressionPart.getName()));
} else if (expressionPart instanceof ExpressionMethod) {
container.add(new Label(expressionPart.getName()));
container.add(new Label("("));
final ExpressionMethod em = (ExpressionMethod) expressionPart;
final List<ExpressionFormLine> emParams = em.getOrderedParams();
for (int index = 0; index < emParams.size(); index++) {
final ExpressionFormLine paramValueHolder = emParams.get(index);
final String paramDataType = em.getParameterDataType(paramValueHolder);
final ExpressionMethodParameter paramValue = ((ExpressionMethodParameter) paramValueHolder.getRootExpression());
final TextBox paramValueEditor = TextBoxFactory.getTextBox(paramDataType);
paramValueEditor.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
paramValue.setText(event.getValue());
}
});
paramValueEditor.setText(paramValue.getName());
container.add(paramValueEditor);
if (index < emParams.size() - 1) {
container.add(new Label(", "));
}
}
container.add(new Label(")"));
} else if (!(expressionPart instanceof ExpressionText)) {
container.add(new Label(expressionPart.getName()));
} else {
final TextBox tb = new TextBox();
final ExpressionText expressionTextPart = (ExpressionText) expressionPart;
tb.setText(expressionTextPart.getName());
tb.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(final ChangeEvent changeEvent) {
expressionTextPart.setText(tb.getText());
}
});
container.add(tb);
}
container.add(new Label("."));
}
return container;
}
use of org.gwtbootstrap3.client.ui.TextBox 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.TextBox in project drools-wb by kiegroup.
the class ConstraintValueEditorTest method defaultTextBoxHasHandlersAttachedInCorrectOrder.
@Test
public void defaultTextBoxHasHandlersAttachedInCorrectOrder() {
final TextBox defaultTextBox = mock(TextBox.class);
final ConstraintValueEditor editor = spy(createEditor(constraint));
final InOrder inOrder = inOrder(editor);
doReturn(defaultTextBox).when(editor).getDefaultTextBox(any(String.class));
editor.getNewTextBox(DataType.TYPE_STRING);
inOrder.verify(editor).setUpTextBoxStyleAndHandlers(eq(defaultTextBox), any(Command.class));
verify(defaultTextBox, times(1)).setText(any(String.class));
inOrder.verify(editor).attachDisplayLengthHandler(eq(defaultTextBox));
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class GuidedScoreCardEditor method getCharacteristicFromTable.
private Characteristic getCharacteristicFromTable(FlexTable flexTable) {
ListBox enumDropDown;
final Characteristic characteristic = new Characteristic();
characteristic.setName(((TextBox) flexTable.getWidget(0, 1)).getValue());
// Characteristic Fact Type
enumDropDown = (ListBox) flexTable.getWidget(2, 0);
if (enumDropDown.getSelectedIndex() > -1) {
final String simpleFactName = enumDropDown.getValue(enumDropDown.getSelectedIndex());
characteristic.setFact(simpleFactName);
oracle.getFieldCompletions(simpleFactName, new Callback<ModelField[]>() {
@Override
public void callback(final ModelField[] fields) {
if (fields != null) {
for (ModelField mf : fields) {
if (mf.getType().equals(simpleFactName)) {
characteristic.setFact(mf.getClassName());
break;
}
}
}
}
});
// Characteristic Field (cannot be set if no Fact Type has been set)
enumDropDown = (ListBox) flexTable.getWidget(2, 1);
if (enumDropDown.getSelectedIndex() > -1) {
String fieldName = enumDropDown.getValue(enumDropDown.getSelectedIndex());
fieldName = fieldName.substring(0, fieldName.indexOf(":")).trim();
characteristic.setField(fieldName);
} else {
characteristic.setField("");
}
getDataTypeForField(simpleFactName, characteristic.getField(), new Callback<String>() {
@Override
public void callback(final String result) {
characteristic.setDataType(result);
}
});
}
// Characteristic Reason Code
characteristic.setReasonCode(((TextBox) flexTable.getWidget(2, 3)).getValue());
// Characteristic Base Line Score
final String baselineScore = ((TextBox) flexTable.getWidget(2, 2)).getValue();
try {
characteristic.setBaselineScore(Double.parseDouble(baselineScore));
} catch (Exception e) {
characteristic.setBaselineScore(0.0d);
}
return characteristic;
}
Aggregations