use of org.gwtbootstrap3.client.ui.Label in project drools-wb by kiegroup.
the class ConstraintValueEditor method literalEditor.
private Widget literalEditor() {
// Custom screen
if (this.constraint instanceof SingleFieldConstraint) {
final SingleFieldConstraint con = (SingleFieldConstraint) this.constraint;
CustomFormConfiguration customFormConfiguration = getWorkingSetManager().getCustomFormConfiguration(modeller.getPath(), factType, fieldName);
if (customFormConfiguration != null) {
Button btnCustom = new Button(con.getValue(), new ClickHandler() {
public void onClick(ClickEvent event) {
showTypeChoice(constraint);
}
});
btnCustom.setEnabled(!this.readOnly);
return btnCustom;
}
}
// Label if read-only
if (this.readOnly) {
return new SmallLabel(getSanitizedValue());
}
// Enumeration (these support multi-select for "in" and "not in", so check before comma separated lists)
if (this.dropDownData != null) {
final String operator = constraint.getOperator();
final boolean multipleSelect = OperatorsOracle.operatorRequiresList(operator);
EnumDropDown enumDropDown = new EnumDropDown(constraint.getValue(), new DropDownValueChanged() {
public void valueChanged(String newText, String newValue) {
// Prevent recursion once value change has been applied
if (!newValue.equals(constraint.getValue())) {
constraint.setValue(newValue);
executeOnValueChangeCommand();
}
}
}, dropDownData, multipleSelect, modeller.getPath());
return enumDropDown;
}
// Comma separated value list (this will become a dedicated Widget but for now a TextBox suffices)
String operator = null;
if (this.constraint instanceof SingleFieldConstraint) {
SingleFieldConstraint sfc = (SingleFieldConstraint) this.constraint;
operator = sfc.getOperator();
}
if (OperatorsOracle.operatorRequiresList(operator)) {
return getNewTextBox(DataType.TYPE_STRING);
}
// Date picker
boolean isCEPOperator = CEPOracle.isCEPOperator((this.constraint).getOperator());
if (DataType.TYPE_DATE.equals(this.fieldType) || (DataType.TYPE_THIS.equals(this.fieldName) && isCEPOperator)) {
if (this.readOnly) {
return new SmallLabel(constraint.getValue());
}
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()));
boolean update = constraint.getValue() == null || !constraint.getValue().equals(sDate);
constraint.setValue(sDate);
if (update) {
executeOnValueChangeCommand();
}
}
});
datePicker.setFormat(DATE_FORMAT);
datePicker.setValue(getSanitizedDateValue());
return datePicker;
}
// Default editor for all other literals
return getNewTextBox(fieldType);
}
use of org.gwtbootstrap3.client.ui.Label in project drools-wb by kiegroup.
the class ExpressionBuilder method createWidgetForExpression.
// Render Widgets for the Expression. ExpressionMethodParameter and ExpressionText parts
// are represented by a TextBox to allow the User to edit the values, Updates are
// reflected in the model.
private Widget createWidgetForExpression() {
final HorizontalPanel container = new HorizontalPanel();
container.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
container.setStylePrimaryName(GuidedRuleEditorResources.INSTANCE.css().container());
for (ExpressionPart expressionPart : expression.getParts()) {
if (expressionPart instanceof ExpressionUnboundFact) {
continue;
} else if (this.readOnly) {
container.add(new Label(expressionPart.getName()));
} else if (expressionPart instanceof ExpressionMethod) {
container.add(new Label(expressionPart.getName()));
container.add(new Label("("));
final ExpressionMethod em = (ExpressionMethod) expressionPart;
final List<ExpressionFormLine> emParams = em.getOrderedParams();
for (int index = 0; index < emParams.size(); index++) {
final ExpressionFormLine paramValueHolder = emParams.get(index);
final String paramDataType = em.getParameterDataType(paramValueHolder);
final ExpressionMethodParameter paramValue = ((ExpressionMethodParameter) paramValueHolder.getRootExpression());
final TextBox paramValueEditor = TextBoxFactory.getTextBox(paramDataType);
paramValueEditor.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
paramValue.setText(event.getValue());
}
});
paramValueEditor.setText(paramValue.getName());
container.add(paramValueEditor);
if (index < emParams.size() - 1) {
container.add(new Label(", "));
}
}
container.add(new Label(")"));
} else if (!(expressionPart instanceof ExpressionText)) {
container.add(new Label(expressionPart.getName()));
} else {
final TextBox tb = new TextBox();
final ExpressionText expressionTextPart = (ExpressionText) expressionPart;
tb.setText(expressionTextPart.getName());
tb.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(final ChangeEvent changeEvent) {
expressionTextPart.setText(tb.getText());
}
});
container.add(tb);
}
container.add(new Label("."));
}
return container;
}
use of org.gwtbootstrap3.client.ui.Label 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);
}
use of org.gwtbootstrap3.client.ui.Label in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPageViewImpl method initialiseChosenFields.
private void initialiseChosenFields() {
chosenFieldsContainer.add(chosenFieldsWidget);
chosenFieldsWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
chosenFieldsWidget.setMinimumWidth(130);
final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoChosenFields());
lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
chosenFieldsWidget.setEmptyListWidget(lstEmpty);
final MultiSelectionModel<ActionInsertFactCol52> selectionModel = new MultiSelectionModel<ActionInsertFactCol52>(System::identityHashCode);
chosenFieldsWidget.setSelectionModel(selectionModel);
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(final SelectionChangeEvent event) {
chosenFieldsSelections = new HashSet<ActionInsertFactCol52>();
final Set<ActionInsertFactCol52> selections = selectionModel.getSelectedSet();
for (ActionInsertFactCol52 a : selections) {
chosenFieldsSelections.add(a);
}
chosenConditionsSelected(chosenFieldsSelections);
}
private void chosenConditionsSelected(final Set<ActionInsertFactCol52> cws) {
btnRemove.setEnabled(true);
if (cws.size() == 1) {
chosenFieldsSelection = cws.iterator().next();
fieldDefinition.setVisible(true);
validateFieldHeader();
populateFieldDefinition();
} else {
chosenFieldsSelection = null;
fieldDefinition.setVisible(false);
txtColumnHeader.setEnabled(false);
txtValueList.setEnabled(false);
defaultValueContainer.setVisible(false);
}
}
private void populateFieldDefinition() {
// Fields common to all table formats
txtColumnHeader.setEnabled(true);
txtColumnHeader.setText(chosenFieldsSelection.getHeader());
criteriaExtendedEntry.setVisible(presenter.getTableFormat() == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
criteriaLimitedEntry.setVisible(presenter.getTableFormat() == GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
// Fields specific to the table format
switch(presenter.getTableFormat()) {
case EXTENDED_ENTRY:
txtValueList.setEnabled(!presenter.hasEnums(chosenFieldsSelection));
txtValueList.setText(chosenFieldsSelection.getValueList());
makeDefaultValueWidget();
defaultValueContainer.setVisible(true);
break;
case LIMITED_ENTRY:
makeLimitedValueWidget();
limitedEntryValueContainer.setVisible(true);
break;
}
}
private void makeLimitedValueWidget() {
if (!(chosenFieldsSelection instanceof LimitedEntryActionInsertFactCol52)) {
return;
}
LimitedEntryActionInsertFactCol52 lea = (LimitedEntryActionInsertFactCol52) chosenFieldsSelection;
if (lea.getValue() == null) {
lea.setValue(factory.makeNewValue(chosenFieldsSelection));
}
limitedEntryValueWidgetContainer.setWidget(factory.getWidget(chosenFieldsSelection, lea.getValue()));
}
});
}
use of org.gwtbootstrap3.client.ui.Label in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPageViewImpl method initialiseAvailableFields.
private void initialiseAvailableFields() {
availableFieldsContainer.add(availableFieldsWidget);
availableFieldsWidget.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
availableFieldsWidget.setMinimumWidth(130);
final Label lstEmpty = new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardNoAvailableFields());
lstEmpty.setStyleName(WizardCellListResources.INSTANCE.cellListStyle().cellListEmptyItem());
availableFieldsWidget.setEmptyListWidget(lstEmpty);
final MultiSelectionModel<AvailableField> selectionModel = new MultiSelectionModel<AvailableField>();
availableFieldsWidget.setSelectionModel(selectionModel);
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(final SelectionChangeEvent event) {
availableFieldsSelections = selectionModel.getSelectedSet();
btnAdd.setEnabled(availableFieldsSelections.size() > 0);
}
});
}
Aggregations