use of org.gwtbootstrap3.client.ui.Column in project drools-wb by kiegroup.
the class DTCellValueWidgetFactoryTest method testGeTextBoxForBRLColumn.
@Test
public void testGeTextBoxForBRLColumn() throws Exception {
BRLActionVariableColumn column = mock(BRLActionVariableColumn.class);
doReturn("Person").when(column).getFactType();
doReturn("name").when(column).getFactField();
when(oracle.hasEnums("Person", "name")).thenReturn(false);
IsWidget widget = factory.getWidget(column, cellValue);
assertTrue(widget instanceof TextBox);
}
use of org.gwtbootstrap3.client.ui.Column in project drools-wb by kiegroup.
the class GuidedScoreCardEditor method addAttributeCellTable.
private Widget addAttributeCellTable(final FlexTable cGrid, final Characteristic characteristic, final boolean enumColumn, final String dataType, final List<String> operators) {
String[] enumValues = null;
if (characteristic != null) {
// enum values
if (enumColumn) {
String factName = characteristic.getFact();
String fieldName = characteristic.getField();
enumValues = oracle.getEnumValues(factName, fieldName);
}
}
final CellTable<Attribute> attributeCellTable = new CellTable<Attribute>();
// Operators column
final DynamicSelectionCell categoryCell = new DynamicSelectionCell(operators);
final Column<Attribute, String> operatorColumn = new Column<Attribute, String>(categoryCell) {
public String getValue(final Attribute object) {
return object.getOperator();
}
};
operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String value) {
object.setOperator(value);
attributeCellTable.redraw();
}
});
// Value column
Column<Attribute, String> valueColumn = null;
if (enumValues != null && enumValues.length > 0) {
valueColumn = new Column<Attribute, String>(new DynamicSelectionCell(Arrays.asList(enumValues))) {
public String getValue(final Attribute object) {
return object.getValue();
}
};
valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String value) {
object.setValue(value);
attributeCellTable.redraw();
}
});
}
if (valueColumn == null) {
valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) {
public String getValue(final Attribute attribute) {
return attribute.getValue();
}
};
valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String value) {
object.setValue(value);
attributeCellTable.redraw();
}
});
}
// Partial Score column
final EditTextCell partialScoreCell = new EditTextCell();
final Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) {
public String getValue(final Attribute attribute) {
return "" + attribute.getPartialScore();
}
};
partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String value) {
try {
double d = Double.parseDouble(value);
object.setPartialScore(d);
} catch (Exception e1) {
partialScoreCell.clearViewData(object);
}
attributeCellTable.redraw();
}
});
// Reason Code column
final Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) {
public String getValue(final Attribute attribute) {
return attribute.getReasonCode();
}
};
reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String value) {
object.setReasonCode(value);
attributeCellTable.redraw();
}
});
final ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() {
public void execute(final Attribute attribute) {
if (Window.confirm(GuidedScoreCardConstants.INSTANCE.promptDeleteAttribute())) {
final List<Attribute> list = characteristicsAttrMap.get(cGrid).getList();
list.remove(attribute);
if ("boolean".equalsIgnoreCase(dataType)) {
((Button) cGrid.getWidget(0, 3)).setEnabled(list.size() != 2);
}
attributeCellTable.redraw();
}
}
};
final Cell<Attribute> actionCell = new ActionCell<Attribute>(GuidedScoreCardConstants.INSTANCE.remove(), delegate);
final Column<Attribute, String> actionColumn = new IdentityColumn(actionCell);
// Add the columns.
attributeCellTable.addColumn(operatorColumn, GuidedScoreCardConstants.INSTANCE.operator());
attributeCellTable.addColumn(valueColumn, GuidedScoreCardConstants.INSTANCE.value());
attributeCellTable.addColumn(partialScoreColumn, GuidedScoreCardConstants.INSTANCE.partialScore());
attributeCellTable.addColumn(reasonCodeColumn, GuidedScoreCardConstants.INSTANCE.reasonCode());
attributeCellTable.addColumn(actionColumn, GuidedScoreCardConstants.INSTANCE.actions());
attributeCellTable.setWidth("100%", true);
attributeCellTable.setColumnWidth(operatorColumn, 20.0, Style.Unit.PCT);
attributeCellTable.setColumnWidth(valueColumn, 20.0, Style.Unit.PCT);
attributeCellTable.setColumnWidth(partialScoreColumn, 20.0, Style.Unit.PCT);
attributeCellTable.setColumnWidth(reasonCodeColumn, 20.0, Style.Unit.PCT);
attributeCellTable.setColumnWidth(actionColumn, 20.0, Style.Unit.PCT);
ListDataProvider<Attribute> dataProvider = new ListDataProvider<Attribute>();
dataProvider.addDataDisplay(attributeCellTable);
characteristicsAttrMap.put(cGrid, dataProvider);
if ("boolean".equalsIgnoreCase(dataType)) {
CustomEditTextCell etc = (CustomEditTextCell) attributeCellTable.getColumn(1).getCell();
etc.setEnabled(false);
}
return (attributeCellTable);
}
use of org.gwtbootstrap3.client.ui.Column in project drools-wb by kiegroup.
the class GlobalsEditorViewImpl method setup.
private void setup() {
// Setup table
table.setStriped(true);
table.setCondensed(true);
table.setBordered(true);
table.setEmptyTableWidget(new Label(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplNoGlobalsDefined)));
// Columns
final TextColumn<Global> aliasColumn = new TextColumn<Global>() {
@Override
public String getValue(final Global global) {
return global.getAlias();
}
};
final TextColumn<Global> classNameColumn = new TextColumn<Global>() {
@Override
public String getValue(final Global global) {
return global.getClassName();
}
};
deleteGlobalButton = new ButtonCell(IconType.MINUS, ButtonType.DANGER, ButtonSize.SMALL);
final Column<Global, String> deleteGlobalColumn = new Column<Global, String>(deleteGlobalButton) {
@Override
public String getValue(final Global global) {
return translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplRemove);
}
};
deleteGlobalColumn.setFieldUpdater((index, global, value) -> {
if (Window.confirm(translationService.format(GlobalsEditorConstants.GlobalsEditorViewImplPromptForRemovalOfGlobal, global.getAlias()))) {
dataProvider.getList().remove(index);
}
});
table.addColumn(aliasColumn, new TextHeader(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplAlias)));
table.addColumn(classNameColumn, new TextHeader(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplClassName)));
table.addColumn(deleteGlobalColumn, translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplRemove));
// Link data
dataProvider.addDataDisplay(table);
dataProvider.setList(globals);
generatedLabel.setText(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplAutoGeneratedFile));
addGlobalButton.setText(translationService.getTranslation(GlobalsEditorConstants.GlobalsEditorViewImplAdd));
addGlobalButton.setIcon(IconType.PLUS);
}
Aggregations