Search in sources :

Example 21 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.

the class CallMethodWidget method getSetterLabel.

private Widget getSetterLabel() {
    HorizontalPanel horiz = new HorizontalPanel();
    if (mCall.getState() == ActionCallMethod.TYPE_UNDEFINED) {
        Image edit = TestScenarioAltedImages.INSTANCE.AddFieldToFact();
        edit.setTitle(TestScenarioConstants.INSTANCE.AddAnotherFieldToThisSoYouCanSetItsValue());
        edit.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                Image w = (Image) event.getSource();
                showAddFieldPopup(w);
            }
        });
        // NON-NLS
        horiz.add(new SmallLabel(HumanReadable.getActionDisplayName("call") + " [" + mCall.getVariable() + "]"));
        horiz.add(edit);
    } else {
        // NON-NLS
        horiz.add(new SmallLabel(HumanReadable.getActionDisplayName("call") + " [" + mCall.getVariable() + "." + mCall.getMethodName() + "]"));
    }
    return horiz;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) Image(com.google.gwt.user.client.ui.Image)

Example 22 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.

the class VerifyRulesFiredWidget method render.

private FlexTable render(final FixtureList rfl, final Scenario sc) {
    FlexTable data = new FlexTable();
    for (int i = 0; i < rfl.size(); i++) {
        final VerifyRuleFired v = (VerifyRuleFired) rfl.get(i);
        if (showResults && v.getSuccessResult() != null) {
            if (!v.getSuccessResult().booleanValue()) {
                data.setWidget(i, 0, new Image(CommonImages.INSTANCE.warning()));
                data.setWidget(i, 4, new HTML(TestScenarioConstants.INSTANCE.ActualResult(v.getActualResult().toString())));
                data.getCellFormatter().addStyleName(i, 4, // NON-NLS
                "testErrorValue");
            } else {
                data.setWidget(i, 0, new Image(TestScenarioImages.INSTANCE.testPassed()));
            }
        }
        data.setWidget(i, 1, new SmallLabel(v.getRuleName() + ":"));
        data.getFlexCellFormatter().setAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
        final ListBox b = new ListBox();
        b.addItem(TestScenarioConstants.INSTANCE.firedAtLeastOnce(), "y");
        b.addItem(TestScenarioConstants.INSTANCE.didNotFire(), "n");
        b.addItem(TestScenarioConstants.INSTANCE.firedThisManyTimes(), "e");
        final TextBox num = new TextBox();
        ((InputElement) num.getElement().cast()).setSize(5);
        if (v.getExpectedFire() != null) {
            b.setSelectedIndex((v.getExpectedFire().booleanValue()) ? 0 : 1);
            num.setVisible(false);
        } else {
            b.setSelectedIndex(2);
            String xc = (v.getExpectedCount() != null) ? "" + v.getExpectedCount().intValue() : "0";
            num.setText(xc);
        }
        b.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                String s = b.getValue(b.getSelectedIndex());
                if (s.equals("y") || s.equals("n")) {
                    num.setVisible(false);
                    v.setExpectedFire((s.equals("y")) ? Boolean.TRUE : Boolean.FALSE);
                    v.setExpectedCount(null);
                } else {
                    num.setVisible(true);
                    v.setExpectedFire(null);
                    num.setText("1");
                    v.setExpectedCount(Integer.valueOf(1));
                }
            }
        });
        b.addItem(TestScenarioConstants.INSTANCE.ChooseDotDotDot());
        num.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                v.setExpectedCount(Integer.valueOf(num.getText()));
            }
        });
        HorizontalPanel h = new HorizontalPanel();
        h.add(b);
        h.add(num);
        data.setWidget(i, 2, h);
        Button del = new Button();
        del.setIcon(IconType.TRASH);
        del.setTitle(TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation());
        del.addClickHandler(clickEvent -> {
            if (Window.confirm(TestScenarioConstants.INSTANCE.AreYouSureYouWantToRemoveThisRuleExpectation())) {
                rfl.remove(v);
                sc.removeFixture(v);
                outer.setWidget(1, 0, render(rfl, sc));
            }
        });
        data.setWidget(i, 3, del);
        // we only want numbers here...
        num.addKeyPressHandler(new KeyPressHandler() {

            public void onKeyPress(KeyPressEvent event) {
                if (Character.isLetter(event.getCharCode())) {
                    ((TextBox) event.getSource()).cancelKey();
                }
            }
        });
    }
    ScenarioUtils.addBottomAndRightPaddingToTableCells(data);
    return data;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) VerifyRuleFired(org.drools.workbench.models.testscenarios.shared.VerifyRuleFired) FlexTable(com.google.gwt.user.client.ui.FlexTable) HTML(com.google.gwt.user.client.ui.HTML) TextBox(org.gwtbootstrap3.client.ui.TextBox) InputElement(com.google.gwt.dom.client.InputElement) Image(com.google.gwt.user.client.ui.Image) KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 23 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.

the class ColumnsPagePresenter method makeMetaDataWidget.

HorizontalPanel makeMetaDataWidget(final GuidedDecisionTableModellerView.Presenter modeller, final MetadataCol52 metaDataColumn) {
    final HorizontalPanel horizontalPanel = makeHorizontalPanel();
    final ColumnLabelWidget label = makeColumnLabel(metaDataColumn);
    final boolean isEditable = modeller.isActiveDecisionTableEditable();
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.add(label);
    horizontalPanel.add(hideColumnCheckBox(modeller, metaDataColumn));
    if (isEditable) {
        horizontalPanel.add(deleteMetaDataColumnAnchor(modeller, metaDataColumn));
    }
    return horizontalPanel;
}
Also used : ColumnLabelWidget(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.control.ColumnLabelWidget) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel)

Example 24 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.

the class ColumnManagementView method renderColumns.

public void renderColumns(final Map<String, List<BaseColumn>> columnGroups) {
    clear();
    for (String groupLabel : columnGroups.keySet()) {
        final VerticalPanel columnGroup = new VerticalPanel();
        final HorizontalPanel columnGroupHeader = new HorizontalPanel();
        final VerticalPanel columnGroupColumns = new VerticalPanel();
        columnGroupHeader.add(new Label(groupLabel));
        columnGroup.add(columnGroupHeader);
        columnGroup.add(columnGroupColumns);
        add(columnGroup);
        for (final BaseColumn column : columnGroups.get(groupLabel)) {
            if (column instanceof ActionCol52) {
                columnGroupColumns.add(renderColumn((ActionCol52) column));
            } else if (column instanceof BRLConditionColumn) {
                columnGroupColumns.add(renderColumn((BRLConditionColumn) column));
            } else if (column instanceof Pattern52) {
                renderColumn((Pattern52) column).forEach(columnGroupColumns::add);
            }
        }
    }
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) Label(com.google.gwt.user.client.ui.Label) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 25 with HorizontalPanel

use of com.google.gwt.user.client.ui.HorizontalPanel in project drools-wb by kiegroup.

the class ColumnsPagePresenterTest method testMakeMetaDataWidgetWhenDecisionTableIsNotEditable.

@Test
public void testMakeMetaDataWidgetWhenDecisionTableIsNotEditable() {
    final HorizontalPanel expectedHorizontalPanel = mock(HorizontalPanel.class);
    final ColumnLabelWidget columnLabelWidget = mock(ColumnLabelWidget.class);
    final CheckBox hideColumnCheckBox = mock(CheckBox.class);
    final DeleteColumnManagementAnchorWidget deleteColumnManagementAnchorWidget = mock(DeleteColumnManagementAnchorWidget.class);
    final boolean isEditable = false;
    doReturn(expectedHorizontalPanel).when(presenter).makeHorizontalPanel();
    doReturn(columnLabelWidget).when(presenter).makeColumnLabel(metadataColumn);
    doReturn(hideColumnCheckBox).when(presenter).hideColumnCheckBox(modeller, metadataColumn);
    doReturn(deleteColumnManagementAnchorWidget).when(presenter).deleteMetaDataColumnAnchor(modeller, metadataColumn);
    doReturn(isEditable).when(modeller).isActiveDecisionTableEditable();
    final HorizontalPanel actualHorizontalPanel = presenter.makeMetaDataWidget(modeller, metadataColumn);
    verify(actualHorizontalPanel).setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verify(actualHorizontalPanel).add(columnLabelWidget);
    verify(actualHorizontalPanel).add(hideColumnCheckBox);
    verify(actualHorizontalPanel, never()).add(deleteColumnManagementAnchorWidget);
    assertEquals(expectedHorizontalPanel, actualHorizontalPanel);
}
Also used : ColumnLabelWidget(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.control.ColumnLabelWidget) CheckBox(org.gwtbootstrap3.client.ui.CheckBox) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) DeleteColumnManagementAnchorWidget(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.control.DeleteColumnManagementAnchorWidget) Test(org.junit.Test)

Aggregations

HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)75 Label (com.google.gwt.user.client.ui.Label)25 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)24 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)21 Image (com.google.gwt.user.client.ui.Image)15 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)14 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)11 HTML (com.google.gwt.user.client.ui.HTML)8 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)7 Widget (com.google.gwt.user.client.ui.Widget)7 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)7 Button (org.gwtbootstrap3.client.ui.Button)7 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)6 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)6 TextBox (com.google.gwt.user.client.ui.TextBox)6 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)5 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)5 TextBox (org.gwtbootstrap3.client.ui.TextBox)5 InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)5 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)4