use of com.google.gwt.event.dom.client.ChangeEvent 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 com.google.gwt.event.dom.client.ChangeEvent 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;
}
use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.
the class MethodParameterValueEditor method boundVariable.
private ListBox boundVariable() {
BoundListBox boundListBox = new BoundListBox(modeller, methodParameter, new SuperTypeMatcher(oracle));
boundListBox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
ListBox w = (ListBox) event.getSource();
setMethodParameterValue(w.getValue(w.getSelectedIndex()));
refresh();
}
});
return boundListBox;
}
use of com.google.gwt.event.dom.client.ChangeEvent 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 com.google.gwt.event.dom.client.ChangeEvent 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();
}
Aggregations