use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class RuleAttributeWidget method textBoxEditor.
private TextBox textBoxEditor(final RuleMetadata rm, final boolean isReadOnly) {
final TextBox box = new TextBox();
box.setEnabled(!isReadOnly);
((InputElement) box.getElement().cast()).setSize((rm.getValue().length() < 3) ? 3 : rm.getValue().length());
box.setText(rm.getValue());
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
rm.setValue(box.getText());
}
});
box.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
((InputElement) box.getElement().cast()).setSize(box.getText().length());
}
});
return box;
}
use of org.gwtbootstrap3.client.ui.TextBox 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();
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class FieldPageTest method testSetupBindingWhenItIsNotBindable.
@Test
public void testSetupBindingWhenItIsNotBindable() {
final TextBox textBox = mock(TextBox.class);
final boolean isBindable = false;
doReturn(isBindable).when(plugin).isBindable();
doReturn(textBox).when(page).newBindingTextBox();
page.setupBinding();
verify(view, never()).setupBinding(textBox);
verify(view).bindingToggle(isBindable);
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class FieldPageTest method testSetupBindingWhenItIsBindable.
@Test
public void testSetupBindingWhenItIsBindable() {
final TextBox textBox = mock(TextBox.class);
final boolean isBindable = true;
doReturn(isBindable).when(plugin).isBindable();
doReturn(textBox).when(page).newBindingTextBox();
page.setupBinding();
verify(view).setupBinding(textBox);
verify(view).bindingToggle(isBindable);
}
use of org.gwtbootstrap3.client.ui.TextBox in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidget method getCompositeLabel.
@Override
protected Widget getCompositeLabel() {
ClickHandler leftPatternclick = new ClickHandler() {
public void onClick(ClickEvent event) {
showFactTypeSelector();
}
};
ClickHandler sourcePatternClick = new ClickHandler() {
public void onClick(ClickEvent event) {
showSourcePatternSelector();
}
};
String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from accumulate") + "</div>";
FlexTable panel = new FlexTable();
int r = 0;
if (pattern.getFactPattern() == null) {
panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPattern() + "</font>", leftPatternclick, !this.readOnly));
}
panel.setWidget(r++, 0, new HTML(lbl));
if (this.getFromAccumulatePattern().getSourcePattern() == null) {
panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPattern() + "</font>", sourcePatternClick, !this.readOnly));
} else {
IPattern rPattern = this.getFromAccumulatePattern().getSourcePattern();
RuleModellerWidget sourcePatternWidget;
if (rPattern instanceof FactPattern) {
sourcePatternWidget = new FactPatternWidget(this.getModeller(), getEventBus(), rPattern, true, true, this.readOnly);
} else if (rPattern instanceof FromAccumulateCompositeFactPattern) {
sourcePatternWidget = new FromAccumulateCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromAccumulateCompositeFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FromCollectCompositeFactPattern) {
sourcePatternWidget = new FromCollectCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCollectCompositeFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FromEntryPointFactPattern) {
sourcePatternWidget = new FromEntryPointFactPatternWidget(this.getModeller(), this.getEventBus(), (FromEntryPointFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FromCompositeFactPattern) {
sourcePatternWidget = new FromCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCompositeFactPattern) rPattern, this.readOnly);
} else {
throw new IllegalArgumentException("Unsupported pattern " + rPattern + " for right side of FROM ACCUMULATE");
}
sourcePatternWidget.addOnModifiedCommand(new Command() {
public void execute() {
setModified(true);
}
});
panel.setWidget(r++, 0, addRemoveButton(sourcePatternWidget, new ClickHandler() {
public void onClick(ClickEvent event) {
if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisBlockOfData())) {
setModified(true);
getFromAccumulatePattern().setSourcePattern(null);
getModeller().refreshWidget();
}
}
}));
}
final TabPanel tPanel = new TabPanel() {
{
addStyleName("uf-tabbar-panel");
}
};
final NavTabs navTabs = new NavTabs() {
{
addStyleName("uf-tabbar-panel-nav-tabs");
addStyleName("nav-tabs-pf");
}
};
final TabContent content = new TabContent();
tPanel.add(navTabs);
tPanel.add(content);
FlexTable codeTable = new FlexTable();
int codeTableRow = 0;
int codeTableCol = 0;
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Init() + ":</div>"));
final TextBox initField = new TextBox();
initField.setTitle(GuidedRuleEditorResources.CONSTANTS.InitCode());
initField.setText(getFromAccumulatePattern().getInitCode());
initField.setEnabled(!this.readOnly);
codeTable.setWidget(codeTableRow++, codeTableCol--, initField);
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Action() + ":</div>"));
final TextBox actionField = new TextBox();
actionField.setTitle(GuidedRuleEditorResources.CONSTANTS.ActionCode());
actionField.setText(getFromAccumulatePattern().getActionCode());
actionField.setEnabled(!this.readOnly);
codeTable.setWidget(codeTableRow++, codeTableCol--, actionField);
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Reverse() + ":</div>"));
final TextBox reverseField = new TextBox();
reverseField.setTitle(GuidedRuleEditorResources.CONSTANTS.ReverseCode());
reverseField.setText(getFromAccumulatePattern().getReverseCode());
reverseField.setEnabled(!this.readOnly);
codeTable.setWidget(codeTableRow++, codeTableCol--, reverseField);
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Result() + ":</div>"));
final TextBox resultField = new TextBox();
resultField.setTitle(GuidedRuleEditorResources.CONSTANTS.ResultCode());
resultField.setText(getFromAccumulatePattern().getResultCode());
resultField.setEnabled(!this.readOnly);
codeTable.setWidget(codeTableRow++, codeTableCol--, resultField);
// panel.setWidget(r++, 0, codeTable);
final ScrollPanel codePanel = new ScrollPanel();
codePanel.add(codeTable);
final TabPane codeTabPane = new TabPane() {
{
add(codePanel);
}
};
final TabListItem codeTabListItem = new TabListItem(GuidedRuleEditorResources.CONSTANTS.CustomCode()) {
{
addStyleName("uf-dropdown-tab-list-item");
setDataTargetWidget(codeTabPane);
getElement().getStyle().setFontSize(12, Style.Unit.PX);
}
};
navTabs.add(codeTabListItem);
content.add(codeTabPane);
FlexTable functionTable = new FlexTable();
functionTable.setWidget(0, 0, new HTML("<div class='form-field'>" + GuidedRuleEditorResources.CONSTANTS.Function() + ":</div>"));
final TextBox functionField = new TextBox();
functionField.setTitle(GuidedRuleEditorResources.CONSTANTS.FunctionCode());
functionField.setText(getFromAccumulatePattern().getFunction());
functionField.setEnabled(!this.readOnly);
functionTable.setWidget(0, 1, functionField);
// panel.setWidget(r++, 0, functionTable);
final ScrollPanel functionPanel = new ScrollPanel();
functionPanel.add(functionTable);
final TabPane functionTabPane = new TabPane() {
{
add(functionPanel);
}
};
final TabListItem functionTabListItem = new TabListItem(GuidedRuleEditorResources.CONSTANTS.Function()) {
{
addStyleName("uf-dropdown-tab-list-item");
setDataTargetWidget(functionTabPane);
getElement().getStyle().setFontSize(12, Style.Unit.PX);
}
};
navTabs.add(functionTabListItem);
content.add(functionTabPane);
ChangeHandler changehandler = new ChangeHandler() {
public void onChange(ChangeEvent event) {
Widget sender = (Widget) event.getSource();
TextBox senderTB = (TextBox) event.getSource();
String code = senderTB.getText();
setModified(true);
if (sender == initField) {
getFromAccumulatePattern().setFunction(null);
functionField.setText("");
getFromAccumulatePattern().setInitCode(code);
} else if (sender == actionField) {
getFromAccumulatePattern().setFunction(null);
functionField.setText("");
getFromAccumulatePattern().setActionCode(code);
} else if (sender == reverseField) {
getFromAccumulatePattern().setFunction(null);
functionField.setText("");
getFromAccumulatePattern().setReverseCode(code);
} else if (sender == resultField) {
getFromAccumulatePattern().setFunction(null);
functionField.setText("");
getFromAccumulatePattern().setResultCode(code);
} else if (sender == functionField) {
getFromAccumulatePattern().clearCodeFields();
initField.setText("");
actionField.setText("");
reverseField.setText("");
resultField.setText("");
getFromAccumulatePattern().setFunction(code);
}
}
};
initField.addChangeHandler(changehandler);
actionField.addChangeHandler(changehandler);
reverseField.addChangeHandler(changehandler);
resultField.addChangeHandler(changehandler);
functionField.addChangeHandler(changehandler);
boolean useFunction = getFromAccumulatePattern().useFunctionOrCode().equals(FromAccumulateCompositeFactPattern.USE_FUNCTION);
if (useFunction) {
functionTabListItem.setActive(true);
functionTabPane.setActive(true);
} else {
codeTabListItem.setActive(true);
codeTabPane.setActive(true);
}
panel.setWidget(r++, 0, tPanel);
return panel;
}
Aggregations