Search in sources :

Example 31 with Widget

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;
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) FormField(com.willshex.blogwt.client.part.form.FormField)

Example 32 with Widget

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();
}
Also used : TextAreaPart(com.willshex.blogwt.client.part.form.TextAreaPart) ListBoxPart(com.willshex.blogwt.client.part.form.ListBoxPart) FormField(com.willshex.blogwt.client.part.form.FormField) UiField(com.google.gwt.uibinder.client.UiField) Field(com.willshex.blogwt.shared.api.datatype.Field) Form(com.willshex.blogwt.shared.api.datatype.Form) TextBoxPart(com.willshex.blogwt.client.part.form.TextBoxPart) Widget(com.google.gwt.user.client.ui.Widget) ReCaptchaPart(com.willshex.blogwt.client.part.form.ReCaptchaPart) FormField(com.willshex.blogwt.client.part.form.FormField) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 33 with Widget

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;
            }
        }
    }
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) Focusable(com.google.gwt.user.client.ui.Focusable)

Example 34 with Widget

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);
    }
}
Also used : IconLabel(org.openremote.app.client.widget.IconLabel) Widget(com.google.gwt.user.client.ui.Widget) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) FormLabel(org.openremote.app.client.widget.FormLabel)

Example 35 with Widget

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);
        }
    });
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) ScenarioParentWidget(org.drools.workbench.screens.testscenario.client.ScenarioParentWidget) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Widget (com.google.gwt.user.client.ui.Widget)110 Test (org.junit.Test)22 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)12 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)12 ListBox (org.gwtbootstrap3.client.ui.ListBox)8 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)7 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)7 Command (com.google.gwt.user.client.Command)7 HTML (com.google.gwt.user.client.ui.HTML)7 IsWidget (com.google.gwt.user.client.ui.IsWidget)7 Image (com.google.gwt.user.client.ui.Image)6 TextBox (org.gwtbootstrap3.client.ui.TextBox)5 FixedRatioWidget (org.rstudio.core.client.widget.FixedRatioWidget)5 PreWidget (org.rstudio.core.client.widget.PreWidget)5 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)4 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)4 Label (com.google.gwt.user.client.ui.Label)4 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)4 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)4 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)4