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

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

Introduction

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

Prototype

@Override
public Boolean getValue() 

Source Link

Document

Determines whether this check box is currently checked.

Usage

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("  "));
        hp.add(new SmallLabel(Constants.INSTANCE.Metadata1()));
        attributeConfigWidget.add(hp);/*from w  w w. j ava  2 s  . c  om*/
    }
    for (MetadataCol52 atc : guidedDecisionTable.getMetadataCols()) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        hp.add(new HTML("    "));
        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("  "));
        hp.add(hide);

        attributeConfigWidget.add(hp);
    }
    if (guidedDecisionTable.getAttributeCols().size() > 0) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.add(new HTML("  "));
        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("    "));
        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("  "));
            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("  "));
        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("  "));
        hp.add(hide);

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

}

From source file:org.drools.guvnor.client.explorer.navigation.admin.widget.RepoConfigManager.java

License:Apache License

public DecoratorPanel getDbTypePanel() {
    FlexTable layoutA = new FlexTable();
    layoutA.setCellSpacing(6);//from   ww w.j a  va2 s  .  co  m
    FlexCellFormatter cellFormatter = layoutA.getFlexCellFormatter();

    // Add a title to the form
    layoutA.setHTML(0, 0, "RDBMS Info");
    cellFormatter.setColSpan(0, 0, 2);
    cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);

    layoutA.setHTML(1, 0, constants.SelectRdbmsType());
    final ListBox databaseList = getDatabaseList();
    databaseList.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            ListBox listBox = (ListBox) event.getSource();
            int index = listBox.getSelectedIndex();
            rdbmsConf.setDbType(listBox.getItemText(index));
            layoutB.setHTML(0, 0, listBox.getItemText(index) + " Info");
            layoutC.setHTML(0, 0, listBox.getItemText(index) + " Info");
            repoDisplayArea.setVisible(false);
            saveRepoConfigForm.setVisible(false);
        }
    });
    if (rdbmsConf.getDbType() == null || rdbmsConf.getDbType().length() < 1) {
        databaseList.setSelectedIndex(0);
    } else {
        for (int i = 0; i < databaseList.getItemCount(); i++) {
            if (rdbmsConf.getDbType().equals(databaseList.getItemText(i))) {
                databaseList.setSelectedIndex(i);
                break;
            }
        }
    }
    databaseList.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            rdbmsConf.setDbType(databaseList.getValue(databaseList.getSelectedIndex()));
        }
    });
    layoutA.setWidget(1, 1, databaseList);

    layoutA.setHTML(2, 0, constants.UseJndi());

    final CheckBox useJndi = new CheckBox();
    useJndi.setChecked(rdbmsConf.isJndi());
    useJndi.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            // do not change this to isEnabled..it will always return true.
            boolean checked = ((CheckBox) w.getSource()).getValue();
            rdbmsConf.setJndi(checked);
            if (checked) {
                noJndiInfo.setVisible(false);
                jndiInfo.setVisible(true);
            } else {
                noJndiInfo.setVisible(true);
                jndiInfo.setVisible(false);
            }
            repoDisplayArea.setVisible(false);
            saveRepoConfigForm.setVisible(false);
        }
    });
    layoutA.setWidget(2, 1, useJndi);

    Button continueButton = new Button("Continue");
    continueButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            if (databaseList.getSelectedIndex() == 0) {
                Window.alert(constants.PleaseSelectRdbmsType());
                return;
            }
            if (!useJndi.getValue()) {
                jndiInfo.setVisible(false);
            }
            vPanel2.setVisible(true);
        }
    });

    layoutA.setWidget(3, 1, continueButton);
    DecoratorPanel decPanel = new DecoratorPanel();
    decPanel.setWidget(layoutA);
    return decPanel;
}

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  w  w  w . j a va 2  s. 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";
        }//  w  w w . j a va2 s  . 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);
}

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

License:Apache License

/**
 * This binds a field, and returns a check box editor for it.
 * /*w  ww  .  j a v a 2s .c  om*/
 * @param bind
 *            Interface to bind to.
 * @param toolTip
 *            tool tip.
 * @return
 */
private Widget editableBoolean(final FieldBooleanBinding bind, String toolTip) {
    if (!readOnly) {
        final CheckBox box = new CheckBox();
        box.setTitle(toolTip);
        box.setValue(bind.getValue());
        ClickHandler listener = new ClickHandler() {
            public void onClick(ClickEvent w) {
                boolean b = box.getValue();
                bind.setValue(b);
            }
        };
        box.addClickHandler(listener);
        return box;
    } else {
        final CheckBox box = new CheckBox();

        box.setValue(bind.getValue());
        box.setEnabled(false);

        return box;
    }
}

From source file:org.drools.guvnor.client.widgets.drools.explorer.ArtifactDependenciesExplorerWidget.java

License:Apache License

private void addItem(final TreeItem root, final MavenArtifact artifact,
        final Collection<MavenArtifact> unchecked) {
    final SafeHtmlBuilder sb = new SafeHtmlBuilder();
    sb.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(images.modelAsset()).getHTML()));
    sb.appendEscaped(" ").appendEscaped(artifact.toLabel());

    final CheckBox checkBox = new CheckBox(sb.toSafeHtml());
    if (!unchecked.contains(artifact)) {
        checkBox.setValue(true);/* ww  w.  j a v a2 s  .co  m*/
    }

    final TreeItem newTreeItem = root.addItem(checkBox);
    newTreeItem.setUserObject(artifact);
    if (artifact.hasChild()) {
        for (MavenArtifact chilldren : artifact.getChild()) {
            addItem(newTreeItem, chilldren, unchecked);
        }
    }

    checkBox.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final CheckBox me = ((CheckBox) event.getSource());
            boolean checked = me.getValue();
            if (newTreeItem.getChildCount() > 0) {
                for (int i = 0; i < newTreeItem.getChildCount(); i++) {
                    defineState(newTreeItem.getChild(i), checked);
                }
            }
        }

        private void defineState(TreeItem currentItem, boolean checked) {
            ((CheckBox) currentItem.getWidget()).setValue(checked);
            if (currentItem.getChildCount() > 0) {
                for (int i = 0; i < currentItem.getChildCount(); i++) {
                    defineState(currentItem.getChild(i), checked);
                }
            }
        }
    });
}

From source file:org.drools.guvnor.client.widgets.drools.RuleVerifierManager.java

License:Apache License

public RuleVerifierManager() {

    PrettyFormLayout form = new PrettyFormLayout();
    form.addHeader(GuvnorImages.INSTANCE.RuleVerification(),
            new HTML(Constants.INSTANCE.EditRulesVerificationConfiguration()));
    form.startSection(Constants.INSTANCE.AutomaticVerification());

    final CheckBox enableOnlineValidator = new CheckBox();
    enableOnlineValidator.setValue(WorkingSetManager.getInstance().isAutoVerifierEnabled());
    form.addAttribute(Constants.INSTANCE.Enabled(), enableOnlineValidator);

    HorizontalPanel actions = new HorizontalPanel();

    form.addAttribute("", actions);

    Button btnSave = new Button(Constants.INSTANCE.SaveChanges());
    btnSave.setTitle(Constants.INSTANCE.SaveAllChanges());
    btnSave.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            WorkingSetManager.getInstance().setAutoVerifierEnabled(enableOnlineValidator.getValue());
            Window.alert(Constants.INSTANCE.AllChangesHaveBeenSaved());
        }/*from   w  ww  .  ja  v a 2 s  . com*/
    });

    actions.add(btnSave);

    form.endSection();

    initWidget(form);

}

From source file:org.drools.guvnor.client.widgets.query.QueryWidget.java

License:Apache License

private void doTextSearch() {
    DecoratedDisclosurePanel advancedDisclosure = new DecoratedDisclosurePanel(constants.TextSearch());
    advancedDisclosure.setWidth("100%");
    advancedDisclosure.setOpen(true);// w  w  w.  j ava 2s.co  m

    VerticalPanel container = new VerticalPanel();
    VerticalPanel criteria = new VerticalPanel();

    FormStyleLayout ts = new FormStyleLayout();
    final TextBox tx = new TextBox();
    ts.addAttribute(constants.SearchFor(), tx);

    final CheckBox archiveBox = new CheckBox();
    archiveBox.setValue(false);
    ts.addAttribute(constants.IncludeArchivedAssetsInResults(), archiveBox);

    Button go = new Button();
    go.setText(constants.Search1());
    ts.addAttribute("", go);
    ts.setWidth("100%");

    final SimplePanel resultsP = new SimplePanel();
    final ClickHandler cl = new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            if (tx.getText().equals("")) {
                Window.alert(constants.PleaseEnterSomeSearchText());
                return;
            }
            resultsP.clear();
            QueryPagedTable table = new QueryPagedTable(tx.getText(), archiveBox.getValue(), clientFactory);
            resultsP.add(table);
        }

    };

    go.addClickHandler(cl);
    tx.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
                cl.onClick(null);
            }
        }
    });

    criteria.add(ts);
    container.add(criteria);
    container.add(resultsP);
    advancedDisclosure.setContent(container);
    layout.add(advancedDisclosure);
}

From source file:org.ednovo.gooru.client.mvp.gsearch.SearchAbstractView.java

License:Open Source License

/**
 * Get filters for search/*from  www  .  j av  a2s.c  om*/
 * @param filterPanel instance of {@link DisclosurePanelUc} which has filters widget
 * @param separator concatenation of the filters with separator
 * @return concatenation of selected filters
 */
private String getSelectedFilter(PPanel filterPanel, String separator) {
    String selectedFilter = "";
    for (int i = 0; i < filterPanel.getWidgetCount(); i++) {
        Widget filterWidget = filterPanel.getWidget(i);
        if (filterWidget instanceof CheckBox) {
            CheckBox filterCheckBox = (CheckBox) filterWidget;
            if (filterCheckBox != null && filterCheckBox.getValue()) {
                if (!selectedFilter.isEmpty()) {
                    selectedFilter += separator;
                }
                selectedFilter += filterCheckBox.getName();
                MixpanelUtil.mixpanelEvent("search_" + selectedFilter + "_filter_selected");
            }
        }
    }
    return selectedFilter;
}

From source file:org.ednovo.gooru.client.mvp.home.SearchHomeFilterVc.java

License:Open Source License

/**
 * Get selected filters/*from w ww.  j a v a 2s .  co m*/
 * @param filterFlowPanel to get selected filters
 * @return selected filter name as string
 */
private String getSelectedFilter(FlowPanel filterFlowPanel) {
    String selectedFilter = "";
    for (Widget filterWidget : filterFlowPanel) {
        if (filterWidget instanceof CheckBox) {
            CheckBox filterCheckBox = (CheckBox) filterWidget;
            if (filterCheckBox != null && filterCheckBox.getValue()) {
                if (!selectedFilter.isEmpty()) {
                    selectedFilter += ",";
                }
                selectedFilter += filterCheckBox.getText();
            }
        }
    }
    return selectedFilter;
}