Search in sources :

Example 96 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler in project drools-wb by kiegroup.

the class VerifyFactWidget method render.

private FlexTable render(final VerifyFact vf) {
    FlexTable data = new FlexTable();
    for (int i = 0; i < vf.getFieldValues().size(); i++) {
        final VerifyField fld = (VerifyField) vf.getFieldValues().get(i);
        data.setWidget(i, 1, new SmallLabel(fld.getFieldName() + ":"));
        data.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT);
        final ListBox opr = new ListBox();
        opr.addItem(TestScenarioConstants.INSTANCE.equalsScenario(), "==");
        opr.addItem(TestScenarioConstants.INSTANCE.doesNotEqualScenario(), "!=");
        if (fld.getOperator().equals("==")) {
            opr.setSelectedIndex(0);
        } else {
            opr.setSelectedIndex(1);
        }
        opr.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                fld.setOperator(opr.getValue(opr.getSelectedIndex()));
            }
        });
        data.setWidget(i, 2, opr);
        Widget cellEditor = new VerifyFieldConstraintEditor(type, new ValueChanged() {

            public void valueChanged(String newValue) {
                fld.setExpected(newValue);
            }
        }, fld, oracle, this.scenario, this.executionTrace);
        data.setWidget(i, 3, cellEditor);
        Button deleteButton = new Button();
        deleteButton.setIcon(IconType.TRASH);
        deleteButton.setTitle(TestScenarioConstants.INSTANCE.RemoveThisFieldExpectation());
        deleteButton.addClickHandler(clickEvent -> {
            if (Window.confirm(TestScenarioConstants.INSTANCE.AreYouSureYouWantToRemoveThisFieldExpectation(fld.getFieldName()))) {
                vf.getFieldValues().remove(fld);
                FlexTable renderedTableAfterDelete = render(vf);
                outer.setWidget(1, 0, renderedTableAfterDelete);
            }
        });
        data.setWidget(i, 4, deleteButton);
        if (showResults && fld.getSuccessResult() != null) {
            if (!fld.getSuccessResult().booleanValue()) {
                data.setWidget(i, 0, new Image(CommonImages.INSTANCE.warning()));
                data.setWidget(i, 5, new HTML(TestScenarioConstants.INSTANCE.ActualResult(fld.getActualResult())));
                data.getCellFormatter().addStyleName(i, 5, // NON-NLS
                "testErrorValue");
            } else {
                data.setWidget(i, 0, new Image(TestScenarioImages.INSTANCE.testPassed()));
            }
        }
    }
    ScenarioUtils.addBottomAndRightPaddingToTableCells(data);
    return data;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) VerifyField(org.drools.workbench.models.testscenarios.shared.VerifyField) FlexTable(com.google.gwt.user.client.ui.FlexTable) Widget(com.google.gwt.user.client.ui.Widget) HTML(com.google.gwt.user.client.ui.HTML) Image(com.google.gwt.user.client.ui.Image) ValueChanged(org.uberfire.ext.widgets.common.client.common.ValueChanged) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 97 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler in project drools-wb by kiegroup.

the class GuidedScoreCardEditor method addCharacteristic.

private FlexTable addCharacteristic(final Characteristic characteristic) {
    final FlexTable cGrid = new FlexTable();
    cGrid.setBorderWidth(0);
    cGrid.setCellPadding(1);
    cGrid.setCellSpacing(1);
    cGrid.setStyleName("rule-ListHeader");
    Button btnAddAttribute = new Button(GuidedScoreCardConstants.INSTANCE.addAttribute(), new ClickHandler() {

        public void onClick(final ClickEvent event) {
            addAttribute(cGrid, null);
        }
    });
    Button btnRemoveCharacteristic = new Button(GuidedScoreCardConstants.INSTANCE.removeCharacteristic(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            removeCharacteristic(cGrid);
        }
    });
    String selectedFact = "";
    if (characteristic != null) {
        selectedFact = characteristic.getFact();
        if (selectedFact.lastIndexOf(".") > -1) {
            selectedFact = selectedFact.substring(selectedFact.lastIndexOf(".") + 1);
        }
    }
    // Fields List Box
    final ListBox dropDownFields = new ListBox();
    // Facts List Box
    final ListBox dropDownFacts = new ListBox();
    final String[] eligibleFacts = oracle.getFactTypes();
    for (final String factType : eligibleFacts) {
        dropDownFacts.addItem(factType);
    }
    dropDownFacts.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(final ChangeEvent event) {
            characteristicFactChanged(characteristic, dropDownFacts, dropDownFields);
        }
    });
    final int selectedFactIndex = Arrays.asList(eligibleFacts).indexOf(selectedFact);
    dropDownFacts.setSelectedIndex(selectedFactIndex >= 0 ? selectedFactIndex : 0);
    characteristicFactChanged(characteristic, dropDownFacts, dropDownFields);
    cGrid.setWidget(0, 0, new Label(GuidedScoreCardConstants.INSTANCE.name()));
    final TextBox tbName = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
    cGrid.setWidget(0, 1, tbName);
    cGrid.setWidget(0, 2, btnRemoveCharacteristic);
    cGrid.setWidget(0, 3, btnAddAttribute);
    cGrid.setWidget(1, 0, new Label(GuidedScoreCardConstants.INSTANCE.fact()));
    cGrid.setWidget(1, 1, new Label(GuidedScoreCardConstants.INSTANCE.characteristic()));
    cGrid.setWidget(1, 2, new Label(GuidedScoreCardConstants.INSTANCE.baselineScore()));
    cGrid.setWidget(1, 3, new Label(GuidedScoreCardConstants.INSTANCE.reasonCode()));
    cGrid.setWidget(2, 0, dropDownFacts);
    cGrid.setWidget(2, 1, dropDownFields);
    final TextBox tbBaseline = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_DOUBLE);
    final boolean useReasonCodesValue = "true".equalsIgnoreCase(ddUseReasonCode.getValue(ddUseReasonCode.getSelectedIndex()));
    tbBaseline.setEnabled(useReasonCodesValue);
    cGrid.setWidget(2, 2, tbBaseline);
    final TextBox tbReasonCode = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
    tbReasonCode.setEnabled(useReasonCodesValue);
    cGrid.setWidget(2, 3, tbReasonCode);
    final SimplePanel gapPanel = new SimplePanel();
    gapPanel.add(new HTML("<br/>"));
    final VerticalPanel panel = new VerticalPanel();
    panel.add(cGrid);
    characteristicsAttrPanelMap.put(cGrid, panel);
    // panel.add( addAttributeCellTable( cGrid, characteristic ) );
    panel.setWidth("100%");
    DecoratorPanel decoratorPanel = new DecoratorPanel();
    decoratorPanel.add(panel);
    characteristicsPanel.add(decoratorPanel);
    characteristicsPanel.add(gapPanel);
    characteristicsTables.add(cGrid);
    cGrid.getColumnFormatter().setWidth(0, "150px");
    cGrid.getColumnFormatter().setWidth(1, "250px");
    cGrid.getColumnFormatter().setWidth(2, "150px");
    cGrid.getColumnFormatter().setWidth(3, "150px");
    if (characteristic != null) {
        tbReasonCode.setValue(characteristic.getReasonCode());
        tbBaseline.setValue("" + characteristic.getBaselineScore());
        tbName.setValue(characteristic.getName());
    }
    return cGrid;
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) Label(com.google.gwt.user.client.ui.Label) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) HTML(com.google.gwt.user.client.ui.HTML) TextBox(org.gwtbootstrap3.client.ui.TextBox) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) Button(org.gwtbootstrap3.client.ui.Button) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) DecoratorPanel(com.google.gwt.user.client.ui.DecoratorPanel) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 98 with ChangeHandler

use of com.google.gwt.event.dom.client.ChangeHandler in project drools-wb by kiegroup.

the class GuidedScoreCardEditor method booleanEditor.

private ListBox booleanEditor(final String currentValue) {
    final ListBox listBox = listBoxEditor(booleanOperators, currentValue, false);
    listBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(final ChangeEvent event) {
            final int selectedIndex = listBox.getSelectedIndex();
            final String selectedValue = listBox.getItemText(selectedIndex);
            final boolean enabled = "true".equalsIgnoreCase(selectedValue);
            ddReasonCodeAlgorithm.setEnabled(enabled);
            tbBaselineScore.setEnabled(enabled);
            ddReasonCodeField.setEnabled(enabled);
            for (final FlexTable cGrid : characteristicsTables) {
                // baseline score for each characteristic
                ((TextBox) cGrid.getWidget(2, 2)).setEnabled(enabled);
                // reason code for each characteristic
                ((TextBox) cGrid.getWidget(2, 3)).setEnabled(enabled);
            }
        }
    });
    return listBox;
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FlexTable(com.google.gwt.user.client.ui.FlexTable) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Aggregations

ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)98 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)98 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)41 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)41 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)31 ListBox (org.gwtbootstrap3.client.ui.ListBox)31 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)28 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)27 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)27 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)27 ArrayList (java.util.ArrayList)21 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)20 PerunError (cz.metacentrum.perun.webgui.model.PerunError)16 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)15 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)13 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)12 HashMap (java.util.HashMap)11 Map (java.util.Map)9 Button (org.gwtbootstrap3.client.ui.Button)9 HTML (com.google.gwt.user.client.ui.HTML)7