Example usage for com.google.gwt.user.client.ui CheckBox setValue

List of usage examples for com.google.gwt.user.client.ui CheckBox setValue

Introduction

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

Prototype

@Override
public void setValue(Boolean value) 

Source Link

Document

Checks or unchecks the check box.

Usage

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModellerActionSelectorPopup.java

License:Apache License

@Override
public Widget getContent() {
    if (position == null) {
        positionCbo.addItem(Constants.INSTANCE.Bottom(), String.valueOf(this.model.rhs.length));
        positionCbo.addItem(Constants.INSTANCE.Top(), "0");
        for (int i = 1; i < model.rhs.length; i++) {
            positionCbo.addItem(Constants.INSTANCE.Line0(i), String.valueOf(i));
        }//from  w  w w . ja  v  a2  s. c  o  m
    } else {
        //if position is fixed, we just add one element to the drop down.
        positionCbo.addItem(String.valueOf(position));
        positionCbo.setSelectedIndex(0);
    }

    if (completions.getDSLConditions().length == 0 && completions.getFactTypes().length == 0) {
        layoutPanel.addRow(new HTML("<div class='highlight'>" + Constants.INSTANCE.NoModelTip() + "</div>"));
    }

    //only show the drop down if we are not using fixed position.
    if (position == null) {
        HorizontalPanel hp0 = new HorizontalPanel();
        hp0.add(new HTML(Constants.INSTANCE.PositionColon()));
        hp0.add(positionCbo);
        hp0.add(new InfoPopup(Constants.INSTANCE.PositionColon(),
                Constants.INSTANCE.ActionPositionExplanation()));
        layoutPanel.addRow(hp0);
    }

    choices = makeChoicesListBox();
    choicesPanel.add(choices);
    layoutPanel.addRow(choicesPanel);

    HorizontalPanel hp = new HorizontalPanel();
    Button ok = new Button(Constants.INSTANCE.OK());
    hp.add(ok);
    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            selectSomething();
        }
    });

    Button cancel = new Button(Constants.INSTANCE.Cancel());
    hp.add(cancel);
    cancel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            hide();
        }
    });

    CheckBox chkOnlyDisplayDSLConditions = new CheckBox();
    chkOnlyDisplayDSLConditions.setText(Constants.INSTANCE.OnlyDisplayDSLActions());
    chkOnlyDisplayDSLConditions.setValue(bOnlyShowDSLConditions);
    chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        public void onValueChange(ValueChangeEvent<Boolean> event) {
            bOnlyShowDSLConditions = event.getValue();
            choicesPanel.setWidget(makeChoicesListBox());
        }

    });

    layoutPanel.addRow(chkOnlyDisplayDSLConditions);

    layoutPanel.addRow(hp);

    this.setAfterShow(new Command() {

        public void execute() {
            choices.setFocus(true);
        }
    });

    return layoutPanel;
}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModellerConditionSelectorPopup.java

License:Apache License

@Override
public Widget getContent() {
    if (position == null) {
        positionCbo.addItem(Constants.INSTANCE.Bottom(), String.valueOf(this.model.lhs.length));
        positionCbo.addItem(Constants.INSTANCE.Top(), "0");
        for (int i = 1; i < model.lhs.length; i++) {
            positionCbo.addItem(Constants.INSTANCE.Line0(i), String.valueOf(i));
        }// ww w .ja  v  a2 s .com
    } else {
        //if position is fixed, we just add one element to the drop down.
        positionCbo.addItem(String.valueOf(position));
        positionCbo.setSelectedIndex(0);
    }

    if (completions.getDSLConditions().length == 0 && completions.getFactTypes().length == 0) {
        layoutPanel.addRow(new HTML("<div class='highlight'>" + Constants.INSTANCE.NoModelTip() + "</div>"));
    }

    //only show the drop down if we are not using fixed position.
    if (position == null) {
        HorizontalPanel hp0 = new HorizontalPanel();
        hp0.add(new HTML(Constants.INSTANCE.PositionColon()));
        hp0.add(positionCbo);
        hp0.add(new InfoPopup(Constants.INSTANCE.PositionColon(),
                Constants.INSTANCE.ConditionPositionExplanation()));
        layoutPanel.addRow(hp0);
    }

    choices = makeChoicesListBox();
    choicesPanel.add(choices);
    layoutPanel.addRow(choicesPanel);

    HorizontalPanel hp = new HorizontalPanel();
    Button ok = new Button(Constants.INSTANCE.OK());
    hp.add(ok);
    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            selectSomething();
        }
    });

    Button cancel = new Button(Constants.INSTANCE.Cancel());
    hp.add(cancel);
    cancel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            hide();
        }
    });

    CheckBox chkOnlyDisplayDSLConditions = new CheckBox();
    chkOnlyDisplayDSLConditions.setText(Constants.INSTANCE.OnlyDisplayDSLConditions());
    chkOnlyDisplayDSLConditions.setValue(bOnlyShowDSLConditions);
    chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        public void onValueChange(ValueChangeEvent<Boolean> event) {
            bOnlyShowDSLConditions = event.getValue();
            choicesPanel.setWidget(makeChoicesListBox());
        }

    });

    layoutPanel.addRow(chkOnlyDisplayDSLConditions);

    layoutPanel.addRow(hp);

    this.setAfterShow(new Command() {

        public void execute() {
            choices.setFocus(true);
        }
    });

    return layoutPanel;
}

From source file:org.drools.guvnor.client.decisiontable.ActionInsertFactPopup.java

License:Apache License

private Widget doInsertLogical() {
    HorizontalPanel hp = new HorizontalPanel();

    final CheckBox cb = new CheckBox();
    cb.setValue(editingCol.isInsertLogical());
    cb.setText("");
    cb.setEnabled(!isReadOnly);// w  w w.jav a2s . c om
    if (!isReadOnly) {
        cb.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent arg0) {
                if (sce.isGlobalVariable(editingCol.getBoundName())) {
                    cb.setEnabled(false);
                    editingCol.setInsertLogical(false);
                } else {
                    editingCol.setInsertLogical(cb.getValue());
                }
            }
        });
    }
    hp.add(cb);
    hp.add(new InfoPopup(Constants.INSTANCE.LogicallyInsertANewFact(),
            Constants.INSTANCE.LogicallyAssertAFactTheFactWillBeRetractedWhenTheSupportingEvidenceIsRemoved()));
    return hp;
}

From source file:org.drools.guvnor.client.decisiontable.ActionSetFieldPopup.java

License:Apache License

private Widget doUpdate() {
    HorizontalPanel hp = new HorizontalPanel();

    final CheckBox cb = new CheckBox();
    cb.setValue(editingCol.isUpdate());
    cb.setText("");
    cb.setEnabled(!isReadOnly);/* w ww.j  a  v  a  2s .co m*/
    if (!isReadOnly) {
        cb.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent arg0) {
                if (sce.isGlobalVariable(editingCol.getBoundName())) {
                    cb.setEnabled(false);
                    editingCol.setUpdate(false);
                } else {
                    editingCol.setUpdate(cb.getValue());
                }
            }
        });
    }
    hp.add(cb);
    hp.add(new InfoPopup(Constants.INSTANCE.UpdateFact(), Constants.INSTANCE.UpdateDescription()));
    return hp;
}

From source file:org.drools.guvnor.client.decisiontable.DTCellValueWidgetFactory.java

License:Apache License

/**
 * An editor for whether the column is hidden or not
 * //from   w w  w.  jav  a 2s. c  o m
 * @param col
 * @return
 */
public static CheckBox getHideColumnIndicator(final DTColumnConfig52 col) {
    final CheckBox chkHide = new CheckBox();
    chkHide.setValue(col.isHideColumn());
    chkHide.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent sender) {
            col.setHideColumn(chkHide.getValue());
        }
    });
    return chkHide;
}

From source file:org.drools.guvnor.client.decisiontable.GuidedDecisionTableWidget.java

License:Apache License

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

    addButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            final FormStylePopup pop = new FormStylePopup();
            pop.setModal(false);/*from   w w w. j  a v  a2 s.co m*/

            //List of basic column types
            final ListBox choice = new ListBox();
            choice.setVisibleItemCount(NewColumnTypes.values().length);

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

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

                public void onClick(ClickEvent event) {
                    if (chkIncludeAdvancedOptions.getValue()) {
                        addItem(3, Constants.INSTANCE.AddNewConditionBRLFragment(),
                                NewColumnTypes.CONDITION_BRL_FRAGMENT.name());
                        addItem(Constants.INSTANCE.WorkItemAction(), NewColumnTypes.ACTION_WORKITEM.name());
                        addItem(Constants.INSTANCE.WorkItemActionSetField(),
                                NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name());
                        addItem(Constants.INSTANCE.WorkItemActionInsertFact(),
                                NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name());
                        addItem(Constants.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());
                    }
                    pop.center();
                }

                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 Button ok = new Button(Constants.INSTANCE.OK());
            ok.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent w) {
                    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
                    Image image = new Image(DroolsGuvnorImageResources.INSTANCE.config());
                    image.setAltText(Constants.INSTANCE.Config());
                    final FormStylePopup pop = new FormStylePopup(image,
                            Constants.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 : guidedDecisionTable.getAttributeCols()) {
                        for (int iItem = 0; iItem < list.getItemCount(); iItem++) {
                            if (list.getItemText(iItem).equals(col.getAttribute())) {
                                list.removeItem(iItem);
                                break;
                            }
                        }
                    }

                    final Image addbutton = DroolsGuvnorImages.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(Constants.INSTANCE.AddMetadataToTheRule());

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

                            String metadata = box.getText();
                            if (!isUnique(metadata)) {
                                Window.alert(
                                        Constants.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 : guidedDecisionTable.getMetadataCols()) {
                                if (metadata.equals(mc.getMetadata())) {
                                    return false;
                                }
                            }
                            return true;
                        }

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

                    pop.addAttribute(Constants.INSTANCE.Metadata1(), horiz);
                    pop.addAttribute(Constants.INSTANCE.Attribute(), list);
                    pop.show();
                }

                private void showConditionSimple() {
                    final ConditionCol52 column = makeNewConditionColumn();
                    ConditionPopup dialog = new ConditionPopup(getSCE(), guidedDecisionTable,
                            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 (guidedDecisionTable.getTableFormat()) {
                    case EXTENDED_ENTRY:
                        BRLConditionColumnViewImpl popup = new BRLConditionColumnViewImpl(sce,
                                guidedDecisionTable, true, asset, column, clientFactory, eventBus);
                        popup.setPresenter(BRL_CONDITION_PRESENTER);
                        popup.show();
                        break;
                    case LIMITED_ENTRY:
                        LimitedEntryBRLConditionColumnViewImpl limtedEntryPopup = new LimitedEntryBRLConditionColumnViewImpl(
                                sce, guidedDecisionTable, true, asset, (LimitedEntryBRLConditionColumn) column,
                                clientFactory, eventBus);
                        limtedEntryPopup.setPresenter(LIMITED_ENTRY_BRL_CONDITION_PRESENTER);
                        limtedEntryPopup.show();
                        break;
                    }
                }

                private void showActionInsert() {
                    final ActionInsertFactCol52 afc = makeNewActionInsertColumn();
                    ActionInsertFactPopup ins = new ActionInsertFactPopup(getSCE(), guidedDecisionTable,
                            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(getSCE(), guidedDecisionTable,
                            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(guidedDecisionTable,
                            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(clientFactory, packageUUID,
                            guidedDecisionTable, GuidedDecisionTableWidget.this, new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awi, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemActionSet() {
                    final ActionWorkItemSetFieldCol52 awisf = makeNewActionWorkItemSetField();
                    ActionWorkItemSetFieldPopup popup = new ActionWorkItemSetFieldPopup(getSCE(),
                            guidedDecisionTable, 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(getSCE(),
                            guidedDecisionTable, new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awiif, true, isReadOnly);
                    popup.show();
                }

                private void showActionBRLFragment() {
                    final BRLActionColumn column = makeNewActionBRLFragment();
                    switch (guidedDecisionTable.getTableFormat()) {
                    case EXTENDED_ENTRY:
                        BRLActionColumnViewImpl popup = new BRLActionColumnViewImpl(sce, guidedDecisionTable,
                                true, asset, column, clientFactory, eventBus);
                        popup.setPresenter(BRL_ACTION_PRESENTER);
                        popup.show();
                        break;
                    case LIMITED_ENTRY:
                        LimitedEntryBRLActionColumnViewImpl limtedEntryPopup = new LimitedEntryBRLActionColumnViewImpl(
                                sce, guidedDecisionTable, true, asset, (LimitedEntryBRLActionColumn) column,
                                clientFactory, eventBus);
                        limtedEntryPopup.setPresenter(LIMITED_ENTRY_BRL_ACTION_PRESENTER);
                        limtedEntryPopup.show();
                        break;
                    }

                }

                private void newActionAdded(ActionCol52 column) {
                    dtable.addColumn(column);
                    refreshActionsWidget();
                }
            });

            //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;
                    }
                    ok.setEnabled(!choice.getValue(itemIndex).equals(SECTION_SEPARATOR));
                }

            });

            pop.setTitle(Constants.INSTANCE.AddNewColumn());
            pop.addAttribute(Constants.INSTANCE.TypeOfColumn(), choice);
            pop.addAttribute("", chkIncludeAdvancedOptions);
            pop.addAttribute("", ok);
            pop.show();
        }

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

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

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

        private ActionRetractFactCol52 makeNewActionRetractFact() {
            switch (guidedDecisionTable.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 (guidedDecisionTable.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryBRLActionColumn();
            default:
                return new BRLActionColumn();
            }
        }

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

    });

    return addButton;
}

From source file:org.drools.guvnor.client.decisiontable.GuidedDecisionTableWidget.java

License:Apache License

private void refreshAttributeWidget() {
    this.attributeConfigWidget.clear();
    if (guidedDecisionTable.getMetadataCols().size() > 0) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(new SmallLabel(Constants.INSTANCE.Metadata1()));
        attributeConfigWidget.add(hp);/*  w w  w.ja v  a2 s.c  om*/
    }
    for (MetadataCol52 atc : guidedDecisionTable.getMetadataCols()) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        hp.add(new HTML("&nbsp;&nbsp;&nbsp;&nbsp;"));
        if (!isReadOnly) {
            hp.add(removeMeta(atc));
        }
        final SmallLabel label = makeColumnLabel(atc);
        hp.add(label);

        final MetadataCol52 at = atc;
        final CheckBox hide = new CheckBox(Constants.INSTANCE.HideThisColumn());
        hide.setStyleName("form-field");
        hide.setValue(atc.isHideColumn());
        hide.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent sender) {
                at.setHideColumn(hide.getValue());
                dtable.setColumnVisibility(at, !at.isHideColumn());
                setColumnLabelStyleWhenHidden(label, hide.getValue());
            }
        });
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(hide);

        attributeConfigWidget.add(hp);
    }
    if (guidedDecisionTable.getAttributeCols().size() > 0) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(new SmallLabel(Constants.INSTANCE.Attributes()));
        attributeConfigWidget.add(hp);
    }

    for (AttributeCol52 atc : guidedDecisionTable.getAttributeCols()) {
        final AttributeCol52 at = atc;
        HorizontalPanel hp = new HorizontalPanel();
        hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

        hp.add(new HTML("&nbsp;&nbsp;&nbsp;&nbsp;"));
        if (!isReadOnly) {
            hp.add(removeAttr(at));
        }
        final SmallLabel label = makeColumnLabel(atc);
        hp.add(label);

        final TextBox defaultValue = new TextBox();
        final DTCellValue52 dcv = at.getDefaultValue();
        defaultValue.setStyleName("form-field");
        defaultValue.setText((dcv == null ? "" : dcv.getStringValue()));
        defaultValue.setEnabled(!isReadOnly);
        defaultValue.addChangeHandler(new ChangeHandler() {
            public void onChange(ChangeEvent event) {
                at.setDefaultValue(new DTCellValue52(defaultValue.getText()));
            }
        });

        if (at.getAttribute().equals(RuleAttributeWidget.SALIENCE_ATTR)) {
            hp.add(new HTML("&nbsp;&nbsp;"));
            final CheckBox useRowNumber = new CheckBox(Constants.INSTANCE.UseRowNumber());
            useRowNumber.setStyleName("form-field");
            useRowNumber.setValue(at.isUseRowNumber());
            useRowNumber.setEnabled(!isReadOnly);
            hp.add(useRowNumber);

            hp.add(new SmallLabel("("));
            final CheckBox reverseOrder = new CheckBox(Constants.INSTANCE.ReverseOrder());
            reverseOrder.setStyleName("form-field");
            reverseOrder.setValue(at.isReverseOrder());
            reverseOrder.setEnabled(at.isUseRowNumber() && !isReadOnly);

            useRowNumber.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent sender) {
                    at.setUseRowNumber(useRowNumber.getValue());
                    reverseOrder.setEnabled(useRowNumber.getValue());
                    dtable.updateSystemControlledColumnValues();
                }
            });

            reverseOrder.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent sender) {
                    at.setReverseOrder(reverseOrder.getValue());
                    dtable.updateSystemControlledColumnValues();
                }
            });
            hp.add(reverseOrder);
            hp.add(new SmallLabel(")"));
        }
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(new SmallLabel(Constants.INSTANCE.DefaultValue()));
        hp.add(defaultValue);

        final CheckBox hide = new CheckBox(Constants.INSTANCE.HideThisColumn());
        hide.setStyleName("form-field");
        hide.setValue(at.isHideColumn());
        hide.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent sender) {
                at.setHideColumn(hide.getValue());
                dtable.setColumnVisibility(at, !at.isHideColumn());
                setColumnLabelStyleWhenHidden(label, hide.getValue());
            }
        });
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(hide);

        attributeConfigWidget.add(hp);
        setupColumnsNote();
    }

}

From source file:org.drools.guvnor.client.decisiontable.widget.auditlog.AuditLogViewImpl.java

License:Apache License

private Widget makeEventTypeCheckBox(final String eventType, final Boolean isEnabled) {
    final CheckBox chkEventType = new CheckBox(AuditLogEntryCellHelper.getEventTypeDisplayText(eventType));
    chkEventType.setValue(Boolean.TRUE.equals(isEnabled));
    chkEventType.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override/*  w  w w . j  a v  a 2 s  .  co  m*/
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            auditLog.getAuditLogFilter().getAcceptedTypes().put(eventType, event.getValue());
        }

    });

    return chkEventType;
}

From source file:org.drools.guvnor.client.moduleeditor.drools.PackageBuilderWidget.java

License:Apache License

public PackageBuilderWidget(final Module conf, ClientFactory clientFactory) {

    this.conf = conf;
    this.clientFactory = clientFactory;

    // UI above the results table
    FormStyleLayout layout = new FormStyleLayout();
    final VerticalPanel container = new VerticalPanel();
    final VerticalPanel buildResults = new VerticalPanel();

    RadioButton wholePackageRadioButton = new RadioButton("action", Constants.INSTANCE.BuildWholePackage());
    RadioButton builtInSelectorRadioButton = new RadioButton("action",
            Constants.INSTANCE.BuildPackageUsingBuiltInSelector());
    RadioButton customSelectorRadioButton = new RadioButton("action",
            Constants.INSTANCE.BuildPackageUsingCustomSelector());
    wholePackageRadioButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(true);
            builtInSelectorLayout.setVisible(false);
            customSelectorLayout.setVisible(false);
            buildMode = "buildWholePackage";
        }//from  www .j a v a 2s.  c o  m
    });
    builtInSelectorRadioButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(false);
            builtInSelectorLayout.setVisible(true);
            customSelectorLayout.setVisible(false);
            buildMode = "BuiltInSelector";
        }
    });
    customSelectorRadioButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(false);
            builtInSelectorLayout.setVisible(false);
            customSelectorLayout.setVisible(true);
            buildMode = "customSelector";
        }
    });

    VerticalPanel verticalPanel = new VerticalPanel();

    HorizontalPanel wholePackageRadioButtonPanel = new HorizontalPanel();
    wholePackageRadioButtonPanel.add(wholePackageRadioButton);
    wholePackageRadioButtonPanel.add(
            new InfoPopup(Constants.INSTANCE.BuildWholePackage(), Constants.INSTANCE.BuildWholePackageTip()));
    verticalPanel.add(wholePackageRadioButtonPanel);

    HorizontalPanel builtInSelectorRadioButtonPanel = new HorizontalPanel();
    builtInSelectorRadioButtonPanel.add(builtInSelectorRadioButton);
    builtInSelectorRadioButtonPanel
            .add(new InfoPopup(Constants.INSTANCE.BuiltInSelector(), Constants.INSTANCE.BuiltInSelectorTip()));
    verticalPanel.add(builtInSelectorRadioButtonPanel);

    HorizontalPanel customSelectorRadioButtonPanel = new HorizontalPanel();
    customSelectorRadioButtonPanel.add(customSelectorRadioButton);
    customSelectorRadioButtonPanel
            .add(new InfoPopup(Constants.INSTANCE.CustomSelector(), Constants.INSTANCE.SelectorTip()));
    verticalPanel.add(customSelectorRadioButtonPanel);

    layout.addAttribute("", verticalPanel);
    wholePackageRadioButton.setValue(true);

    buildWholePackageLayout.setVisible(true);
    builtInSelectorLayout.setVisible(false);
    customSelectorLayout.setVisible(false);

    // Build whole package layout
    layout.addRow(buildWholePackageLayout);

    // Built-in selector layout
    builtInSelectorLayout.addRow(
            new HTML("&nbsp;&nbsp;<i>" + Constants.INSTANCE.BuildPackageUsingFollowingAssets() + "</i>"));

    HorizontalPanel builtInSelectorStatusPanel = new HorizontalPanel();
    final CheckBox enableStatusCheckBox = new CheckBox();
    enableStatusCheckBox.setValue(false);
    builtInSelectorStatusPanel.add(enableStatusCheckBox);
    builtInSelectorStatusPanel.add(new HTML(
            "&nbsp;&nbsp;<i>" + Constants.INSTANCE.BuildPackageUsingBuiltInSelectorStatus() + " </i>"));
    final ListBox statusOperator = new ListBox();
    String[] vals = new String[] { "=", "!=" };
    for (int i = 0; i < vals.length; i++) {
        statusOperator.addItem(vals[i], vals[i]);
    }
    builtInSelectorStatusPanel.add(statusOperator);

    final TextBox statusValue = new TextBox();
    statusValue.setTitle(Constants.INSTANCE.WildCardsSearchTip());
    builtInSelectorStatusPanel.add(statusValue);

    builtInSelectorLayout.addRow(builtInSelectorStatusPanel);

    HorizontalPanel builtInSelectorCatPanel = new HorizontalPanel();
    final CheckBox enableCategoryCheckBox = new CheckBox();
    enableCategoryCheckBox.setValue(false);
    builtInSelectorCatPanel.add(enableCategoryCheckBox);
    builtInSelectorCatPanel.add(
            new HTML("&nbsp;&nbsp;<i>" + Constants.INSTANCE.BuildPackageUsingBuiltInSelectorCat() + " </i>"));
    final ListBox catOperator = new ListBox();
    String[] catVals = new String[] { "=", "!=" };
    for (int i = 0; i < catVals.length; i++) {
        catOperator.addItem(catVals[i], catVals[i]);
    }
    builtInSelectorCatPanel.add(catOperator);
    final CategoryExplorerWidget catChooser = new CategoryExplorerWidget(new CategorySelectHandler() {
        public void selected(String selectedPath) {
        }
    });
    ScrollPanel catScroll = new ScrollPanel(catChooser);
    catScroll.setAlwaysShowScrollBars(true);
    catScroll.setSize("300px", "130px");

    builtInSelectorCatPanel.add(catScroll);
    builtInSelectorLayout.addRow(builtInSelectorCatPanel);

    layout.addRow(builtInSelectorLayout);

    // Custom selector layout
    customSelectorLayout.setVisible(false);
    HorizontalPanel customSelectorPanel = new HorizontalPanel();
    customSelectorPanel.add(new HTML(
            "&nbsp;&nbsp;<i>" + Constants.INSTANCE.BuildPackageUsingCustomSelectorSelector() + " </i>")); // NON-NLS

    final ListBox customSelector = new ListBox();
    customSelector.setTitle(Constants.INSTANCE.WildCardsSearchTip());
    customSelectorPanel.add(customSelector);
    loadCustomSelectorList(customSelector);

    customSelectorLayout.addRow(customSelectorPanel);
    layout.addRow(customSelectorLayout);

    final Button b = new Button(Constants.INSTANCE.BuildPackage());
    b.setTitle(Constants.INSTANCE.ThisWillValidateAndCompileAllTheAssetsInAPackage());
    b.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            doBuild(buildResults, statusOperator.getValue(statusOperator.getSelectedIndex()),
                    statusValue.getText(), enableStatusCheckBox.getValue(),
                    catOperator.getValue(catOperator.getSelectedIndex()), catChooser.getSelectedPath(),
                    enableCategoryCheckBox.getValue(),
                    customSelector.getSelectedIndex() != -1
                            ? customSelector.getValue(customSelector.getSelectedIndex())
                            : null);
        }
    });
    HorizontalPanel buildStuff = new HorizontalPanel();
    buildStuff.add(b);

    layout.addAttribute(Constants.INSTANCE.BuildBinaryPackage(), buildStuff);
    layout.addRow(new HTML("<i><small>" + Constants.INSTANCE.BuildingPackageNote() + "</small></i>"));// NON-NLS
    container.add(layout);

    // The build results
    container.add(buildResults);

    // UI below the results table
    layout = new FormStyleLayout();
    Button snap = new Button(Constants.INSTANCE.CreateSnapshotForDeployment());
    snap.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            showSnapshotDialog(conf.getName(), null);
        }
    });
    layout.addAttribute(Constants.INSTANCE.TakeSnapshot(), snap);
    container.add(layout);

    initWidget(container);
}

From source file:org.drools.guvnor.client.moduleeditor.soa.SOAServiceBuilderWidget.java

License:Apache License

public SOAServiceBuilderWidget(final Module conf, ClientFactory clientFactory) {

    this.conf = conf;
    this.clientFactory = clientFactory;

    // UI above the results table
    FormStyleLayout layout = new FormStyleLayout();
    final VerticalPanel container = new VerticalPanel();
    final VerticalPanel buildResults = new VerticalPanel();

    RadioButton wholePackageRadioButton = new RadioButton("action", constants.BuildWholeService());
    RadioButton builtInSelectorRadioButton = new RadioButton("action",
            constants.BuildServiceUsingBuiltInSelector());
    RadioButton customSelectorRadioButton = new RadioButton("action",
            constants.BuildServiceUsingCustomSelector());
    wholePackageRadioButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(true);
            builtInSelectorLayout.setVisible(false);
            customSelectorLayout.setVisible(false);
            buildMode = "buildWholePackage";
        }/*from   w  w  w. j a va  2s .com*/
    });
    builtInSelectorRadioButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(false);
            builtInSelectorLayout.setVisible(true);
            customSelectorLayout.setVisible(false);
            buildMode = "BuiltInSelector";
        }
    });
    customSelectorRadioButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            buildWholePackageLayout.setVisible(false);
            builtInSelectorLayout.setVisible(false);
            customSelectorLayout.setVisible(true);
            buildMode = "customSelector";
        }
    });

    VerticalPanel verticalPanel = new VerticalPanel();

    HorizontalPanel wholePackageRadioButtonPanel = new HorizontalPanel();
    wholePackageRadioButtonPanel.add(wholePackageRadioButton);
    wholePackageRadioButtonPanel
            .add(new InfoPopup(constants.BuildWholeService(), constants.BuildWholeServiceTip()));
    verticalPanel.add(wholePackageRadioButtonPanel);

    HorizontalPanel builtInSelectorRadioButtonPanel = new HorizontalPanel();
    builtInSelectorRadioButtonPanel.add(builtInSelectorRadioButton);
    builtInSelectorRadioButtonPanel
            .add(new InfoPopup(constants.BuiltInServiceSelectorTip(), constants.BuiltInServiceSelectorTip()));
    verticalPanel.add(builtInSelectorRadioButtonPanel);

    HorizontalPanel customSelectorRadioButtonPanel = new HorizontalPanel();
    customSelectorRadioButtonPanel.add(customSelectorRadioButton);
    customSelectorRadioButtonPanel
            .add(new InfoPopup(constants.CustomSelector(), constants.ServiceSelectorTip()));
    verticalPanel.add(customSelectorRadioButtonPanel);

    layout.addAttribute("", verticalPanel);
    wholePackageRadioButton.setValue(true);

    buildWholePackageLayout.setVisible(true);
    builtInSelectorLayout.setVisible(false);
    customSelectorLayout.setVisible(false);

    // Build whole package layout
    layout.addRow(buildWholePackageLayout);

    // Built-in selector layout
    builtInSelectorLayout
            .addRow(new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingFollowingAssets() + "</i>"));

    HorizontalPanel builtInSelectorStatusPanel = new HorizontalPanel();
    final CheckBox enableStatusCheckBox = new CheckBox();
    enableStatusCheckBox.setValue(false);
    builtInSelectorStatusPanel.add(enableStatusCheckBox);
    builtInSelectorStatusPanel
            .add(new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingBuiltInSelectorStatus() + " </i>"));
    final ListBox statusOperator = new ListBox();
    String[] vals = new String[] { "=", "!=" };
    for (int i = 0; i < vals.length; i++) {
        statusOperator.addItem(vals[i], vals[i]);
    }
    builtInSelectorStatusPanel.add(statusOperator);

    final TextBox statusValue = new TextBox();
    statusValue.setTitle(constants.WildCardsSearchTip());
    builtInSelectorStatusPanel.add(statusValue);

    builtInSelectorLayout.addRow(builtInSelectorStatusPanel);

    HorizontalPanel builtInSelectorCatPanel = new HorizontalPanel();
    final CheckBox enableCategoryCheckBox = new CheckBox();
    enableCategoryCheckBox.setValue(false);
    builtInSelectorCatPanel.add(enableCategoryCheckBox);
    builtInSelectorCatPanel
            .add(new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingBuiltInSelectorCat() + " </i>"));
    final ListBox catOperator = new ListBox();
    String[] catVals = new String[] { "=", "!=" };
    for (int i = 0; i < catVals.length; i++) {
        catOperator.addItem(catVals[i], catVals[i]);
    }
    builtInSelectorCatPanel.add(catOperator);
    final CategoryExplorerWidget catChooser = new CategoryExplorerWidget(new CategorySelectHandler() {
        public void selected(String selectedPath) {
        }
    });
    ScrollPanel catScroll = new ScrollPanel(catChooser);
    catScroll.setAlwaysShowScrollBars(true);
    catScroll.setSize("300px", "130px");

    builtInSelectorCatPanel.add(catScroll);
    builtInSelectorLayout.addRow(builtInSelectorCatPanel);

    layout.addRow(builtInSelectorLayout);

    // Custom selector layout
    customSelectorLayout.setVisible(false);
    HorizontalPanel customSelectorPanel = new HorizontalPanel();
    customSelectorPanel
            .add(new HTML("&nbsp;&nbsp;<i>" + constants.BuildPackageUsingCustomSelectorSelector() + " </i>")); // NON-NLS

    final ListBox customSelector = new ListBox();
    customSelector.setTitle(constants.WildCardsSearchTip());
    customSelectorPanel.add(customSelector);
    loadCustomSelectorList(customSelector);

    customSelectorLayout.addRow(customSelectorPanel);
    layout.addRow(customSelectorLayout);

    final Button b = new Button(constants.BuildService());
    b.setTitle(constants.ThisWillValidateAndCompileAllTheAssetsInAPackage());
    b.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            doBuild(buildResults, statusOperator.getValue(statusOperator.getSelectedIndex()),
                    statusValue.getText(), enableStatusCheckBox.getValue(),
                    catOperator.getValue(catOperator.getSelectedIndex()), catChooser.getSelectedPath(),
                    enableCategoryCheckBox.getValue(),
                    customSelector.getSelectedIndex() != -1
                            ? customSelector.getValue(customSelector.getSelectedIndex())
                            : null);
        }
    });
    HorizontalPanel buildStuff = new HorizontalPanel();
    buildStuff.add(b);

    layout.addAttribute(constants.BuildBinaryService(), buildStuff);
    layout.addRow(new HTML("<i><small>" + constants.BuildingServiceNote() + "</small></i>"));// NON-NLS
    container.add(layout);

    // The build results
    container.add(buildResults);

    initWidget(container);
}