use of com.google.gwt.user.client.ui.Widget in project blogwt by billy1380.
the class FormPart method isValid.
private boolean isValid() {
boolean isValid = true;
final int count = pnlFields.getWidgetCount();
Widget current;
for (int i = 0; i < count; i++) {
current = pnlFields.getWidget(i);
if (current instanceof FormField) {
if (!((FormField) current).isValid()) {
isValid = false;
((FormField) current).showError();
} else {
((FormField) current).hideError();
}
}
}
return isValid;
}
use of com.google.gwt.user.client.ui.Widget in project blogwt by billy1380.
the class FormPart method onFormSubmit.
@UiHandler("frmForm")
void onFormSubmit(SubmitEvent se) {
if (isValid()) {
loading();
Form form = new Form();
form.name = name;
// add fields to form
final int count = pnlFields.getWidgetCount();
Widget current;
Field field;
for (int i = 0; i < count; i++) {
current = pnlFields.getWidget(i);
field = null;
if (current instanceof FormField) {
field = new Field().name(((FormField) current).name()).value(((FormField) current).value());
if (form.fields == null) {
form.fields = new ArrayList<Field>();
}
form.fields.add(field);
if (current instanceof TextBoxPart) {
field.type(FieldTypeType.FieldTypeTypeText);
} else if (current instanceof TextAreaPart) {
field.type(FieldTypeType.FieldTypeTypeLongText);
} else if (current instanceof ListBoxPart) {
field.type(FieldTypeType.FieldTypeTypeSingleOption);
} else if (current instanceof ReCaptchaPart) {
field.type(FieldTypeType.FieldTypeTypeCaptcha);
}
}
}
FormController.get().submitForm(form);
}
se.cancel();
}
use of com.google.gwt.user.client.ui.Widget in project blogwt by billy1380.
the class PropertiesPage method ready.
private void ready() {
btnUpdate.getElement().setInnerSafeHtml(WizardDialog.WizardDialogTemplates.INSTANCE.nextButton("Update"));
// enable properties
btnUpdate.setEnabled(true);
if (propertyWidgets != null) {
for (Widget widget : propertyWidgets) {
if (widget instanceof Focusable) {
((Focusable) widget).setFocus(true);
break;
}
}
}
}
use of com.google.gwt.user.client.ui.Widget in project openremote by openremote.
the class MapInfoPanel method setItems.
public void setItems(List<MapInfoItem> infoItems) {
contentPanel.clear();
int itemLineHeightPixels = 20;
int itemMarginPixels = 8;
int itemHeightPixels = itemLineHeightPixels + (itemMarginPixels * 2);
int totalMaxHeight = itemHeightPixels * MAX_ITEMS_BEFORE_SCROLLING;
for (MapInfoItem infoItem : infoItems) {
IconLabel itemIcon = new IconLabel(infoItem.getIcon());
itemIcon.addStyleName(style.infoItemIcon());
FormLabel itemLabel = new FormLabel(TextUtil.ellipsize(infoItem.getLabel(), 35));
itemLabel.addStyleName("flex");
itemLabel.addStyleName(style.infoItemLabel());
Widget itemValue = createItemValue(infoItem);
itemValue.addStyleName(style.infoItemValue());
FlowPanel itemPanel = new FlowPanel();
itemPanel.addStyleName("flex-none layout horizontal center");
itemPanel.addStyleName(style.infoItem());
itemPanel.add(itemIcon);
itemPanel.add(itemLabel);
itemPanel.add(itemValue);
contentPanel.add(itemPanel);
}
// Show up to 6 items, then start scrolling
panel.setHeight(Math.min((infoItems.size() * itemHeightPixels), totalMaxHeight) + "px");
// If the panel is already shown, "blink" it so users know there is an update
if (isOpen()) {
contentPanel.addStyleName(widgetStyle.HighlightBackground());
Browser.getWindow().setTimeout(() -> {
contentPanel.removeStyleName(widgetStyle.HighlightBackground());
}, 250);
}
}
use of com.google.gwt.user.client.ui.Widget in project drools-wb by kiegroup.
the class ConfigWidget method setupHandlers.
@PostConstruct
public void setupHandlers() {
addButton.addClickHandler(event -> {
final FormStylePopup pop = new FormStylePopup(TestScenarioAltedImages.INSTANCE.RuleAsset(), TestScenarioConstants.INSTANCE.SelectRule());
final Widget ruleSelector = scenarioWidgetComponentCreator.getRuleSelectionWidget(selectedRule -> {
scenario.getRules().add(selectedRule);
configuredRules.addItem(selectedRule);
pop.hide();
});
pop.addRow(ruleSelector);
pop.show();
});
removeButton.addClickHandler(event -> {
if (configuredRules.getSelectedIndex() == -1) {
Window.alert(TestScenarioConstants.INSTANCE.PleaseChooseARuleToRemove());
} else {
final String rule = configuredRules.getItemText(configuredRules.getSelectedIndex());
scenario.getRules().remove(rule);
configuredRules.removeItem(configuredRules.getSelectedIndex());
}
});
configurationType.addChangeHandler(event -> {
final String selectedType = configurationType.getValue(configurationType.getSelectedIndex());
if (selectedType.equals("inc")) {
// NON-NLS
scenario.setInclusive(true);
addButton.setVisible(true);
removeButton.setVisible(true);
configuredRules.setVisible(true);
} else if (selectedType.equals("exc")) {
// NON-NLS
scenario.setInclusive(false);
addButton.setVisible(true);
removeButton.setVisible(true);
configuredRules.setVisible(true);
} else {
scenario.getRules().clear();
configuredRules.clear();
configuredRules.setVisible(false);
addButton.setVisible(false);
removeButton.setVisible(false);
}
});
}
Aggregations