List of usage examples for com.google.gwt.user.client.ui CheckBox addValueChangeHandler
@Override
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
From source file:org.jbpm.formbuilder.client.tasks.QuickFormPanel.java
License:Apache License
private Grid toGrid(List<TaskPropertyRef> ioList, final List<TaskPropertyRef> selectedIos) { Grid grid = new Grid(ioList == null ? 1 : ioList.size(), 2); if (ioList != null) { for (int index = 0; index < ioList.size(); index++) { final TaskPropertyRef io = ioList.get(index); CheckBox checkBox = new CheckBox(); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override//from ww w.ja v a 2 s . c o m public void onValueChange(ValueChangeEvent<Boolean> event) { Boolean val = event.getValue(); if (val == null || val == false) { if (selectedIos.contains(io)) { selectedIos.remove(io); } } else { if (!selectedIos.contains(io)) { selectedIos.add(io); } } } }); checkBox.setValue(Boolean.TRUE); selectedIos.add(io); grid.setWidget(index, 0, checkBox); grid.setWidget(index, 1, new Label(io.getName())); } } return grid; }
From source file:org.kaaproject.avro.ui.gwt.client.widget.AbstractFieldWidget.java
License:Apache License
private Widget constructBooleanWidget(final BooleanField field, List<HandlerRegistration> handlerRegistrations) { CheckBox checkBox = new CheckBox(); checkBox.setValue(field.getValue()); checkBox.setTitle(field.getDisplayPrompt()); checkBox.setEnabled(!readOnly && !field.isReadOnly()); if (!readOnly && !field.isReadOnly()) { handlerRegistrations.add(checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override/*from ww w. j av a 2 s. c o m*/ public void onValueChange(ValueChangeEvent<Boolean> event) { field.setValue(event.getValue()); fireChanged(); } })); } return checkBox; }
From source file:org.kaaproject.avro.ui.sandbox.client.mvp.view.form.FormConstructorViewImpl.java
License:Apache License
public FormConstructorViewImpl() { setWidth(FULL_WIDTH);/*from w ww . java 2 s . c o m*/ int row = 0; HorizontalPanel toolbarPanel = new HorizontalPanel(); CheckBox readOnlyCheckBox = new CheckBox(Utils.constants.read_only()); readOnlyCheckBox.setWidth(FULL_WIDTH); readOnlyCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { form.setReadOnly(event.getValue()); } }); toolbarPanel.add(readOnlyCheckBox); Button showDisplayStringButton = new Button(Utils.constants.view_display_string()); showDisplayStringButton.getElement().getStyle().setMarginLeft(10, Unit.PX); showDisplayStringButton.addStyleName(Utils.avroUiStyle.buttonSmall()); showDisplayStringButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { RecordField field = form.getValue(); String displayString = field != null ? field.getDisplayString() : "null"; Window.alert(Utils.constants.display_string() + ":\n" + displayString); } }); toolbarPanel.add(showDisplayStringButton); setWidget(row++, 0, toolbarPanel); form = new RecordFieldWidget(new AvroWidgetsConfig.Builder().createConfig()); form.addValueChangeHandler(new ValueChangeHandler<RecordField>() { @Override public void onValueChange(ValueChangeEvent<RecordField> event) { fireFormChanged(); } }); CaptionPanel formPanel = new CaptionPanel(Utils.constants.avroUiView()); form.getElement().getStyle().setPropertyPx("minHeight", MIN_PANEL_HEIGHT); formPanel.add(form); setWidget(row++, 0, formPanel); showJsonButton = new Button(Utils.constants.showJson()); showJsonButton.setEnabled(true); loadJsonButton = new Button(Utils.constants.loadJson()); loadJsonButton.setEnabled(false); generateRecordButton = new Button(Utils.constants.generateRecordForm()); generateRecordButton.getElement().getStyle().setProperty("float", "right"); generateRecordButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { generateRecordButton.setEnabled(false); } }); FlexTable buttonTable = new FlexTable(); buttonTable.setWidth(FULL_WIDTH); HorizontalPanel buttonsPanel1 = new HorizontalPanel(); buttonsPanel1.setSpacing(15); buttonsPanel1.add(showJsonButton); buttonsPanel1.add(loadJsonButton); HorizontalPanel buttonsPanel2 = new HorizontalPanel(); buttonsPanel2.setSpacing(15); buttonsPanel2.add(generateRecordButton); buttonTable.setWidget(0, 0, buttonsPanel1); buttonTable.setWidget(0, 1, buttonsPanel2); setWidget(row++, 0, buttonTable); buttonTable.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT); buttonTable.getElement().getParentElement().getStyle().setPaddingTop(0, Unit.PX); jsonArea = new SizedTextArea(-1); jsonArea.getTextArea().setWidth(JSON_PANEL_WIDTH); jsonArea.getTextArea().getElement().getStyle().setPropertyPx("minHeight", 300); jsonArea.setVisible(false); jsonArea.addInputHandler(new InputEventHandler() { @Override public void onInputChanged(InputEvent event) { fireChanged(); } }); formJsonPanel = new CaptionPanel(Utils.constants.jsonView()); formJsonPanel.getElement().getStyle().setMargin(5, Unit.PX); VerticalPanel jsonAreaPanel = new VerticalPanel(); jsonAreaPanel.add(jsonArea); jsonAreaPanel.add(uploadForm); formJsonPanel.add(jsonAreaPanel); formJsonPanel.setVisible(false); setWidget(row, 0, formJsonPanel); downloadButton.setEnabled(false); uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); uploadForm.setAction(GWT.getModuleBaseURL() + UPLOAD_SERVLET_PATH); FlexTable fileOpsTable = new FlexTable(); fileOpsTable.setWidth(JSON_PANEL_WIDTH); fileOpsTable.setCellSpacing(8); int column = 0; uploadForm.setWidget(fileOpsTable); fileUpload.setName(Utils.constants.uploadFromFile()); fileOpsTable.setWidget(0, column++, uploadButton); fileOpsTable.setWidget(0, column, fileUpload); fileOpsTable.getFlexCellFormatter().setVerticalAlignment(0, column++, HasVerticalAlignment.ALIGN_MIDDLE); uploadButton.setEnabled(false); uploadButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { if (!"".equals(fileUpload.getFilename())) { uploadForm.submit(); } } }); fileUpload.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent changeEvent) { if (!"".equals(fileUpload.getFilename())) { uploadButton.setEnabled(true); } else { uploadButton.setEnabled(false); } } }); fileOpsTable.setWidget(0, column, downloadButton); fileOpsTable.getFlexCellFormatter().setHorizontalAlignment(0, column, HasHorizontalAlignment.ALIGN_RIGHT); }
From source file:org.kie.guvnor.guided.rule.client.editor.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 ww w . j a v a 2 s.co 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().size() == 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.kie.guvnor.guided.rule.client.editor.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)); }//w ww.j a v a 2s . 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().size() == 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.nsesa.editor.gwt.amendment.client.ui.amendment.share.SharePanelController.java
License:EUPL
/** * Sets the parent amendment controller, and registers the event listeners. * * @param amendmentController the parent amendment controller *///from www .j a v a 2s . c o m public void setAmendmentController(final AmendmentController amendmentController) { this.amendmentController = amendmentController; final ClientContext clientContext = amendmentController.getDocumentController().getClientFactory() .getClientContext(); PersonDTO person = clientContext.getLoggedInPerson(); view.getMainPanel().clear(); for (final GroupDTO group : person.getGroups()) { final CheckBox checkBox = new CheckBox(group.getName()); if (amendmentController.getModel().getGroups() != null) checkBox.setValue(amendmentController.getModel().getGroups().contains(group), false); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(final ValueChangeEvent<Boolean> event) { // TODO register this amendmentController.getDocumentController().getServiceFactory().getGwtAmendmentService() .shareAmendmentContainer(clientContext, amendmentController.getModel().getAmendmentContainerID(), group.getGroupID(), event.getValue(), new AsyncCallback<AmendmentContainerDTO>() { @Override public void onFailure(Throwable caught) { amendmentController.getDocumentController().getClientFactory() .getEventBus().fireEvent(new CriticalErrorEvent( "Could not share amendment with group.", caught)); } @Override public void onSuccess(AmendmentContainerDTO result) { EventBus eventBus = amendmentController.getDocumentController() .getClientFactory().getEventBus(); // merge our updated result amendmentController.setModel(result); eventBus.fireEvent(new AmendmentContainerMergeEvent(result)); // re-diff amendmentController.getDocumentController().getDocumentEventBus() .fireEvent( new AmendmentContainerSavedEvent(amendmentController)); String message = (event.getValue() ? "Successfully shared amendment with group " : "Successfully stopped sharing amendment with group ") + group.getName(); eventBus.fireEvent(new NotificationEvent(message)); } }); } }); addWidget(checkBox); } }
From source file:org.nsesa.editor.gwt.amendment.client.ui.document.amendments.AmendmentsPanelViewImpl.java
License:EUPL
/** * Display a check box and an amendment representation by using * {@link org.nsesa.editor.gwt.amendment.client.ui.amendment.AmendmentController#getExtendedView()} * for each amendment controller present in the provided map of amendment controllers * * @param amendments The amendments that will be displayed *///w w w . j a v a 2s.c o m @Override public void setAmendmentControllers(final Map<String, AmendmentController> amendments) { for (final Map.Entry<String, AmendmentController> entry : amendments.entrySet()) { FlowPanel panel = new FlowPanel(); //create a check box CheckBox checkBox = new CheckBox(); checkBox.getElement().getStyle().setFloat(Style.Float.LEFT); checkBox.getElement().getStyle().setPaddingTop(15, Style.Unit.PX); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { selectedAmendments.add(entry.getValue()); } else { selectedAmendments.remove(entry.getValue()); } documentEventBus .fireEvent(new OverlayWidgetAwareSelectionEvent(new Selection<AmendmentController>() { @Override public boolean select(AmendmentController amendmentController) { return selectedAmendments.contains(amendmentController); } })); } }); checkBoxes.put(entry.getKey(), checkBox); panel.add(checkBox); panel.add(entry.getValue().getExtendedView()); amendmentsPanel.add(panel); } }
From source file:org.onesocialweb.gwt.client.ui.widget.ListSelector.java
License:Apache License
public void addCheckbox(String list, Boolean value) { final CheckBox checkbox = new CheckBox(list); StyledFlowPanel fix = new StyledFlowPanel("fix"); checkbox.addStyleName("checkbox"); // manage checks and unchecks checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override//from w w w . j ava2 s . c om public void onValueChange(ValueChangeEvent<Boolean> event) { // is the item is checked? if (event.getValue() == true && !listed.contains(checkbox.getText()) && checkbox.getText() != null && checkbox.getText().length() != 0) { // set the values listed.add(checkbox.getText()); rosterItem.setGroups(listed); // disable during processing checkbox.setEnabled(false); // show task final DefaultTaskInfo task = new DefaultTaskInfo("Adding person to the list", false); TaskMonitor.getInstance().addTask(task); // save new state rosterItem.save(new RequestCallback<RosterItem>() { @Override public void onFailure() { // return to original state and notify user checkbox.setEnabled(true); checkbox.setValue(true); task.complete("Could not add person to list.", Status.failure); } @Override public void onSuccess(RosterItem result) { // enable the checkbox again checkbox.setEnabled(true); task.complete("", Status.succes); } }); } else if (event.getValue() == false && listed.contains(checkbox.getText())) { // set the values listed.remove(checkbox.getText()); rosterItem.setGroups(listed); // disable during processing checkbox.setEnabled(false); // show task final DefaultTaskInfo task = new DefaultTaskInfo("Removing person from the list", false); TaskMonitor.getInstance().addTask(task); // save new state rosterItem.save(new RequestCallback<RosterItem>() { @Override public void onFailure() { // return to original state and notify user checkbox.setEnabled(true); checkbox.setValue(true); task.complete("Could not remove person from the list.", Status.failure); } @Override public void onSuccess(RosterItem result) { // enable the checkbox again checkbox.setEnabled(true); task.complete("", Status.succes); } }); } } }); // if this person is already on the list make sure the checkbox is // checked if (listed != null && list.length() > 0 && listed.contains(list)) { checkbox.setValue(true); } else if (value == true) { // if a new checkbox is added automatically check it and fire a // change event checkbox.setValue(true); checkbox.fireEvent(new ValueChangeEvent<Boolean>(true) { }); } if (checkbox.getText() != null && checkbox.getText().length() != 0) { wrapper.add(checkbox); wrapper.add(fix); } }
From source file:org.pentaho.mantle.client.admin.PermissionsPanel.java
License:Open Source License
public void initializeActionBaseSecurityElements(String roleMappings) { JsLogicalRoleMap logicalRoleMap = (JsLogicalRoleMap) parseRoleMappings( JsonUtils.escapeJsonForEval(roleMappings)); if (logicalRoles.size() == 0) { for (int i = 0; i < logicalRoleMap.getLogicalRoles().length(); i++) { CheckBox permCB = new CheckBox(logicalRoleMap.getLogicalRoles().get(i).getLocalizedName()); permCB.addValueChangeHandler( new RolesValueChangeListener(logicalRoleMap.getLogicalRoles().get(i).getRoleName())); add(permCB);//from w w w. j a v a 2 s . c o m logicalRoles.put(logicalRoleMap.getLogicalRoles().get(i).getLocalizedName(), new LogicalRoleInfo(logicalRoleMap.getLogicalRoles().get(i).getRoleName(), permCB)); } } for (int j = 0; j < logicalRoleMap.getRoleAssignments().length(); j++) { String roleName = logicalRoleMap.getRoleAssignments().get(j).getRoleName(); List<String> logicalRoles = new ArrayList<String>(); JsArrayString jsLogicalRoles = logicalRoleMap.getRoleAssignments().get(j).getAssignedLogicalRoles(); if (jsLogicalRoles != null) { for (int k = 0; k < jsLogicalRoles.length(); k++) { logicalRoles.add(jsLogicalRoles.get(k)); } } masterRoleMap.put(roleName, logicalRoles); if (logicalRoleMap.getRoleAssignments().get(j).isImmutable()) { immutableRoles.add(roleName); } } }
From source file:org.pepstock.jem.gwt.client.panels.resources.inspector.widgets.CheckBoxesFieldPanel.java
License:Open Source License
@Override protected final void build() { inputObject = new Grid((int) Math.ceil(getDescriptor().getValues().size() / 2f), 2); inputObject.setWidth(Sizes.HUNDRED_PERCENT); checkBoxes = new CheckBox[getDescriptor().getValues().size()]; // builds the boxes and add them to panel Handler handler = new Handler(); List<String> valueList = new ArrayList<String>(getDescriptor().getValues()); Collections.sort(valueList);//from ww w . ja v a 2 s. com int i = 0; int row = 0; for (String v : valueList) { CheckBox cb = new CheckBox(v); // events cb.addValueChangeHandler(handler); checkBoxes[i] = cb; inputObject.setWidget(row, i % 2 == 0 ? 0 : 1, cb); if (++i % 2 == 0) { row++; } } ResourceProperty existingProperty = getPanel().getResource().getProperties().get(getDescriptor().getKey()); if (existingProperty != null) { setSelectedValue(CSVUtil.splitAndTrim(existingProperty.getValue())); // save not needed because it's aloaded property } else if (getDescriptor().hasDefaultValues()) { Set<String> defaultValue = getDescriptor().getDefaultValues(); String[] defaultValueArray = defaultValue.toArray(new String[0]); setSelectedValue(defaultValueArray); saveProperty(defaultValueArray); } }