Example usage for com.google.gwt.user.client.ui TextBox setVisibleLength

List of usage examples for com.google.gwt.user.client.ui TextBox setVisibleLength

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui TextBox setVisibleLength.

Prototype

public void setVisibleLength(int length) 

Source Link

Document

Sets the number of visible characters in the text box.

Usage

From source file:org.drools.guvnor.client.ruleeditor.MetaDataWidgetNew.java

License:Apache License

/**
 * This binds a field, and returns a TextBox editor for it.
 * //from ww w.j ava 2  s .co  m
 * @param bind
 *            Interface to bind to.
 * @param toolTip
 *            tool tip.
 * @return
 */
private Widget editableText(final FieldBinding bind, String toolTip) {
    if (!readOnly) {
        final TextBox tbox = new TextBox();
        tbox.setTitle(toolTip);
        tbox.setText(bind.getValue());
        tbox.setVisibleLength(10);
        ChangeHandler listener = new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                String txt = tbox.getText();
                bind.setValue(txt);
            }

        };
        tbox.addChangeHandler(listener);
        return tbox;
    } else {
        return new Label(bind.getValue());
    }
}

From source file:org.drools.workbench.screens.guided.dtable.client.widget.GuidedDecisionTableWidget.java

License:Apache License

private Widget newColumn() {
    AddButton addButton = new AddButton();
    addButton.setText(GuidedDecisionTableConstants.INSTANCE.NewColumn());
    addButton.setTitle(GuidedDecisionTableConstants.INSTANCE.AddNewColumn());

    addButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            final FormStylePopup pop = new FormStylePopup(GuidedDecisionTableConstants.INSTANCE.AddNewColumn());

            //List of basic column types
            final ListBox choice = new ListBox();
            choice.setVisibleItemCount(NewColumnTypes.values().length);
            choice.setWidth((Window.getClientWidth() * 0.25) + "px");

            choice.addItem(GuidedDecisionTableConstants.INSTANCE.AddNewMetadataOrAttributeColumn(),
                    NewColumnTypes.METADATA_ATTRIBUTE.name());
            choice.addItem(SECTION_SEPARATOR);
            choice.addItem(GuidedDecisionTableConstants.INSTANCE.AddNewConditionSimpleColumn(),
                    NewColumnTypes.CONDITION_SIMPLE.name());
            choice.addItem(SECTION_SEPARATOR);
            choice.addItem(GuidedDecisionTableConstants.INSTANCE.SetTheValueOfAField(),
                    NewColumnTypes.ACTION_UPDATE_FACT_FIELD.name());
            choice.addItem(GuidedDecisionTableConstants.INSTANCE.SetTheValueOfAFieldOnANewFact(),
                    NewColumnTypes.ACTION_INSERT_FACT_FIELD.name());
            choice.addItem(GuidedDecisionTableConstants.INSTANCE.DeleteAnExistingFact(),
                    NewColumnTypes.ACTION_RETRACT_FACT.name());

            //Checkbox to include Advanced Action types
            final CheckBox chkIncludeAdvancedOptions = new CheckBox(
                    SafeHtmlUtils.fromString(GuidedDecisionTableConstants.INSTANCE.IncludeAdvancedOptions()));
            chkIncludeAdvancedOptions.setValue(false);
            chkIncludeAdvancedOptions.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    if (chkIncludeAdvancedOptions.getValue()) {
                        addItem(3, GuidedDecisionTableConstants.INSTANCE.AddNewConditionBRLFragment(),
                                NewColumnTypes.CONDITION_BRL_FRAGMENT.name());
                        addItem(GuidedDecisionTableConstants.INSTANCE.WorkItemAction(),
                                NewColumnTypes.ACTION_WORKITEM.name());
                        addItem(GuidedDecisionTableConstants.INSTANCE.WorkItemActionSetField(),
                                NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name());
                        addItem(GuidedDecisionTableConstants.INSTANCE.WorkItemActionInsertFact(),
                                NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name());
                        addItem(GuidedDecisionTableConstants.INSTANCE.AddNewActionBRLFragment(),
                                NewColumnTypes.ACTION_BRL_FRAGMENT.name());
                    } else {
                        removeItem(NewColumnTypes.CONDITION_BRL_FRAGMENT.name());
                        removeItem(NewColumnTypes.ACTION_WORKITEM.name());
                        removeItem(NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name());
                        removeItem(NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name());
                        removeItem(NewColumnTypes.ACTION_BRL_FRAGMENT.name());
                    }/* w  w w  .  j a v  a 2  s  . c o m*/
                }

                private void addItem(int index, String item, String value) {
                    for (int itemIndex = 0; itemIndex < choice.getItemCount(); itemIndex++) {
                        if (choice.getValue(itemIndex).equals(value)) {
                            return;
                        }
                    }
                    choice.insertItem(item, value, index);
                }

                private void addItem(String item, String value) {
                    for (int itemIndex = 0; itemIndex < choice.getItemCount(); itemIndex++) {
                        if (choice.getValue(itemIndex).equals(value)) {
                            return;
                        }
                    }
                    choice.addItem(item, value);
                }

                private void removeItem(String value) {
                    for (int itemIndex = 0; itemIndex < choice.getItemCount(); itemIndex++) {
                        if (choice.getValue(itemIndex).equals(value)) {
                            choice.removeItem(itemIndex);
                            break;
                        }
                    }
                }

            });

            //OK button to create column
            final ModalFooterOKCancelButtons footer = new ModalFooterOKCancelButtons(new Command() {
                @Override
                public void execute() {
                    String s = choice.getValue(choice.getSelectedIndex());
                    if (s.equals(NewColumnTypes.METADATA_ATTRIBUTE.name())) {
                        showMetaDataAndAttribute();
                    } else if (s.equals(NewColumnTypes.CONDITION_SIMPLE.name())) {
                        showConditionSimple();
                    } else if (s.equals(NewColumnTypes.CONDITION_BRL_FRAGMENT.name())) {
                        showConditionBRLFragment();
                    } else if (s.equals(NewColumnTypes.ACTION_UPDATE_FACT_FIELD.name())) {
                        showActionSet();
                    } else if (s.equals(NewColumnTypes.ACTION_INSERT_FACT_FIELD.name())) {
                        showActionInsert();
                    } else if (s.equals(NewColumnTypes.ACTION_RETRACT_FACT.name())) {
                        showActionRetract();
                    } else if (s.equals(NewColumnTypes.ACTION_WORKITEM.name())) {
                        showActionWorkItemAction();
                    } else if (s.equals(NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name())) {
                        showActionWorkItemActionSet();
                    } else if (s.equals(NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name())) {
                        showActionWorkItemActionInsert();
                    } else if (s.equals(NewColumnTypes.ACTION_BRL_FRAGMENT.name())) {
                        showActionBRLFragment();
                    }
                    pop.hide();
                }

                private void showMetaDataAndAttribute() {
                    // show choice of attributes
                    final Image image = GuidedDecisionTableImageResources508.INSTANCE.Config();
                    final FormStylePopup pop = new FormStylePopup(image,
                            GuidedDecisionTableConstants.INSTANCE.AddAnOptionToTheRule());
                    final ListBox list = RuleAttributeWidget.getAttributeList();

                    //This attribute is only used for Decision Tables
                    list.addItem(GuidedDecisionTable52.NEGATE_RULE_ATTR);

                    // Remove any attributes already added
                    for (AttributeCol52 col : model.getAttributeCols()) {
                        for (int iItem = 0; iItem < list.getItemCount(); iItem++) {
                            if (list.getItemText(iItem).equals(col.getAttribute())) {
                                list.removeItem(iItem);
                                break;
                            }
                        }
                    }

                    final Image addbutton = GuidedDecisionTableImageResources508.INSTANCE.NewItem();
                    final TextBox box = new TextBox();
                    box.setVisibleLength(15);

                    list.setSelectedIndex(0);

                    list.addChangeHandler(new ChangeHandler() {
                        public void onChange(ChangeEvent event) {
                            AttributeCol52 attr = new AttributeCol52();
                            attr.setAttribute(list.getItemText(list.getSelectedIndex()));
                            dtable.addColumn(attr);
                            refreshAttributeWidget();
                            pop.hide();
                        }
                    });

                    addbutton.setTitle(GuidedDecisionTableConstants.INSTANCE.AddMetadataToTheRule());

                    addbutton.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent w) {

                            String metadata = box.getText();
                            if (!isUnique(metadata)) {
                                Window.alert(GuidedDecisionTableConstants.INSTANCE
                                        .ThatColumnNameIsAlreadyInUsePleasePickAnother());
                                return;
                            }
                            MetadataCol52 met = new MetadataCol52();
                            met.setHideColumn(true);
                            met.setMetadata(metadata);
                            dtable.addColumn(met);
                            refreshAttributeWidget();
                            pop.hide();
                        }

                        private boolean isUnique(String metadata) {
                            for (MetadataCol52 mc : model.getMetadataCols()) {
                                if (metadata.equals(mc.getMetadata())) {
                                    return false;
                                }
                            }
                            return true;
                        }

                    });
                    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
                    horiz.add(box);
                    horiz.add(addbutton);

                    pop.addAttribute(new StringBuilder(GuidedDecisionTableConstants.INSTANCE.Metadata1())
                            .append(GuidedDecisionTableConstants.COLON).toString(), horiz);
                    pop.addAttribute(GuidedDecisionTableConstants.INSTANCE.Attribute(), list);
                    pop.show();
                }

                private void showConditionSimple() {
                    final ConditionCol52 column = makeNewConditionColumn();
                    ConditionPopup dialog = new ConditionPopup(model, oracle, new ConditionColumnCommand() {
                        public void execute(Pattern52 pattern, ConditionCol52 column) {

                            //Update UI
                            dtable.addColumn(pattern, column);
                            refreshConditionsWidget();
                        }
                    }, column, true, isReadOnly);
                    dialog.show();
                }

                private void showConditionBRLFragment() {
                    final BRLConditionColumn column = makeNewConditionBRLFragment();
                    switch (model.getTableFormat()) {
                    case EXTENDED_ENTRY:
                        BRLConditionColumnViewImpl popup = new BRLConditionColumnViewImpl(path, model, oracle,
                                ruleNameService, column, eventBus, true, isReadOnly);
                        popup.setPresenter(BRL_CONDITION_PRESENTER);
                        popup.show();
                        break;
                    case LIMITED_ENTRY:
                        LimitedEntryBRLConditionColumnViewImpl limtedEntryPopup = new LimitedEntryBRLConditionColumnViewImpl(
                                path, model, oracle, ruleNameService, (LimitedEntryBRLConditionColumn) column,
                                eventBus, true, isReadOnly);
                        limtedEntryPopup.setPresenter(LIMITED_ENTRY_BRL_CONDITION_PRESENTER);
                        limtedEntryPopup.show();
                        break;
                    }
                }

                private void showActionInsert() {
                    final ActionInsertFactCol52 afc = makeNewActionInsertColumn();
                    ActionInsertFactPopup ins = new ActionInsertFactPopup(model, oracle,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, afc, true, isReadOnly);
                    ins.show();
                }

                private void showActionSet() {
                    final ActionSetFieldCol52 afc = makeNewActionSetColumn();
                    ActionSetFieldPopup set = new ActionSetFieldPopup(model, oracle,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, afc, true, isReadOnly);
                    set.show();
                }

                private void showActionRetract() {
                    final ActionRetractFactCol52 arf = makeNewActionRetractFact();
                    ActionRetractFactPopup popup = new ActionRetractFactPopup(model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, arf, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemAction() {
                    final ActionWorkItemCol52 awi = makeNewActionWorkItem();
                    ActionWorkItemPopup popup = new ActionWorkItemPopup(path, model,
                            GuidedDecisionTableWidget.this, new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awi, workItemDefinitions, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemActionSet() {
                    final ActionWorkItemSetFieldCol52 awisf = makeNewActionWorkItemSetField();
                    ActionWorkItemSetFieldPopup popup = new ActionWorkItemSetFieldPopup(model, oracle,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awisf, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemActionInsert() {
                    final ActionWorkItemInsertFactCol52 awiif = makeNewActionWorkItemInsertFact();
                    ActionWorkItemInsertFactPopup popup = new ActionWorkItemInsertFactPopup(model, oracle,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awiif, true, isReadOnly);
                    popup.show();
                }

                private void showActionBRLFragment() {
                    final BRLActionColumn column = makeNewActionBRLFragment();
                    switch (model.getTableFormat()) {
                    case EXTENDED_ENTRY:
                        BRLActionColumnViewImpl popup = new BRLActionColumnViewImpl(path, model, oracle,
                                ruleNameService, column, eventBus, true, isReadOnly);
                        popup.setPresenter(BRL_ACTION_PRESENTER);
                        popup.show();
                        break;
                    case LIMITED_ENTRY:
                        LimitedEntryBRLActionColumnViewImpl limtedEntryPopup = new LimitedEntryBRLActionColumnViewImpl(
                                path, model, oracle, ruleNameService, (LimitedEntryBRLActionColumn) column,
                                eventBus, true, isReadOnly);
                        limtedEntryPopup.setPresenter(LIMITED_ENTRY_BRL_ACTION_PRESENTER);
                        limtedEntryPopup.show();
                        break;
                    }

                }

                private void newActionAdded(ActionCol52 column) {
                    dtable.addColumn(column);
                    refreshActionsWidget();
                }
            }, new Command() {
                @Override
                public void execute() {
                    pop.hide();
                }
            });

            //If a separator is clicked disable OK button
            choice.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    int itemIndex = choice.getSelectedIndex();
                    if (itemIndex < 0) {
                        return;
                    }
                    footer.enableOkButton(!choice.getValue(itemIndex).equals(SECTION_SEPARATOR));
                }

            });

            pop.setTitle(GuidedDecisionTableConstants.INSTANCE.AddNewColumn());
            pop.addAttribute(GuidedDecisionTableConstants.INSTANCE.TypeOfColumn(), choice);
            pop.addAttribute("", chkIncludeAdvancedOptions);
            pop.add(footer);
            pop.show();
        }

        private ConditionCol52 makeNewConditionColumn() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryConditionCol52();
            default:
                return new ConditionCol52();
            }
        }

        private ActionInsertFactCol52 makeNewActionInsertColumn() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryActionInsertFactCol52();
            default:
                return new ActionInsertFactCol52();
            }
        }

        private ActionSetFieldCol52 makeNewActionSetColumn() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryActionSetFieldCol52();
            default:
                return new ActionSetFieldCol52();
            }
        }

        private ActionRetractFactCol52 makeNewActionRetractFact() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                LimitedEntryActionRetractFactCol52 ler = new LimitedEntryActionRetractFactCol52();
                ler.setValue(new DTCellValue52(""));
                return ler;
            default:
                return new ActionRetractFactCol52();
            }
        }

        private ActionWorkItemCol52 makeNewActionWorkItem() {
            //WorkItems are defined within the column and always boolean (i.e. Limited Entry) in the table
            return new ActionWorkItemCol52();
        }

        private ActionWorkItemSetFieldCol52 makeNewActionWorkItemSetField() {
            //Actions setting Field Values from Work Item Result Parameters are always boolean (i.e. Limited Entry) in the table
            return new ActionWorkItemSetFieldCol52();
        }

        private ActionWorkItemInsertFactCol52 makeNewActionWorkItemInsertFact() {
            //Actions setting Field Values from Work Item Result Parameters are always boolean (i.e. Limited Entry) in the table
            return new ActionWorkItemInsertFactCol52();
        }

        private BRLActionColumn makeNewActionBRLFragment() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryBRLActionColumn();
            default:
                return new BRLActionColumn();
            }
        }

        private BRLConditionColumn makeNewConditionBRLFragment() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryBRLConditionColumn();
            default:
                return new BRLConditionColumn();
            }
        }

    });

    return addButton;
}

From source file:org.drools.workbench.screens.guided.rule.client.editor.factPattern.PopupCreator.java

License:Apache License

/**
 * This adds in (optionally) the editor for changing the bound variable
 * name. If its a bindable pattern, it will show the editor, if it is
 * already bound, and the name is used, it should not be editable.
 *///ww w .  j a v a  2s .  com
private void doBindingEditor(final FormStylePopup popup) {
    if (bindable || !(modeller.getModel().isBoundFactUsed(pattern.getBoundName()))) {
        HorizontalPanel varName = new HorizontalPanel();
        final TextBox varTxt = new BindingTextBox();
        if (pattern.getBoundName() == null) {
            varTxt.setText("");
        } else {
            varTxt.setText(pattern.getBoundName());
        }

        varTxt.setVisibleLength(6);
        varName.add(varTxt);

        Button bindVar = new Button(HumanReadableConstants.INSTANCE.Set());
        bindVar.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String var = varTxt.getText();
                if (modeller.isVariableNameUsed(var)) {
                    Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
                    return;
                }
                pattern.setBoundName(varTxt.getText());
                modeller.refreshWidget();
                popup.hide();
            }
        });

        varName.add(bindVar);
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.VariableName(), varName);

    }
}

From source file:org.drools.workbench.screens.guided.rule.client.editor.RuleAttributeWidget.java

License:Apache License

private TextBox textBoxEditor(final RuleMetadata rm, final boolean isReadOnly) {
    final TextBox box = new TextBox();
    box.setEnabled(!isReadOnly);/*from   www . j  a v  a 2  s  .  c om*/
    box.setVisibleLength((rm.getValue().length() < 3) ? 3 : rm.getValue().length());
    box.setText(rm.getValue());
    box.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            rm.setValue(box.getText());
        }
    });

    box.addKeyUpHandler(new KeyUpHandler() {
        public void onKeyUp(KeyUpEvent event) {
            box.setVisibleLength(box.getText().length());
        }
    });
    return box;
}

From source file:org.drools.workbench.screens.testscenario.client.MethodParameterCallValueEditor.java

License:Apache License

private TextBox boundTextBox(final CallFieldValue c) {

    final TextBox box = TextBoxFactory.getTextBox(methodParameter.type);
    box.setStyleName("constraint-value-Editor");
    if (c.value == null) {
        box.setText("");
    } else {//from w ww  .j  ava  2s. c  o  m
        if (c.value.trim().equals("")) {
            c.value = "";
        }
        box.setText(c.value);
    }

    if (c.value == null || c.value.length() < 5) {
        box.setVisibleLength(6);
    } else {
        box.setVisibleLength(c.value.length() - 1);
    }

    box.addValueChangeHandler(new ValueChangeHandler<String>() {

        public void onValueChange(final ValueChangeEvent<String> event) {
            c.value = event.getValue();
        }

    });

    box.addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(KeyUpEvent event) {
            box.setVisibleLength(box.getText().length());
        }
    });

    return box;
}

From source file:org.drools.workbench.screens.testscenario.client.VerifyRulesFiredWidget.java

License:Apache License

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,//from  ww w.  j  a  va 2  s  . c  om
                        new HTML(TestScenarioConstants.INSTANCE.ActualResult(v.getActualResult().toString())));

                data.getCellFormatter().addStyleName(i, 4, "testErrorValue"); //NON-NLS

            } 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();
        num.setVisibleLength(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);

        Image del = CommonAltedImages.INSTANCE.DeleteItemSmall();
        del.setAltText(TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation());
        del.setTitle(TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation());
        del.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent w) {
                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();
                }
            }
        });
    }
    return data;
}

From source file:org.gwtlib.client.table.ui.PagingBar.java

License:Apache License

protected Widget createGotoWidget() {
    final TextBox gotoPage = new TextBox();
    int maxlen = String.valueOf(computeNumPages()).length();
    gotoPage.setMaxLength(maxlen);/*from w ww . ja v  a  2s.  c  o m*/
    gotoPage.setVisibleLength(maxlen);
    final PushButton go = new PushButton();
    go.setStylePrimaryName(STYLE_GOTO_BUTTON);
    go.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            setPage(Integer.parseInt(gotoPage.getText()) - 1);
            gotoPage.setText("");
            go.setEnabled(false);
            fireChange();
        }
    });
    go.setEnabled(false);
    gotoPage.addKeyDownHandler(new KeyDownHandler() {
        public void onKeyDown(final KeyDownEvent event) {
            final int keyCode = event.getNativeKeyCode();
            DeferredCommand.addCommand(new Command() {
                public void execute() {
                    int page = -1;
                    try {
                        page = Integer.parseInt(gotoPage.getText()) - 1;
                    } catch (NumberFormatException e) {
                    }
                    go.setEnabled(page >= 0 && page < computeNumPages());
                    if (keyCode == KeyCodes.KEY_ENTER && go.isEnabled()) {
                        setPage(Integer.parseInt(gotoPage.getText()) - 1);
                        gotoPage.setText("");
                        go.setEnabled(false);
                        fireChange();
                    }
                }
            });
        }
    });

    HorizontalPanel panel = new HorizontalPanel();
    panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    panel.add(new HTML(_messages.go()));
    panel.add(gotoPage);
    panel.add(go);
    panel.setStylePrimaryName(STYLE_GOTO);
    return panel;
}

From source file:org.gwtlib.client.table.ui.PagingBar.java

License:Apache License

protected void updateGotoWidget(Widget widget) {
    widget.setVisible(computeNumPages() > 1);
    // Update allowed number of characters in the goto page textbox in case page size has changed (Yuck!)
    if (widget instanceof HorizontalPanel) {
        HorizontalPanel panel = (HorizontalPanel) widget;
        if (panel.getWidgetCount() == 3 && panel.getWidget(1) instanceof TextBox) {
            TextBox gotoPage = (TextBox) panel.getWidget(1);
            int maxlen = String.valueOf(computeNumPages()).length();
            gotoPage.setMaxLength(maxlen);
            gotoPage.setVisibleLength(maxlen);
        }/*www  . j a  v  a 2  s  .c o m*/
    }
}

From source file:org.gwtlib.client.table.ui.renderer.TextBoxRenderer.java

License:Apache License

public Widget render(Row row, Column column, Object value) {
    if (value == null || !(value instanceof String)) {
        return null;
    } else {// w  w w  . ja v a2s  .c  o m
        TextBox textbox = new TextBox();
        textbox.setText((String) value);
        if (_maxLength > 0)
            textbox.setMaxLength(_maxLength);
        if (_visibleLength > 0)
            textbox.setVisibleLength(_visibleLength);
        if (_title != null)
            textbox.setTitle(_title);
        return textbox;
    }
}

From source file:org.gwtportlets.portlet.client.ui.MenuPortlet.java

License:Open Source License

public void configure() {
    final TextBox path = new TextBox();
    path.setVisibleLength(30);
    path.setTitle("Any content served from the web application " + "(JSP pages, static HTML etc.)");
    path.setText(getPath());//from w  ww  .  j  a  v a  2 s .c  om

    final CheckBox vertical = new CheckBox("Vertical menu bar");
    vertical.setTitle("Open first level sub menus to the right (true) or " + "below (false)");
    vertical.setValue(isVertical());

    FormBuilder b = new FormBuilder();
    b.label("Menu template path").field(path).endRow();
    b.field(vertical).colspan(2).endRow();

    final Dialog dlg = new Dialog();
    dlg.setText("Configure " + getWidgetName());
    dlg.setWidget(b.getForm());

    dlg.addButton(new CssButton("OK", new ClickHandler() {
        public void onClick(ClickEvent event) {
            dlg.hide();
            setPath(path.getText().trim());
            setVertical(vertical.getValue());
            refresh();
        }
    }));
    dlg.addCloseButton("Cancel");
    dlg.showNextTo(this);
}