Search in sources :

Example 51 with Widget

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

the class RuleAttributeWidget method getEditorWidget.

private Widget getEditorWidget(final RuleAttribute at, final int idx, final boolean isReadOnly) {
    Widget editor = null;
    final String attributeName = at.getAttributeName();
    if (attributeName.equals(RULEFLOW_GROUP_ATTR) || attributeName.equals(AGENDA_GROUP_ATTR) || attributeName.equals(ACTIVATION_GROUP_ATTR) || attributeName.equals(TIMER_ATTR) || attributeName.equals(CALENDARS_ATTR)) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
        tb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            tb.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {
                    at.setValue(tb.getValue());
                }
            });
        }
        tb.setValue(at.getValue());
        editor = tb;
    } else if (attributeName.equals(SALIENCE_ATTR)) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_INTEGER);
        tb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            tb.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {
                    at.setValue(tb.getValue());
                }
            });
        }
        tb.setValue(at.getValue());
        editor = tb;
    } else if (attributeName.equals(DURATION_ATTR)) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_LONG);
        tb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            tb.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {
                    at.setValue(tb.getValue());
                }
            });
        }
        tb.setValue(at.getValue());
        editor = tb;
    } else if (attributeName.equals(NO_LOOP_ATTR) || attributeName.equals(LOCK_ON_ACTIVE_ATTR) || attributeName.equals(AUTO_FOCUS_ATTR) || attributeName.equals(ENABLED_ATTR)) {
        editor = checkBoxEditor(at, isReadOnly);
    } else if (attributeName.equals(DATE_EFFECTIVE_ATTR) || attributeName.equals(DATE_EXPIRES_ATTR)) {
        if (isReadOnly) {
            final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
            tb.setValue(at.getValue());
            tb.setEnabled(false);
        } else {
            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()));
                    at.setValue(sDate);
                }
            });
            datePicker.setFormat(DATE_FORMAT);
            datePicker.setValue(assertDateValue(at));
            editor = datePicker;
        }
    } else if (attributeName.equals(DIALECT_ATTR)) {
        final ListBox lb = new ListBox();
        lb.addItem(DIALECTS[0]);
        lb.addItem(DIALECTS[1]);
        lb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            lb.addChangeHandler(new ChangeHandler() {

                @Override
                public void onChange(ChangeEvent event) {
                    final int selectedIndex = lb.getSelectedIndex();
                    if (selectedIndex < 0) {
                        return;
                    }
                    at.setValue(lb.getValue(selectedIndex));
                }
            });
        }
        if (at.getValue() == null || at.getValue().isEmpty()) {
            lb.setSelectedIndex(1);
            at.setValue(DIALECTS[1]);
        } else if (at.getValue().equals(DIALECTS[0])) {
            lb.setSelectedIndex(0);
        } else if (at.getValue().equals(DIALECTS[1])) {
            lb.setSelectedIndex(1);
        } else {
            lb.setSelectedIndex(1);
            at.setValue(DIALECTS[1]);
        }
        editor = lb;
    }
    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
    if (editor != null) {
        horiz.add(editor);
        if (!isReadOnly) {
            horiz.add(getRemoveIcon(idx));
        }
    }
    return horiz;
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) Widget(com.google.gwt.user.client.ui.Widget) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) TextBox(org.gwtbootstrap3.client.ui.TextBox) Date(java.util.Date) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) DirtyableHorizontalPane(org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane) DatePicker(org.uberfire.ext.widgets.common.client.common.DatePicker) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 52 with Widget

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

the class RuleModeller method clearLineIcons.

private void clearLineIcons(int row, int col) {
    if (layout.getCellCount(row) <= col) {
        return;
    }
    Widget widget = layout.getWidget(row, col);
    if (widget instanceof DirtyableHorizontalPane) {
        DirtyableHorizontalPane horiz = (DirtyableHorizontalPane) widget;
        horiz.clear();
    }
}
Also used : RuleModellerWidget(org.drools.workbench.screens.guided.rule.client.widget.RuleModellerWidget) Widget(com.google.gwt.user.client.ui.Widget) DirtyableHorizontalPane(org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane)

Example 53 with Widget

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

the class RuleModeller method addLineIcon.

private void addLineIcon(int row, int col, Image icon) {
    Widget widget = layout.getWidget(row, col);
    if (widget instanceof DirtyableHorizontalPane) {
        DirtyableHorizontalPane horiz = (DirtyableHorizontalPane) widget;
        horiz.add(icon);
    }
}
Also used : RuleModellerWidget(org.drools.workbench.screens.guided.rule.client.widget.RuleModellerWidget) Widget(com.google.gwt.user.client.ui.Widget) DirtyableHorizontalPane(org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane)

Example 54 with Widget

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

the class ActionInsertFactWidget method getAssertLabel.

private Widget getAssertLabel() {
    ClickHandler cl = new ClickHandler() {

        public void onClick(ClickEvent event) {
            Widget w = (Widget) event.getSource();
            showAddFieldPopup(w);
        }
    };
    // NON-NLS
    String assertType = "assert";
    if (this.model instanceof ActionInsertLogicalFact) {
        // NON-NLS
        assertType = "assertLogical";
    }
    String lbl = (model.isBound() == false) ? HumanReadable.getActionDisplayName(assertType) + " <b>" + this.model.getFactType() + "</b>" : HumanReadable.getActionDisplayName(assertType) + " <b>" + this.model.getFactType() + "</b>" + " <b>[" + model.getBoundName() + "]</b>";
    if (this.model.getFieldValues() != null && model.getFieldValues().length > 0) {
        lbl = lbl + ":";
    }
    return new ClickableLabel(lbl, cl, !this.readOnly);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Widget(com.google.gwt.user.client.ui.Widget) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) ActionInsertLogicalFact(org.drools.workbench.models.datamodel.rule.ActionInsertLogicalFact)

Example 55 with Widget

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

the class GuidedScoreCardEditor method removeCharacteristic.

private void removeCharacteristic(final FlexTable selectedTable) {
    if (selectedTable != null) {
        final TextBox tbName = (TextBox) selectedTable.getWidget(0, 1);
        String name = tbName.getValue();
        if (name == null || name.trim().length() == 0) {
            name = "Untitled";
        }
        final String msg = GuidedScoreCardConstants.INSTANCE.promptDeleteCharacteristic0(name);
        if (Window.confirm(msg)) {
            characteristicsTables.remove(selectedTable);
            characteristicsAttrMap.remove(selectedTable);
            final Widget parent = selectedTable.getParent().getParent();
            final int i = characteristicsPanel.getWidgetIndex(parent);
            characteristicsPanel.remove(parent);
            characteristicsPanel.remove(i);
        }
    }
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) TextBox(org.gwtbootstrap3.client.ui.TextBox)

Aggregations

Widget (com.google.gwt.user.client.ui.Widget)194 Test (org.junit.Test)22 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)16 IsWidget (com.google.gwt.user.client.ui.IsWidget)16 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)15 HTML (com.google.gwt.user.client.ui.HTML)10 ArrayList (java.util.ArrayList)10 IFrameTabPanel (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)10 Element (com.google.gwt.dom.client.Element)9 MaterialWidget (gwt.material.design.client.base.MaterialWidget)9 Label (com.google.gwt.user.client.ui.Label)8 ListItem (gwt.material.design.client.ui.html.ListItem)8 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 FileItem (org.pentaho.mantle.client.solutionbrowser.filelist.FileItem)7 Image (com.google.gwt.user.client.ui.Image)6 CubaFileUploadWidget (com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget)6 Timer (com.google.gwt.user.client.Timer)5