use of org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane 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 String attributeName = at.getAttributeName();
if (attributeName.equals(RULEFLOW_GROUP_ATTR) || attributeName.equals(AGENDA_GROUP_ATTR) || attributeName.equals(ACTIVATION_GROUP_ATTR) || attributeName.equals(TIMER_ATTR) || attributeName.equals(CALENDARS_ATTR)) {
final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
tb.setEnabled(!isReadOnly);
if (!isReadOnly) {
tb.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
at.setValue(tb.getValue());
}
});
}
tb.setValue(at.getValue());
editor = tb;
} else if (attributeName.equals(SALIENCE_ATTR)) {
final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_INTEGER);
tb.setEnabled(!isReadOnly);
if (!isReadOnly) {
tb.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
at.setValue(tb.getValue());
}
});
}
tb.setValue(at.getValue());
editor = tb;
} else if (attributeName.equals(DURATION_ATTR)) {
final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_LONG);
tb.setEnabled(!isReadOnly);
if (!isReadOnly) {
tb.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
at.setValue(tb.getValue());
}
});
}
tb.setValue(at.getValue());
editor = tb;
} else if (attributeName.equals(NO_LOOP_ATTR) || attributeName.equals(LOCK_ON_ACTIVE_ATTR) || attributeName.equals(AUTO_FOCUS_ATTR) || attributeName.equals(ENABLED_ATTR)) {
editor = checkBoxEditor(at, isReadOnly);
} else if (attributeName.equals(DATE_EFFECTIVE_ATTR) || attributeName.equals(DATE_EXPIRES_ATTR)) {
if (isReadOnly) {
final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
tb.setValue(at.getValue());
tb.setEnabled(false);
} else {
final DatePicker datePicker = new DatePicker(false);
// Wire up update handler
datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(final ValueChangeEvent<Date> event) {
final Date date = datePicker.getValue();
final String sDate = (date == null ? null : DATE_FORMATTER.format(datePicker.getValue()));
at.setValue(sDate);
}
});
datePicker.setFormat(DATE_FORMAT);
datePicker.setValue(assertDateValue(at));
editor = datePicker;
}
} else if (attributeName.equals(DIALECT_ATTR)) {
final ListBox lb = new ListBox();
lb.addItem(DIALECTS[0]);
lb.addItem(DIALECTS[1]);
lb.setEnabled(!isReadOnly);
if (!isReadOnly) {
lb.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent 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[1]);
} else if (at.getValue().equals(DIALECTS[0])) {
lb.setSelectedIndex(0);
} else if (at.getValue().equals(DIALECTS[1])) {
lb.setSelectedIndex(1);
} else {
lb.setSelectedIndex(1);
at.setValue(DIALECTS[1]);
}
editor = lb;
}
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
if (editor != null) {
horiz.add(editor);
if (!isReadOnly) {
horiz.add(getRemoveIcon(idx));
}
}
return horiz;
}
use of org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane in project drools-wb by kiegroup.
the class RuleModeller method wrapLineNumber.
private Widget wrapLineNumber(int number, boolean isLHSLine) {
String id = "rhsLine";
if (isLHSLine) {
id = "lhsLine";
}
id += number;
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
horiz.add(new HTML("<div class='form-field' id='" + id + "'>" + number + ".</div>"));
return horiz;
}
use of org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane in project drools-wb by kiegroup.
the class RuleModeller method clearLineIcons.
private void clearLineIcons(int row, int col) {
if (layout.getCellCount(row) <= col) {
return;
}
Widget widget = layout.getWidget(row, col);
if (widget instanceof DirtyableHorizontalPane) {
DirtyableHorizontalPane horiz = (DirtyableHorizontalPane) widget;
horiz.clear();
}
}
use of org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane in project drools-wb by kiegroup.
the class RuleModeller method addLineIcon.
private void addLineIcon(int row, int col, Image icon) {
Widget widget = layout.getWidget(row, col);
if (widget instanceof DirtyableHorizontalPane) {
DirtyableHorizontalPane horiz = (DirtyableHorizontalPane) widget;
horiz.add(icon);
}
}
use of org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane in project drools-wb by kiegroup.
the class RuleModeller method renderRhs.
/**
* Do all the widgets for the RHS.
*/
private void renderRhs(final RuleModel model) {
for (int i = 0; i < model.rhs.length; i++) {
DirtyableVerticalPane widget = new DirtyableVerticalPane();
widget.setWidth("100%");
IAction action = model.rhs[i];
// if lockRHS() set the widget RO, otherwise let them decide.
Boolean readOnly = this.lockRHS() ? true : null;
RuleModellerWidget w = getWidgetFactory().getWidget(this, eventBus, action, readOnly);
w.addOnModifiedCommand(this.onWidgetModifiedCommand);
widget.add(wrapRHSWidget(model, i, w));
widget.add(spacerWidget());
layout.setWidget(currentLayoutRow, 0, new DirtyableHorizontalPane());
layout.setWidget(currentLayoutRow, 1, new DirtyableHorizontalPane());
layout.setWidget(currentLayoutRow, 2, this.wrapLineNumber(i + 1, false));
layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2, HasVerticalAlignment.ALIGN_MIDDLE);
layout.setWidget(currentLayoutRow, 3, widget);
layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 3, HasHorizontalAlignment.ALIGN_LEFT);
layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 3, HasVerticalAlignment.ALIGN_TOP);
layout.getFlexCellFormatter().setWidth(currentLayoutRow, 3, "100%");
layout.getRowFormatter().addStyleName(currentLayoutRow, (i % 2 == 0 ? GuidedRuleEditorResources.INSTANCE.css().evenRow() : GuidedRuleEditorResources.INSTANCE.css().oddRow()));
if (!w.isFactTypeKnown()) {
addInvalidPatternIcon();
addFactTypeKnownValueChangeHandler(w, currentLayoutRow);
}
final int index = i;
if (!(this.lockRHS() || w.isReadOnly())) {
this.addActionsButtonsToLayout(GuidedRuleEditorResources.CONSTANTS.AddAnActionBelow(), new ClickHandler() {
public void onClick(ClickEvent event) {
showActionSelector(index + 1);
}
}, new ClickHandler() {
public void onClick(ClickEvent event) {
model.moveRhsItemDown(index);
refreshWidget();
}
}, new ClickHandler() {
public void onClick(ClickEvent event) {
model.moveRhsItemUp(index);
refreshWidget();
}
});
}
this.rhsWidgets.add(w);
currentLayoutRow++;
}
}
Aggregations