use of org.gwtbootstrap3.client.ui.ListBox in project drools-wb by kiegroup.
the class CompositeFactPatternWidget method showFactTypeSelector.
/**
* Pops up the fact selector.
*/
protected void showFactTypeSelector(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) {
pattern.addFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
final Button fromBtn = new Button(HumanReadableConstants.INSTANCE.From());
final Button fromAccumulateBtn = new Button(HumanReadableConstants.INSTANCE.FromAccumulate());
final Button fromCollectBtn = new Button(HumanReadableConstants.INSTANCE.FromCollect());
ClickHandler btnsClickHandler = new ClickHandler() {
public void onClick(ClickEvent event) {
Widget sender = (Widget) event.getSource();
if (sender == fromBtn) {
pattern.addFactPattern(new FromCompositeFactPattern());
} else if (sender == fromAccumulateBtn) {
pattern.addFactPattern(new FromAccumulateCompositeFactPattern());
} else if (sender == fromCollectBtn) {
pattern.addFactPattern(new FromCollectCompositeFactPattern());
} else {
throw new IllegalArgumentException("Unknown sender: " + sender);
}
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
};
fromBtn.addClickHandler(btnsClickHandler);
fromAccumulateBtn.addClickHandler(btnsClickHandler);
fromCollectBtn.addClickHandler(btnsClickHandler);
popup.addAttribute("", fromBtn);
popup.addAttribute("", fromAccumulateBtn);
popup.addAttribute("", fromCollectBtn);
popup.show();
}
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 RuleAttributeWidget method getEditorWidget.
private Widget getEditorWidget(final RuleAttribute at, final int idx, final boolean isReadOnly) {
Widget editor = null;
final EditAttributeWidgetFactory editAttributeWidgetFactory = new EditAttributeWidgetFactory(isReadOnly);
final String attributeName = at.getAttributeName();
if (attributeName.equals(Attribute.DIALECT.getAttributeName())) {
final ListBox lb = new ListBox();
lb.addItem(DIALECTS.get(0));
lb.addItem(DIALECTS.get(1));
lb.setEnabled(!isReadOnly);
if (!isReadOnly) {
lb.addChangeHandler(event -> {
final int selectedIndex = lb.getSelectedIndex();
if (selectedIndex < 0) {
return;
}
at.setValue(lb.getValue(selectedIndex));
});
}
if (at.getValue() == null || at.getValue().isEmpty()) {
lb.setSelectedIndex(1);
at.setValue(DIALECTS.get(1));
} else if (at.getValue().equals(DIALECTS.get(0))) {
lb.setSelectedIndex(0);
} else if (at.getValue().equals(DIALECTS.get(1))) {
lb.setSelectedIndex(1);
} else {
lb.setSelectedIndex(1);
at.setValue(DIALECTS.get(1));
}
editor = lb;
} else if (Objects.equals(DataType.TYPE_STRING, Attribute.getAttributeDataType(attributeName))) {
editor = editAttributeWidgetFactory.textBox(at, DataType.TYPE_STRING);
} else if (Objects.equals(DataType.TYPE_NUMERIC_INTEGER, Attribute.getAttributeDataType(attributeName))) {
editor = editAttributeWidgetFactory.textBox(at, DataType.TYPE_NUMERIC_INTEGER);
} else if (Objects.equals(DataType.TYPE_NUMERIC_LONG, Attribute.getAttributeDataType(attributeName))) {
editor = editAttributeWidgetFactory.textBox(at, DataType.TYPE_NUMERIC_LONG);
} else if (Objects.equals(DataType.TYPE_BOOLEAN, Attribute.getAttributeDataType(attributeName))) {
editor = checkBoxEditor(at, isReadOnly);
} else if (Objects.equals(DataType.TYPE_DATE, Attribute.getAttributeDataType(attributeName))) {
if (isReadOnly) {
editor = editAttributeWidgetFactory.textBox(at, DataType.TYPE_STRING);
} else {
editor = editAttributeWidgetFactory.datePicker(at, false);
}
}
DirtyableHorizontalPane horiz = GWT.create(DirtyableHorizontalPane.class);
if (editor != null) {
horiz.add(editor);
if (!isReadOnly) {
horiz.add(getRemoveIcon(idx));
}
}
return horiz;
}
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;
}
Aggregations