use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.
the class FromCollectCompositeFactPatternWidget method showFactTypeSelector.
@Override
protected void showFactTypeSelector() {
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
popup.setTitle(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
final ListBox box = GWT.create(ListBox.class);
box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
for (Map.Entry<String, String> entry : this.getExtraLeftSidePatternFactTypes().entrySet()) {
box.addItem(entry.getKey(), entry.getValue());
}
box.setSelectedIndex(0);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
pattern.setFactPattern(new FactPattern(box.getValue(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
popup.show();
}
use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.
the class FromCollectCompositeFactPatternWidget method showRightPatternSelector.
/**
* Pops up the fact selector.
*/
protected void showRightPatternSelector(final Widget w) {
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) {
getFromCollectPattern().setRightPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
final Button freeFormDRLBtn = new Button(GuidedRuleEditorResources.CONSTANTS.FreeFormDrl());
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) {
getFromCollectPattern().setRightPattern(new FromCompositeFactPattern());
} else if (sender == fromAccumulateBtn) {
getFromCollectPattern().setRightPattern(new FromAccumulateCompositeFactPattern());
} else if (sender == fromCollectBtn) {
getFromCollectPattern().setRightPattern(new FromCollectCompositeFactPattern());
} else if (sender == freeFormDRLBtn) {
getFromCollectPattern().setRightPattern(new FreeFormLine());
} else if (sender == fromEntryPointBtn) {
getFromCollectPattern().setRightPattern(new FromEntryPointFactPattern());
} else {
throw new IllegalArgumentException("Unknown sender: " + sender);
}
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
};
freeFormDRLBtn.addClickHandler(btnsClickHandler);
fromBtn.addClickHandler(btnsClickHandler);
fromAccumulateBtn.addClickHandler(btnsClickHandler);
fromCollectBtn.addClickHandler(btnsClickHandler);
fromEntryPointBtn.addClickHandler(btnsClickHandler);
popup.addAttribute("", freeFormDRLBtn);
popup.addAttribute("", fromBtn);
popup.addAttribute("", fromAccumulateBtn);
popup.addAttribute("", fromCollectBtn);
popup.addAttribute("", fromEntryPointBtn);
popup.show();
}
use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.
the class RuleModellerActionSelectorPopup method makeChoicesListBox.
private ListBox makeChoicesListBox(final String filter) {
choices = GWT.create(ListBox.class);
choices.setMultipleSelect(true);
choices.setPixelSize(getChoicesWidth(), getChoicesHeight());
choices.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(com.google.gwt.event.dom.client.KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
selectSomething();
}
}
});
final Predicate<String> predicate = (item) -> item.toLowerCase().contains(Objects.isNull(filter) ? "" : filter.toLowerCase());
boolean itemsAdded = addDSLSentences(predicate);
if (!onlyShowDSLStatements) {
itemsAdded = addUpdateNotModify(itemsAdded) || itemsAdded;
itemsAdded = addGlobals(itemsAdded) || itemsAdded;
itemsAdded = addRetractions(itemsAdded) || itemsAdded;
itemsAdded = addModifies(itemsAdded) || itemsAdded;
itemsAdded = addInsertions(predicate, itemsAdded) || itemsAdded;
itemsAdded = addLogicalInsertions(predicate, itemsAdded) || itemsAdded;
itemsAdded = addGlobalCollections(itemsAdded) || itemsAdded;
itemsAdded = addFreeFormDRL(itemsAdded) || itemsAdded;
itemsAdded = addCallMethodOn(itemsAdded) || itemsAdded;
addCustomActionPlugins(itemsAdded);
}
return choices;
}
use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.
the class ActionValueEditor method boundVariable.
private Widget boundVariable() {
// If there is a bound variable that is the same type of the current variable type, then display a list
ListBox listVariable = new ListBox();
listVariable.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
List<String> bindings = getApplicableBindings();
for (String v : bindings) {
listVariable.addItem(v);
}
// Pre-select applicable item
if (value.getValue().equals("=")) {
listVariable.setSelectedIndex(0);
} else {
for (int i = 0; i < listVariable.getItemCount(); i++) {
if (listVariable.getItemText(i).equals(value.getValue().substring(1))) {
listVariable.setSelectedIndex(i);
}
}
}
// Add event handler
if (listVariable.getItemCount() > 0) {
listVariable.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
ListBox w = (ListBox) event.getSource();
value.setValue("=" + w.getValue(w.getSelectedIndex()));
executeOnChangeCommand();
refresh();
}
});
}
if (this.readOnly) {
return new SmallLabel(listVariable.getItemText(listVariable.getSelectedIndex()));
}
return listVariable;
}
use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.
the class CEPOperatorsDropdown method getDropDown.
// Actual drop-down
private Widget getDropDown() {
String selected = "";
String selectedText = "";
box = new ListBox();
for (int i = 0; i < operators.length; i++) {
String op = operators[i];
box.addItem(HumanReadable.getOperatorDisplayName(op), op);
if (op.equals(hop.getOperator())) {
selected = op;
selectedText = HumanReadable.getOperatorDisplayName(op);
box.setSelectedIndex(i);
}
}
// Fire event to ensure parent Widgets correct their state depending on selection
final HasValueChangeHandlers<OperatorSelection> source = this;
final OperatorSelection selection = new OperatorSelection(selected, selectedText);
Scheduler.get().scheduleFinally(new Command() {
public void execute() {
operatorChanged(selection);
ValueChangeEvent.fire(source, selection);
}
});
// Signal parent Widget whenever a change happens
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String selected = box.getValue(box.getSelectedIndex());
String selectedText = box.getItemText(box.getSelectedIndex());
OperatorSelection selection = new OperatorSelection(selected, selectedText);
operatorChanged(selection);
ValueChangeEvent.fire(source, selection);
}
});
return box;
}
Aggregations