List of usage examples for com.google.gwt.user.client.ui CheckBox CheckBox
protected CheckBox(Element elem)
From source file:org.drools.guvnor.client.asseteditor.drools.serviceconfig.KBaseConfigPanel.java
License:Apache License
private TreeItem buildTreeItem(final TreeItem parent, final String text, final ImageResource image, final AssetReference asset) { if (asset != null) { for (int i = 0; i < parent.getChildCount(); i++) { if (parent.getChild(i).getUserObject() == null) { continue; }// w w w . jav a 2 s. c o m final AssetReference currentAsset = (AssetReference) parent.getChild(i).getUserObject(); if (currentAsset.getName().equals(text)) { return parent.getChild(i); } } } final CheckBox checkBox = new CheckBox(treeItemFormat(text, image)); final TreeItem newTreeItem = parent.addItem(checkBox); newTreeItem.setUserObject(asset); 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); } } } }); parent.setState(true, false); newTreeItem.setState(true, false); return newTreeItem; }
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);/* w w w . ja va 2 s .c o 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(" ")); hp.add(new SmallLabel(Constants.INSTANCE.Metadata1())); attributeConfigWidget.add(hp);//from ww w . jav a 2 s . com } 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.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/*from w ww. ja va2 s . c om*/ public void onValueChange(ValueChangeEvent<Boolean> event) { auditLog.getAuditLogFilter().getAcceptedTypes().put(eventType, event.getValue()); } }); return chkEventType; }
From source file:org.drools.guvnor.client.table.ColumnPicker.java
License:Apache License
public ToggleButton createToggleButton() { final ToggleButton button = new ToggleButton(COLUMN_PICKER_IMAGE); final PopupPanel popup = new PopupPanel(true); popup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> popupPanelCloseEvent) { button.setDown(false);/* ww w . j ava2 s .c om*/ } }); VerticalPanel popupContent = new VerticalPanel(); for (final ColumnMeta<T> columnMeta : columnMetaList) { final CheckBox checkBox = new CheckBox(columnMeta.getHeader().getValue()); checkBox.setValue(columnMeta.isVisible()); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) { boolean visible = booleanValueChangeEvent.getValue(); if (visible) { // WORKAROUND because CellTable does not support insertColumn at this time for (ColumnMeta<T> resettingColumnMeta : columnMetaList) { if (resettingColumnMeta.isVisible()) { cellTable.removeColumn(resettingColumnMeta.getColumn()); } } columnMeta.setVisible(visible); for (ColumnMeta<T> resettingColumnMeta : columnMetaList) { if (resettingColumnMeta.isVisible()) { cellTable.addColumn(resettingColumnMeta.getColumn(), resettingColumnMeta.getHeader()); } } } else { columnMeta.setVisible(visible); cellTable.removeColumn(columnMeta.getColumn()); } } }); popupContent.add(checkBox); } popup.add(popupContent); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (button.isDown()) { popup.setPopupPosition(button.getAbsoluteLeft(), button.getAbsoluteTop() + button.getOffsetHeight()); popup.show(); } // Note: no need to hide the popup when clicked when down, // because clicking anywhere outside the popup will hide the popup } }); return button; }
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);/*from w w w . j a v a2 s. c om*/ } 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.tables.ColumnPicker.java
License:Apache License
public ToggleButton createToggleButton() { final ToggleButton button = new ToggleButton(COLUMN_PICKER_IMAGE); final PopupPanel popup = new PopupPanel(true); popup.addAutoHidePartner(button.getElement()); popup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> popupPanelCloseEvent) { button.setDown(false);/*from ww w . j a va2 s. co m*/ } }); VerticalPanel popupContent = new VerticalPanel(); for (final ColumnMeta<T> columnMeta : columnMetaList) { final CheckBox checkBox = new CheckBox(columnMeta.getHeader().getValue()); checkBox.setValue(columnMeta.isVisible()); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) { boolean visible = booleanValueChangeEvent.getValue(); if (visible) { // WORKAROUND because CellTable does not support insertColumn at this time for (ColumnMeta<T> resettingColumnMeta : columnMetaList) { if (resettingColumnMeta.isVisible()) { cellTable.removeColumn(resettingColumnMeta.getColumn()); } } columnMeta.setVisible(visible); for (ColumnMeta<T> resettingColumnMeta : columnMetaList) { if (resettingColumnMeta.isVisible()) { cellTable.addColumn(resettingColumnMeta.getColumn(), resettingColumnMeta.getHeader()); } } } else { columnMeta.setVisible(visible); cellTable.removeColumn(columnMeta.getColumn()); } } }); popupContent.add(checkBox); } popup.add(popupContent); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (button.isDown()) { popup.setPopupPosition(button.getAbsoluteLeft(), button.getAbsoluteTop() + button.getOffsetHeight()); popup.show(); } else { popup.hide(false); } } }); return button; }
From source file:org.ebayopensource.turmeric.monitoring.client.view.ErrorFilterWidget.java
License:Open Source License
/** * Sets the grid values.//from ww w . j av a 2 s . co m * * @param grid the grid * @param names the names * @param localizedNameMap the localized name map * @param counterpartGrid the counterpart grid */ protected void setGridValues(final Grid grid, final List<String> names, final Map localizedNameMap, final Grid counterpartGrid) { grid.clear(); grid.resize(names.size(), 1); int i = 0; for (String name : names) { CheckBox cb = new CheckBox((String) localizedNameMap.get(name)); cb.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { //if a checkbox is selected, the counterpart Grid entries are all disabled if (((CheckBox) event.getSource()).getValue()) disable(counterpartGrid); else { //if no checkboxes are selected, then the counterpart Grid is enabled int checkCount = 0; Iterator<Widget> itor = grid.iterator(); while (itor.hasNext()) { Widget w = itor.next(); if (w instanceof CheckBox) { if (((CheckBox) w).getValue()) checkCount++; } } if (checkCount == 0) enable(counterpartGrid); } } }); cb.setFormValue(name); grid.setWidget(i, 0, cb); grid.getCellFormatter().setWordWrap(i, 0, false); i++; } }
From source file:org.ebayopensource.turmeric.monitoring.client.view.FilterWidget.java
License:Open Source License
/** * Sets the metric names.// w w w . j av a 2 s. com * * @param names * the new metric names * @see org.ebayopensource.turmeric.monitoring.client.model.Filterable#setMetricNames(java.util.List) */ public void setMetricNames(List<String> names) { metricsGrid.clear(); metricsGrid.resize(names.size(), 1); int i = 0; for (String name : names) { String localizedName = (String) ConsoleUtil.constants.metricNameMap().get(name); CheckBox checkbox = new CheckBox(localizedName); checkbox.setFormValue(name); metricsGrid.setWidget(i++, 0, checkbox); } }
From source file:org.ebayopensource.turmeric.policy.adminui.client.view.FilterWidget.java
License:Open Source License
public void setMetricNames(List<String> names) { metricsGrid.clear();/*from w w w. j av a 2 s . co m*/ metricsGrid.resize(names.size(), 1); int i = 0; for (String name : names) { String localizedName = (String) PolicyAdminUIUtil.constants.metricNameMap().get(name); CheckBox checkbox = new CheckBox(localizedName); checkbox.setFormValue(name); metricsGrid.setWidget(i++, 0, checkbox); } }