use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.
the class FromCompositeFactPatternWidget method showFactTypeSelector.
/**
* Pops up the fact selector.
*/
protected void showFactTypeSelector() {
AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
final ListBox box = new ListBox();
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.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.show();
}
use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.
the class GuidedScoreCardEditor method getScorecardProperties.
private Widget getScorecardProperties() {
scorecardPropertiesGrid = new Grid(4, 4);
scorecardPropertiesGrid.setCellSpacing(5);
scorecardPropertiesGrid.setCellPadding(5);
tbInitialScore = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_DOUBLE);
tbInitialScore.setText(Double.toString(model.getInitialScore()));
String factName = model.getFactName();
// if fact is a fully qualified className, strip off the packageName
if (factName.lastIndexOf(".") > -1) {
factName = factName.substring(factName.lastIndexOf(".") + 1);
}
dropDownFacts.clear();
dropDownFacts.addItem(GuidedScoreCardConstants.INSTANCE.pleaseChoose());
final String[] eligibleFacts = oracle.getFactTypes();
for (final String factType : eligibleFacts) {
dropDownFacts.addItem(factType);
}
dropDownFacts.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(final ChangeEvent event) {
scoreCardPropertyFactChanged(dropDownFacts, dropDownFields);
}
});
final int selectedFactIndex = Arrays.asList(eligibleFacts).indexOf(factName);
dropDownFacts.setSelectedIndex(selectedFactIndex >= 0 ? selectedFactIndex + 1 : 0);
scoreCardPropertyFactChanged(dropDownFacts, dropDownFields);
// Reason Codes List Box
ddReasonCodeField = new ListBox();
getEligibleFields(factName, typesForRC, new Callback<String[]>() {
@Override
public void callback(final String[] eligibleReasonCodeFields) {
ddReasonCodeField.addItem(GuidedScoreCardConstants.INSTANCE.pleaseChoose());
ddReasonCodeField.setEnabled(eligibleReasonCodeFields.length > 0);
for (final String field : eligibleReasonCodeFields) {
ddReasonCodeField.addItem(field);
}
final String rcField = model.getReasonCodeField() + " : List";
final int selectedReasonCodeIndex = Arrays.asList(eligibleReasonCodeFields).indexOf(rcField);
ddReasonCodeField.setSelectedIndex(selectedReasonCodeIndex >= 0 ? selectedReasonCodeIndex : 0);
}
});
final boolean useReasonCodes = model.isUseReasonCodes();
final String reasonCodesAlgo = model.getReasonCodesAlgorithm();
ddUseReasonCode = booleanEditor(Boolean.toString(useReasonCodes));
ddReasonCodeAlgorithm = listBoxEditor(reasonCodeAlgorithms, reasonCodesAlgo, true);
tbBaselineScore = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_DOUBLE);
scorecardPropertiesGrid.setText(0, 0, GuidedScoreCardConstants.INSTANCE.facts());
scorecardPropertiesGrid.setText(0, 1, GuidedScoreCardConstants.INSTANCE.resultantScoreField());
scorecardPropertiesGrid.setText(0, 2, GuidedScoreCardConstants.INSTANCE.initialScore());
scorecardPropertiesGrid.setWidget(1, 0, dropDownFacts);
scorecardPropertiesGrid.setWidget(1, 1, dropDownFields);
scorecardPropertiesGrid.setWidget(1, 2, tbInitialScore);
scorecardPropertiesGrid.setText(2, 0, GuidedScoreCardConstants.INSTANCE.useReasonCodes());
scorecardPropertiesGrid.setText(2, 1, GuidedScoreCardConstants.INSTANCE.resultantReasonCodesField());
scorecardPropertiesGrid.setText(2, 2, GuidedScoreCardConstants.INSTANCE.reasonCodesAlgorithm());
scorecardPropertiesGrid.setText(2, 3, GuidedScoreCardConstants.INSTANCE.baselineScore());
scorecardPropertiesGrid.setWidget(3, 0, ddUseReasonCode);
scorecardPropertiesGrid.setWidget(3, 1, ddReasonCodeField);
scorecardPropertiesGrid.setWidget(3, 2, ddReasonCodeAlgorithm);
scorecardPropertiesGrid.setWidget(3, 3, tbBaselineScore);
/* TODO : Remove this explicitly Disabled Reasoncode support field*/
ddUseReasonCode.setEnabled(false);
ddReasonCodeField.setEnabled(false);
tbBaselineScore.setText(Double.toString(model.getBaselineScore()));
scorecardPropertiesGrid.getCellFormatter().setWidth(0, 0, "200px");
scorecardPropertiesGrid.getCellFormatter().setWidth(0, 1, "250px");
scorecardPropertiesGrid.getCellFormatter().setWidth(0, 2, "200px");
scorecardPropertiesGrid.getCellFormatter().setWidth(0, 3, "200px");
return scorecardPropertiesGrid;
}
use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.
the class FactPatternWidget method predicateEditor.
/**
* This provides an inline formula editor, not unlike a spreadsheet does.
*/
private Widget predicateEditor(final SingleFieldConstraint c) {
HorizontalPanel pred = new HorizontalPanel();
pred.setWidth("100%");
Image img = new Image(GuidedRuleEditorResources.INSTANCE.images().functionAssets());
img.setTitle(GuidedRuleEditorResources.CONSTANTS.FormulaBooleanTip());
pred.add(img);
if (c.getValue() == null) {
c.setValue("");
}
final TextBox box = new TextBox();
box.setText(c.getValue());
if (!this.readOnly) {
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
setModified(true);
c.setValue(box.getText());
}
});
box.setWidth("100%");
pred.add(box);
} else {
pred.add(new SmallLabel(c.getValue()));
}
return pred;
}
use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidget method showSourcePatternSelector.
/**
* Pops up the fact selector.
*/
protected void showSourcePatternSelector() {
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) {
getFromAccumulatePattern().setSourcePattern(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());
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) {
getFromAccumulatePattern().setSourcePattern(new FromCompositeFactPattern());
} else if (sender == fromAccumulateBtn) {
getFromAccumulatePattern().setSourcePattern(new FromAccumulateCompositeFactPattern());
} else if (sender == fromCollectBtn) {
getFromAccumulatePattern().setSourcePattern(new FromCollectCompositeFactPattern());
} else if (sender == fromEntryPointBtn) {
getFromAccumulatePattern().setSourcePattern(new FromEntryPointFactPattern());
} else {
throw new IllegalArgumentException("Unknown sender: " + sender);
}
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
};
fromBtn.addClickHandler(btnsClickHandler);
fromAccumulateBtn.addClickHandler(btnsClickHandler);
fromCollectBtn.addClickHandler(btnsClickHandler);
fromEntryPointBtn.addClickHandler(btnsClickHandler);
popup.addAttribute("", fromBtn);
popup.addAttribute("", fromAccumulateBtn);
popup.addAttribute("", fromCollectBtn);
popup.addAttribute("", fromEntryPointBtn);
popup.show();
}
use of com.google.gwt.event.dom.client.ChangeEvent in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidget method showFactTypeSelector.
/**
* Pops up the fact selector.
*/
@Override
protected void showFactTypeSelector() {
final ListBox box = GWT.create(ListBox.class);
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.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.show();
}
Aggregations