use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.
the class FactPatternWidget method fieldLabel.
/**
* get the field widget. This may be a simple label, or it may be bound (and
* show the var name) or a icon to create a binding. It will only show the
* binding option of showBinding is true.
*/
private Widget fieldLabel(final SingleFieldConstraint con, final HasConstraints hasConstraints, final boolean showBinding, final int padding) {
HorizontalPanel ab = new HorizontalPanel();
ab.setStyleName("modeller-field-Label");
StringBuilder bindingLabel = new StringBuilder();
if (con.isBound()) {
bindingLabel.append("<b>[");
bindingLabel.append(con.getFieldBinding());
bindingLabel.append("]</b> ");
}
String fieldName = con.getFieldName();
bindingLabel.append(fieldName);
if (bindable && showBinding && !this.readOnly) {
ClickHandler click = new ClickHandler() {
public void onClick(final ClickEvent event) {
// If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type
String fieldName = con.getFieldName();
if (DataType.TYPE_THIS.equals(fieldName)) {
getConnectives().getDataModelOracle().getFieldCompletions(pattern.getFactType(), new Callback<ModelField[]>() {
@Override
public void callback(final ModelField[] fields) {
popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator);
}
});
} else {
getConnectives().getDataModelOracle().getFieldCompletions(con.getFieldType(), new Callback<ModelField[]>() {
@Override
public void callback(final ModelField[] fields) {
popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator);
}
});
}
}
};
ClickableLabel cl = new ClickableLabel(bindingLabel.toString(), click, !this.readOnly);
DOM.setStyleAttribute(cl.getElement(), "marginLeft", "" + padding + "pt");
ab.add(cl);
} else {
ab.add(new SmallLabel(bindingLabel.toString()));
}
return ab;
}
use of org.uberfire.ext.widgets.common.client.common.SmallLabel 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 org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.
the class ActionValueEditor method showTypeChoice.
protected void showTypeChoice() {
final FormStylePopup form = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.FieldValue());
Button lit = new Button(GuidedRuleEditorResources.CONSTANTS.LiteralValue());
lit.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
value.setNature(FieldNatureType.TYPE_LITERAL);
value.setValue("");
doTypeChosen(form);
}
});
form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.LiteralValue(), GuidedRuleEditorResources.CONSTANTS.Literal(), GuidedRuleEditorResources.CONSTANTS.ALiteralValueMeansTheValueAsTypedInIeItsNotACalculation(), lit);
if (modeller.isTemplate()) {
Button templateButton = new Button(GuidedRuleEditorResources.CONSTANTS.TemplateKey());
templateButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
value.setNature(FieldNatureType.TYPE_TEMPLATE);
value.setValue("");
doTypeChosen(form);
}
});
form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKeyTip(), templateButton);
}
form.addRow(new HTML("<hr/>"));
form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedSection()));
Button formula = new Button(GuidedRuleEditorResources.CONSTANTS.Formula());
formula.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
value.setNature(FieldNatureType.TYPE_FORMULA);
doTypeChosen(form);
}
});
// If there is a bound Facts or Fields that are of the same type as the current variable type, then show a button
List<String> bindings = getApplicableBindings();
if (bindings.size() > 0) {
Button variable = new Button(GuidedRuleEditorResources.CONSTANTS.BoundVariable());
form.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable() + ":", variable);
variable.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
value.setNature(FieldNatureType.TYPE_VARIABLE);
value.setValue("=");
doTypeChosen(form);
}
});
}
form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.Formula(), GuidedRuleEditorResources.CONSTANTS.Formula(), GuidedRuleEditorResources.CONSTANTS.FormulaTip(), formula);
form.show();
}
use of org.uberfire.ext.widgets.common.client.common.SmallLabel in project drools-wb by kiegroup.
the class ActionValueEditor method formulaEditor.
/**
* An editor for formula
* @return
*/
private Widget formulaEditor() {
if (this.readOnly) {
return new SmallLabel(assertValue());
}
final TextBox box = new TextBox();
box.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
value.setValue(event.getValue());
executeOnChangeCommand();
}
});
// FireEvents as the box could assume a default value
box.setValue(assertValue(), true);
attachDisplayLengthHandler(box);
return box;
}
use of org.uberfire.ext.widgets.common.client.common.SmallLabel 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;
}
Aggregations