Java Code Examples for com.smartgwt.client.widgets.form.fields.CheckboxItem#setValue()

The following examples show how to use com.smartgwt.client.widgets.form.fields.CheckboxItem#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DigitalObjectSearchView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private void filter() {
    CheckboxItem checkbox = ((CheckboxItem)filters.getField(DigitalObjectResourceApi.SEARCH_MODEL_PARAM_REMEMBER));
    if (checkbox.getValueAsBoolean()) {
        checkbox.setValue(false);
        Offline.put(sourceName, filters.getField(DigitalObjectResourceApi.SEARCH_QUERY_MODEL_PARAM).getValue());
    }
    Criteria valuesAsCriteria = filters.getValuesAsCriteria();
    foundGrid.deselectAllRecords();
    foundGrid.fetchData(valuesAsCriteria);
}
 
Example 2
Source File: SetPassword.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SetPassword(final long userId) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("changepassword"));
	setWidth(300);
	setHeight(140);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setWidth(350);

	MatchesFieldValidator equalsValidator = new MatchesFieldValidator();
	equalsValidator.setOtherField(NEWPASSWORDAGAIN);
	equalsValidator.setErrorMessage(I18N.message("passwordnotmatch"));

	LengthRangeValidator sizeValidator = new LengthRangeValidator();
	sizeValidator.setErrorMessage(
			I18N.message("errorfieldminlenght", Integer.toString(Session.get().getUser().getPasswordMinLenght())));
	sizeValidator.setMin(Session.get().getUser().getPasswordMinLenght());

	PasswordItem newPass = new PasswordItem();
	newPass.setName(NEWPASSWORD);
	newPass.setTitle(I18N.message(NEWPASSWORD));
	newPass.setRequired(true);
	newPass.setAutoComplete(AutoComplete.NONE);
	newPass.setValidators(equalsValidator, sizeValidator);

	PasswordItem newPassAgain = new PasswordItem();
	newPassAgain.setName(NEWPASSWORDAGAIN);
	newPassAgain.setTitle(I18N.message(NEWPASSWORDAGAIN));
	newPassAgain.setAutoComplete(AutoComplete.NONE);
	newPassAgain.setWrapTitle(false);
	newPassAgain.setRequired(true);

	final CheckboxItem notify = ItemFactory.newCheckbox(NOTIFY, "notifycredentials");
	notify.setValue(false);

	final ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				apply.setDisabled(true);
				SecurityService.Instance.get().changePassword(Session.get().getUser().getId(), userId, null,
						vm.getValueAsString(NEWPASSWORD), notify.getValueAsBoolean(), new AsyncCallback<Integer>() {

							@Override
							public void onFailure(Throwable caught) {
								SC.warn(caught.getMessage());
								apply.setDisabled(false);
							}

							@Override
							public void onSuccess(Integer ret) {
								apply.setDisabled(false);
								if (ret.intValue() > 0) {
									// Alert the user and maintain the popup
									// opened
									if (ret == 1)
										Log.warn(I18N.message("wrongpassword"), null);
									else if (ret == 2)
										Log.warn(I18N.message("passwdnotnotified"), null);
									else
										Log.warn(I18N.message("genericerror"), null);
								}
								SetPassword.this.destroy();
							}
						});
			}
		}
	});

	form.setFields(newPass, newPassAgain, notify, apply);

	addItem(form);
}
 
Example 3
Source File: ReplicateUserSettings.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ReplicateUserSettings(List<Long> userIds, final UsersPanel panel) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("replicatesettings"));
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setWidth(350);

	SelectItem masterUser = ItemFactory.newUserSelector("user", "masteruser", null, true);
	masterUser.setHint(I18N.message("masteruserhint"));

	final CheckboxItem userInterface = ItemFactory.newCheckbox("userinterface", "userinterface");
	userInterface.setValue(true);

	final CheckboxItem groups = ItemFactory.newCheckbox("groups", "groups");
	groups.setValue(false);

	final ButtonItem confirm = new ButtonItem();
	confirm.setTitle(I18N.message("confirm"));
	confirm.setAutoFit(true);
	confirm.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				long masterUserId = Long.parseLong(vm.getValueAsString("user"));
				ContactingServer.get().show();
				SecurityService.Instance.get().replicateUsersSettings(masterUserId, userIds.toArray(new Long[0]),
						userInterface.getValueAsBoolean(), groups.getValueAsBoolean(), new AsyncCallback<Void>() {

							@Override
							public void onFailure(Throwable caught) {
								ContactingServer.get().hide();
								Log.serverError(caught);
							}

							@Override
							public void onSuccess(Void arg0) {
								ContactingServer.get().hide();
								Log.info(I18N.message("userssaved"));
								destroy();
								panel.refresh();
							}
						});
			}
		}
	});

	form.setFields(masterUser, userInterface, groups, confirm);

	addItem(form);
}
 
Example 4
Source File: TaskNotificationPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onDraw() {
	VLayout notificationsPane = new VLayout();
	setMembers(notificationsPane);

	final DynamicForm notificationsForm = new DynamicForm();
	notificationsForm.setColWidths(1, "*");
	notificationsForm.setMargin(3);

	List<FormItem> items = new ArrayList<FormItem>();

	// Enable/Disable notifications
	CheckboxItem sendReport = new CheckboxItem();
	sendReport.setName("sendReport");
	sendReport.setTitle(I18N.message("sendactivityreport"));
	sendReport.setRedrawOnChange(true);
	sendReport.setWidth(50);
	sendReport.setValue(task.isSendActivityReport());
	sendReport.addChangedHandler(new ChangedHandler() {

		@Override
		public void onChanged(ChangedEvent event) {
			task.setSendActivityReport("true".equals(notificationsForm.getValue("sendReport").toString()));

			// Notify the external handler
			changedHandler.onChanged(event);
		}
	});

	items.add(sendReport);

	Long[] ids = new Long[task.getReportRecipients().length];
	for (int i = 0; i < ids.length; i++)
		ids[i] = task.getReportRecipients()[i].getId();

	recipients = ItemFactory.newMultiComboBoxItem("recipients", "recipients", new UsersDS(null, false), ids);
	recipients.setValueField("id");
	recipients.setDisplayField("username");
	recipients.addChangedHandler(changedHandler);
	items.add(recipients);

	notificationsForm.setItems(items.toArray(new FormItem[0]));
	notificationsPane.setMembers(notificationsForm);
}
 
Example 5
Source File: ImportSourceChooser.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private DynamicForm createOptionsForm() {
    DynamicForm form = new DynamicForm();
    form.setNumCols(10);
    form.setGroupTitle(i18n.ImportSourceChooser_Options_Title());
    form.setIsGroup(true);
    form.setWrapItemTitles(false);

    final CheckboxItem cbiPageIndexes = new CheckboxItem(ImportBatchDataSource.FIELD_INDICES,
            i18n.ImportSourceChooser_OptionPageIndices_Title());
    cbiPageIndexes.setValue(true);

    final SelectItem selectScanner = createScannerSelection();
    final SelectItem selectProfile = ProfileChooser.createProfileSelection(ProfileGroup.IMPORTS, i18n);
    selectProfile.setName(ImportBatchDataSource.FIELD_PROFILE_ID);
    selectProfile.addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {
            String profile = getImportProfile();
            Criteria criteria = new Criteria();
            if (profile != null) {
                criteria.addCriteria(ImportTreeDataSource.FIELD_PROFILE, profile);
            }
            treeGrid.setCriteria(criteria);
            boolean isArchive= BatchRecord.isArchive(profile);
            boolean isKramerius = BatchRecord.isKramerius(profile);
            selectScanner.setRequired(!isArchive);
            if (isKramerius) {
                selectScanner.show();
                cbiPageIndexes.hide();
            } else if (isArchive) {
                selectScanner.hide();
                cbiPageIndexes.hide();
            } else {
                selectScanner.show();
                cbiPageIndexes.show();
            }
        }
    });

    form.setFields(selectProfile, selectScanner, cbiPageIndexes);
    return form;
}
 
Example 6
Source File: SubscriptionListGrid.java    From SensorWebClient with GNU General Public License v2.0 4 votes vote down vote up
protected CheckboxItem createActivateCheckboxItem(final ListGridRecord ruleRecord) {
    CheckboxItem checkBox = new CheckboxItem(ACTIVATED_FIELD, " ");
    checkBox.setValue(ruleRecord.getAttributeAsBoolean(SUBSCRIBED));
    checkBox.addChangedHandler(createActivateChangedHandler(ruleRecord));
    return checkBox;
}