use of com.google.gwt.user.client.ui.HTML in project drools-wb by kiegroup.
the class GuidedScoreCardEditor method getCharacteristics.
private Widget getCharacteristics() {
characteristicsPanel = new VerticalPanel();
characteristicsTables = new ArrayList<FlexTable>();
final HorizontalPanel toolbar = new HorizontalPanel();
btnAddCharacteristic = new Button(GuidedScoreCardConstants.INSTANCE.addCharacteristic(), new ClickHandler() {
public void onClick(ClickEvent event) {
addCharacteristic(null);
}
});
toolbar.add(btnAddCharacteristic);
toolbar.setHeight("24");
characteristicsPanel.add(toolbar);
final SimplePanel gapPanel = new SimplePanel();
gapPanel.add(new HTML("<br/>"));
characteristicsPanel.add(gapPanel);
return characteristicsPanel;
}
use of com.google.gwt.user.client.ui.HTML in project drools-wb by kiegroup.
the class VerifyRulesFiredWidget method render.
private FlexTable render(final FixtureList rfl, final Scenario sc) {
FlexTable data = new FlexTable();
for (int i = 0; i < rfl.size(); i++) {
final VerifyRuleFired v = (VerifyRuleFired) rfl.get(i);
if (showResults && v.getSuccessResult() != null) {
if (!v.getSuccessResult().booleanValue()) {
data.setWidget(i, 0, new Image(CommonImages.INSTANCE.warning()));
data.setWidget(i, 4, new HTML(TestScenarioConstants.INSTANCE.ActualResult(v.getActualResult().toString())));
data.getCellFormatter().addStyleName(i, 4, // NON-NLS
"testErrorValue");
} else {
data.setWidget(i, 0, new Image(TestScenarioImages.INSTANCE.testPassed()));
}
}
data.setWidget(i, 1, new SmallLabel(v.getRuleName() + ":"));
data.getFlexCellFormatter().setAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
final ListBox b = new ListBox();
b.addItem(TestScenarioConstants.INSTANCE.firedAtLeastOnce(), "y");
b.addItem(TestScenarioConstants.INSTANCE.didNotFire(), "n");
b.addItem(TestScenarioConstants.INSTANCE.firedThisManyTimes(), "e");
final TextBox num = new TextBox();
((InputElement) num.getElement().cast()).setSize(5);
if (v.getExpectedFire() != null) {
b.setSelectedIndex((v.getExpectedFire().booleanValue()) ? 0 : 1);
num.setVisible(false);
} else {
b.setSelectedIndex(2);
String xc = (v.getExpectedCount() != null) ? "" + v.getExpectedCount().intValue() : "0";
num.setText(xc);
}
b.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String s = b.getValue(b.getSelectedIndex());
if (s.equals("y") || s.equals("n")) {
num.setVisible(false);
v.setExpectedFire((s.equals("y")) ? Boolean.TRUE : Boolean.FALSE);
v.setExpectedCount(null);
} else {
num.setVisible(true);
v.setExpectedFire(null);
num.setText("1");
v.setExpectedCount(Integer.valueOf(1));
}
}
});
b.addItem(TestScenarioConstants.INSTANCE.ChooseDotDotDot());
num.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
v.setExpectedCount(Integer.valueOf(num.getText()));
}
});
HorizontalPanel h = new HorizontalPanel();
h.add(b);
h.add(num);
data.setWidget(i, 2, h);
Button del = new Button();
del.setIcon(IconType.TRASH);
del.setTitle(TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation());
del.addClickHandler(clickEvent -> {
if (Window.confirm(TestScenarioConstants.INSTANCE.AreYouSureYouWantToRemoveThisRuleExpectation())) {
rfl.remove(v);
sc.removeFixture(v);
outer.setWidget(1, 0, render(rfl, sc));
}
});
data.setWidget(i, 3, del);
// we only want numbers here...
num.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (Character.isLetter(event.getCharCode())) {
((TextBox) event.getSource()).cancelKey();
}
}
});
}
ScenarioUtils.addBottomAndRightPaddingToTableCells(data);
return data;
}
use of com.google.gwt.user.client.ui.HTML in project drools-wb by kiegroup.
the class FactPatternWidget method compositeFieldConstraintEditor.
/**
* This will show the constraint editor - allowing field constraints to be
* nested etc.
*/
private Widget compositeFieldConstraintEditor(final CompositeFieldConstraint constraint) {
FlexTable t = new FlexTable();
String desc;
ClickHandler click = event -> popupCreator.showPatternPopupForComposite(constraint);
if (constraint.getCompositeJunctionType().equals(CompositeFieldConstraint.COMPOSITE_TYPE_AND)) {
desc = GuidedRuleEditorResources.CONSTANTS.AllOf() + ":";
} else {
desc = GuidedRuleEditorResources.CONSTANTS.AnyOf() + ":";
}
t.setWidget(0, 0, new ClickableLabel(desc, click, !this.readOnly));
t.getFlexCellFormatter().setColSpan(0, 0, 2);
FieldConstraint[] nested = constraint.getConstraints();
FlexTable inner = new FlexTable();
if (nested != null) {
for (int i = 0; i < nested.length; i++) {
this.renderFieldConstraint(inner, i, nested[i], constraint, true, 0);
// add in remove icon here...
final int currentRow = i;
Image clear = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
clear.setTitle(GuidedRuleEditorResources.CONSTANTS.RemoveThisNestedRestriction());
clear.addClickHandler(event -> {
if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisItemFromNestedConstraint())) {
setModified(true);
constraint.removeConstraint(currentRow);
getModeller().refreshWidget();
}
});
if (!this.readOnly) {
// This used to be 5 and Connectives were not rendered
inner.setWidget(i, 6, clear);
inner.setWidget(i, 7, new MoveDownButton(event -> {
constraint.moveDown(currentRow);
getModeller().refreshWidget();
}));
inner.setWidget(i, 8, new MoveUpButton(event -> {
constraint.moveUp(currentRow);
getModeller().refreshWidget();
}));
}
}
}
t.setWidget(1, 1, inner);
t.setWidget(1, 0, new HTML(" "));
return t;
}
use of com.google.gwt.user.client.ui.HTML in project drools-wb by kiegroup.
the class FactPatternWidget method renderSingleFieldConstraint.
/**
* Applies a single field constraint to the given table, and start row.
*/
private void renderSingleFieldConstraint(final FlexTable inner, final int row, final SingleFieldConstraint constraint, final HasConstraints hasConstraints, boolean showBinding, final int tabs) {
// for offsetting, just a slight indent
final int col = 1;
inner.setWidget(row, 0, new HTML(" "));
if (constraint.getConstraintValueType() != BaseSingleFieldConstraint.TYPE_PREDICATE) {
HorizontalPanel ebContainer = null;
if (constraint instanceof SingleFieldConstraintEBLeftSide) {
ebContainer = expressionBuilderLS((SingleFieldConstraintEBLeftSide) constraint, showBinding);
inner.setWidget(row, 0 + col, ebContainer);
} else {
inner.setWidget(row, 0 + col, fieldLabel(constraint, hasConstraints, showBinding, tabs * 20));
}
inner.setWidget(row, 1 + col, operatorDropDown(constraint, inner, row, 2 + col));
// Get first part of constraint.fieldName? #1=Fact1, #2=SubFact1
inner.setWidget(row, 2 + col, createValueEditor(constraint));
inner.setWidget(row, 3 + col, getConnectives().connectives(constraint));
if (ebContainer != null && ebContainer.getWidgetCount() > 0) {
if (ebContainer.getWidget(0) instanceof ExpressionBuilder) {
associateExpressionWithChangeHandler(inner, row, constraint, col, ebContainer);
}
}
} else if (constraint.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_PREDICATE) {
inner.setWidget(row, 1, predicateEditor(constraint));
inner.getFlexCellFormatter().setColSpan(row, 1, 5);
}
}
use of com.google.gwt.user.client.ui.HTML in project drools-wb by kiegroup.
the class FromCompositeFactPatternWidget method getCompositeLabel.
protected Widget getCompositeLabel() {
ClickHandler click = new ClickHandler() {
public void onClick(ClickEvent event) {
showFactTypeSelector();
}
};
String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from") + " </div>";
FlexTable panel = new FlexTable();
int r = 0;
if (pattern.getFactPattern() == null) {
panel.setWidget(r, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", click, !this.readOnly));
r++;
}
panel.setWidget(r, 0, new HTML(lbl));
ExpressionBuilder expressionBuilder = new ExpressionBuilder(this.getModeller(), this.getEventBus(), this.pattern.getExpression(), this.readOnly);
expressionBuilder.addOnModifiedCommand(new Command() {
public void execute() {
setModified(true);
}
});
panel.setWidget(r, 1, expressionBuilder);
return panel;
}
Aggregations