use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class MethodParameterCallValueEditor method showTypeChoice.
protected void showTypeChoice(final Widget w) {
final FormStylePopup form = new FormStylePopup(TestScenarioAltedImages.INSTANCE.Wizard(), TestScenarioConstants.INSTANCE.FieldValue());
Button lit = new Button(TestScenarioConstants.INSTANCE.LiteralValue());
lit.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.nature = FieldData.TYPE_LITERAL;
methodParameter.value = " ";
refresh();
form.hide();
}
});
form.addAttribute(TestScenarioConstants.INSTANCE.LiteralValue() + ":", widgets(lit, new InfoPopup(TestScenarioConstants.INSTANCE.Literal(), TestScenarioConstants.INSTANCE.LiteralValTip())));
form.addRow(new HTML("<hr/>"));
form.addRow(new SmallLabel(TestScenarioConstants.INSTANCE.AdvancedSection()));
/*
* If there is a bound variable that is the same type of the current
* variable type, then show a button
*/
List<String> vars = model.getFactNamesInScope(ex, true);
for (String v : vars) {
boolean createButton = false;
Button variable = new Button(TestScenarioConstants.INSTANCE.BoundVariable());
FactData factData = (FactData) model.getFactTypes().get(v);
if (factData.getType().equals(this.parameterType)) {
createButton = true;
}
if (createButton == true) {
form.addAttribute(TestScenarioConstants.INSTANCE.BoundVariable() + ":", variable);
variable.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.nature = FieldData.TYPE_VARIABLE;
methodParameter.value = "=";
refresh();
form.hide();
}
});
break;
}
}
form.show();
}
use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class AddFieldClickHandler method onClick.
@Override
public void onClick(final ClickEvent event) {
final FormStylePopup pop = new FormStylePopup(TestScenarioConstants.INSTANCE.ChooseAFieldToAdd());
final FactFieldSelector selector = createAddNewField(pop);
pop.addAttribute(TestScenarioConstants.INSTANCE.ChooseAFieldToAdd(), selector);
pop.add(new ModalFooterOKCancelButtons(new Command() {
@Override
public void execute() {
SelectionEvent.fire(selector, selector.getSelectedText());
}
}, new Command() {
@Override
public void execute() {
pop.hide();
}
}));
pop.show();
}
use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class MethodParameterValueEditor method showTypeChoice.
protected void showTypeChoice() {
final FormStylePopup form = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.FieldValue());
// Literal values
Button lit = new Button(GuidedRuleEditorResources.CONSTANTS.LiteralValue());
lit.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.setNature(FieldNatureType.TYPE_LITERAL);
methodParameter.setValue("");
refresh();
form.hide();
}
});
form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.LiteralValue(), GuidedRuleEditorResources.CONSTANTS.LiteralValue(), GuidedRuleEditorResources.CONSTANTS.LiteralValTip(), lit);
if (modeller.isTemplate()) {
Button templateButton = new Button(GuidedRuleEditorResources.CONSTANTS.TemplateKey());
templateButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.setNature(FieldNatureType.TYPE_TEMPLATE);
methodParameter.setValue("");
refresh();
form.hide();
}
});
form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKeyTip(), templateButton);
}
canTheVariableButtonBeShown(new Callback<Boolean>() {
@Override
public void callback(Boolean result) {
if (result) {
addBoundVariableButton(form);
form.addRow(new HTML("<hr/>"));
form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedSection()));
}
// Formulas
Button formula = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
formula.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.setNature(FieldNatureType.TYPE_FORMULA);
refresh();
form.hide();
}
});
form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.AFormula(), GuidedRuleEditorResources.CONSTANTS.AFormula(), GuidedRuleEditorResources.CONSTANTS.FormulaExpressionTip(), formula);
form.show();
}
});
}
use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class ActionCallMethodWidget method showAddFieldPopup.
protected void showAddFieldPopup(Widget w) {
final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.ChooseAMethodToInvoke());
final ListBox box = new ListBox();
box.addItem("...");
for (int i = 0; i < fieldCompletionTexts.length; i++) {
box.addItem(fieldCompletionValues[i], fieldCompletionTexts[i]);
}
box.setSelectedIndex(0);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ChooseAMethodToInvoke(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
final String methodNameWithParams = box.getItemText(box.getSelectedIndex());
oracle.getMethodParams(variableClass, methodNameWithParams, new Callback<List<String>>() {
@Override
public void callback(final List<String> methodParameters) {
final String methodName = box.getValue(box.getSelectedIndex());
model.setMethodName(methodName);
model.setState(ActionCallMethod.TYPE_DEFINED);
for (String methodParameter : methodParameters) {
model.addFieldValue(new ActionFieldFunction(methodName, null, methodParameter));
}
getModeller().refreshWidget();
popup.hide();
}
});
}
});
popup.show();
}
use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.
the class ActionInsertFactWidget method showAddFieldPopup.
protected void showAddFieldPopup(Widget w) {
final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddAField());
final ListBox box = new ListBox();
box.addItem("...");
final ModelField[] availableFieldCompletions = ModelFieldUtil.getAvailableFieldCompletions(fieldCompletions, model);
final boolean isEnabled = !isReadOnly() && availableFieldCompletions.length > 0;
if (availableFieldCompletions.length > 0) {
for (int i = 0; i < availableFieldCompletions.length; i++) {
box.addItem(availableFieldCompletions[i].getName());
}
}
box.setSelectedIndex(0);
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddField(), box);
box.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String fieldName = box.getItemText(box.getSelectedIndex());
String fieldType = oracle.getFieldType(model.getFactType(), fieldName);
model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType));
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
/*
* Propose a textBox to the user to make him set a variable name
*/
final HorizontalPanel vn = new HorizontalPanel();
final TextBox varName = new TextBox();
if (this.model.getBoundName() != null) {
varName.setText(this.model.getBoundName());
}
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 (getModeller().isVariableNameUsed(var) && ((model.getBoundName() != null && model.getBoundName().equals(var) == false) || model.getBoundName() == null)) {
Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
return;
}
model.setBoundName(var);
setModified(true);
getModeller().refreshWidget();
popup.hide();
}
});
popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable(), vn);
box.setEnabled(isEnabled);
varName.setEnabled(isEnabled);
ok.setEnabled(isEnabled);
popup.show();
}
Aggregations