use of com.google.gwt.safehtml.shared.SafeHtml in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_Condition.
@Test
public void getSafeHtml_Condition() {
ConditionCol52 originalColumn = new ConditionCol52();
originalColumn.setBinding("bind1");
originalColumn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
originalColumn.setFactField("field1");
originalColumn.setFieldType("FieldType1");
originalColumn.setOperator("==");
originalColumn.setValueList("a,b,c");
originalColumn.setHeader("condition1");
originalColumn.setHideColumn(false);
originalColumn.setDefaultValue(new DTCellValue52("def1"));
ConditionCol52 newColumn = new ConditionCol52();
newColumn.setBinding("bind2");
newColumn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_PREDICATE);
newColumn.setFactField("field2");
newColumn.setFieldType("FieldType2");
newColumn.setOperator("!=");
newColumn.setValueList("x,y,z");
newColumn.setHeader("condition2");
newColumn.setHideColumn(true);
newColumn.setDefaultValue(new DTCellValue52("def2"));
Pattern52 originalPattern = new Pattern52();
originalPattern.setBoundName("patBind1");
originalPattern.setFactType("FactType1");
originalPattern.setEntryPointName("ep1");
Pattern52 newPattern = new Pattern52();
newPattern.setBoundName("patBind2");
newPattern.setFactType("FactType2");
newPattern.setEntryPointName("ep2");
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
diffs.addAll(originalPattern.diff(newPattern));
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
assertEquals(getConditionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
use of com.google.gwt.safehtml.shared.SafeHtml in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_ActionSetField.
@Test
public void getSafeHtml_ActionSetField() {
ActionSetFieldCol52 originalColumn = new ActionSetFieldCol52();
originalColumn.setBoundName("bind1");
originalColumn.setFactField("field1");
originalColumn.setUpdate(false);
originalColumn.setValueList("q,w,e");
originalColumn.setHeader("action1");
originalColumn.setHideColumn(false);
originalColumn.setDefaultValue(new DTCellValue52("def1"));
ActionSetFieldCol52 newColumn = new ActionSetFieldCol52();
newColumn.setBoundName("bind2");
newColumn.setFactField("field2");
newColumn.setUpdate(true);
newColumn.setValueList("a,s,d");
newColumn.setHeader("action2");
newColumn.setHideColumn(true);
newColumn.setDefaultValue(new DTCellValue52("def2"));
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
assertEquals(getActionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
use of com.google.gwt.safehtml.shared.SafeHtml in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_BrlCondition_DefinitionOnly.
@Test
public void getSafeHtml_BrlCondition_DefinitionOnly() {
BRLConditionColumn originalColumn = new BRLConditionColumn();
originalColumn.setDefinition(Arrays.asList(new FactPattern("FactType1")));
originalColumn.setHeader("condition");
originalColumn.setHideColumn(false);
BRLConditionColumn newColumn = new BRLConditionColumn();
originalColumn.setDefinition(Arrays.asList(new FactPattern("FactType2"), new FactPattern("FactType3")));
newColumn.setHeader("condition");
newColumn.setHideColumn(false);
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
// Definition diffs are currently not supported, maybe #soon?
// assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(new ArrayList<>()), result.asString());
}
use of com.google.gwt.safehtml.shared.SafeHtml in project drools-wb by kiegroup.
the class EnumEditorTextCellTest method testRenderDisabled.
@Test
public void testRenderDisabled() {
context = new Cell.Context(0, 0, new EnumRow("A raw value"));
final SafeHtmlBuilder safeHtmlBuilder = mock(SafeHtmlBuilder.class);
cell.render(context, "Fact", safeHtmlBuilder);
verify(cell, never()).doRender(eq(context), eq("Fact"), eq(safeHtmlBuilder));
verify(safeHtmlBuilder, times(1)).append(safeHtmlArgumentCaptor.capture());
final SafeHtml safeHtml = safeHtmlArgumentCaptor.getValue();
assertEquals("cellContent(disabled, invalidDefinitionDisabled, Fact)", safeHtml.asString());
}
use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.
the class ImportNetworksPopupView method initEntityModelCellTables.
void initEntityModelCellTables() {
providerNetworks.addColumn(new AbstractTextColumn<ExternalNetwork>() {
@Override
public String getValue(ExternalNetwork model) {
return model.getDisplayName();
}
}, constants.nameNetworkHeader());
importedNetworks.addColumn(new AbstractEditTextColumn<ExternalNetwork>((index, model, value) -> model.setDisplayName(value)) {
@Override
public String getValue(ExternalNetwork model) {
return model.getDisplayName();
}
}, constants.nameNetworkHeader());
Column<ExternalNetwork, String> idColumn = new AbstractTextColumn<ExternalNetwork>() {
@Override
public String getValue(ExternalNetwork model) {
return model.getNetwork().getProvidedBy().getExternalId();
}
};
providerNetworks.addColumn(idColumn, constants.idNetworkHeader());
importedNetworks.addColumn(idColumn, constants.idNetworkHeader());
dcColumn = new AbstractListModelListBoxColumn<ExternalNetwork, StoragePool>(new NameRenderer<StoragePool>()) {
@Override
public ListModel<StoragePool> getValue(ExternalNetwork network) {
return network.getDataCenters();
}
};
importedNetworks.addColumn(dcColumn, constants.dcNetworkHeader());
AbstractCheckboxHeader publicAllHeader = new AbstractCheckboxHeader() {
@Override
protected void selectionChanged(Boolean value) {
for (ExternalNetwork model : getAllImportedNetworks()) {
model.setPublicUse(value);
}
refreshImportedNetworks();
}
@Override
public Boolean getValue() {
for (ExternalNetwork model : getAllImportedNetworks()) {
if (!model.isPublicUse()) {
return false;
}
}
return true;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public void render(Context context, SafeHtmlBuilder sb) {
super.render(context, sb);
sb.append(ImportNetworksPopupView.templates.tableHeaderInlineImage(SafeHtmlUtils.fromTrustedString(new InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML).toString())));
}
@Override
public SafeHtml getTooltip() {
return ImportNetworksPopupView.templates.textForCheckBoxHeader(constants.publicNetworkTooltip());
}
@Override
public String getLabel() {
return constants.publicNetwork();
}
};
importedNetworks.addColumn(new AbstractCheckboxColumn<ExternalNetwork>((index, model, value) -> {
model.setPublicUse(value);
refreshImportedNetworks();
}) {
@Override
public Boolean getValue(ExternalNetwork model) {
return model.isPublicUse();
}
@Override
protected boolean canEdit(ExternalNetwork model) {
return true;
}
@Override
public void render(Context context, ExternalNetwork object, SafeHtmlBuilder sb) {
super.render(context, object, sb);
// $NON-NLS-1$
sb.append(templates.textForCheckBox(""));
}
}, publicAllHeader, // $NON-NLS-1$
"80px");
}
Aggregations