com.smartgwt.client.widgets.form.fields.CheckboxItem Java Examples

The following examples show how to use com.smartgwt.client.widgets.form.fields.CheckboxItem. 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: RegisterLayout.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
void createAcceptTermsOfUse() {
    // linkItem for terms of use
    this.linkTerms = new LinkItem("termsOfUse");
    this.linkTerms.setLinkTitle(i18n.termsOfUse());
    this.linkTerms.setShouldSaveValue(false);
    this.linkTerms.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            EventBus.getMainEventBus().fireEvent(new GetTermsOfUseEvent(PropertiesManager.language));
        }
    });

    this.acceptBox = new CheckboxItem();
    this.acceptBox.setName("acceptTerms");
    this.acceptBox.setTitle(i18n.acceptTermsOfUse());
    this.acceptBox.setValue(false);
    this.acceptBox.setRequired(true);
}
 
Example #2
Source File: SubscriptionListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
protected ChangedHandler createActivateChangedHandler(final ListGridRecord ruleRecord) {
    return new ChangedHandler() {
        @Override
        public void onChanged(ChangedEvent event) {
            CheckboxItem checkbox = (CheckboxItem) event.getSource();
            boolean checked = checkbox.getValueAsBoolean().booleanValue();
            String uuid = ruleRecord.getAttribute(UUID);
            String medium = ruleRecord.getAttribute(MEDIUM);
            String format = ruleRecord.getAttribute(FORMAT);
            ruleRecord.setAttribute(SUBSCRIBED, checked);
            if(checked) {
                getMainEventBus().fireEvent(new SubscribeEvent(currentSession(), uuid, medium, format));
            } else {
                getMainEventBus().fireEvent(new UnsubscribeEvent(currentSession(), uuid, medium, format));
            }
        }
    };
}
 
Example #3
Source File: PageMetadataEditor.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private void createPageIndexUi() {
    formPageIndex = createForm();

    allowPageIndexes = new CheckboxItem("fillPageIndexes", i18n.PageMetadataEditor_CheckboxPageIndices_Title());
    allowPageIndexes.setStartRow(true);
    allowPageIndexes.setColSpan("*");
    allowPageIndexes.setShowTitle(false);

    IntegerRangeValidator indexValidator = new IntegerRangeValidator();
    indexValidator.setMin(0);
    indexValidator.setMax(1000000);

    indexStart = new IntegerItem("indexStart", i18n.PageMetadataEditor_IndexStartValue_Title());
    indexStart.setRequired(true);
    indexStart.setValidators(indexValidator);

    allowPageIndexes.addChangedHandler(new DisableStateHandler(indexStart));
}
 
Example #4
Source File: CopyPageMetadataWidget.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private DynamicForm createForm() {
        DynamicForm form = new DynamicForm();
        form.setWrapItemTitles(false);
//        form.setAutoWidth();
        form.setAutoHeight();
        form.setBrowserSpellCheck(false);
        allowPageIndexes = new CheckboxItem("fillPageIndexes", i18n.PageMetadataEditor_CheckboxPageIndices_Title());
        allowPageIndexes.setStartRow(true);
        allowPageIndexes.setColSpan("*");
        allowPageIndexes.setShowTitle(false);
        allowPageNumbers = new CheckboxItem("fillPageNumbers", i18n.PageMetadataEditor_CheckboxPageNubers_Title());
        allowPageNumbers.setStartRow(true);
        allowPageNumbers.setColSpan("*");
        allowPageNumbers.setShowTitle(false);
        allowPageTypes = new CheckboxItem("fillPageTypes", i18n.PageMetadataEditor_CheckboxPageTypes_Title());
        allowPageTypes.setStartRow(true);
        allowPageTypes.setColSpan("*");
        allowPageTypes.setShowTitle(false);
        form.setFields(allowPageTypes, allowPageIndexes, allowPageNumbers);
        return form;
    }
 
Example #5
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 #6
Source File: PageMetadataEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private void createApplyToUi() {
    formApply = createForm();

    applyTo = new ComboBoxItem("applyTo", i18n.PageMetadataEditor_ApplyTo_Title());
    applyTo.setPrompt(i18n.PageMetadataEditor_ApplyTo_Hint());
    applyTo.setRequired(true);

    LinkedHashMap<String, String> vals = new LinkedHashMap<String, String>();
    vals.put("1", i18n.PageMetadataEditor_ApplyToEachItem_Title());
    for (int i = 2; i <= 20; i++) {
        String nth = String.valueOf(i);
        vals.put(nth, i18n.PageMetadataEditor_ApplyToEachNthItem_Title(nth));
    }
    applyTo.setValueMap(vals);
    applyTo.setDefaultValue(1);
    applyTo.setValue(1);

    applyToValidator = new IntegerRangeValidator();
    applyToValidator.setMin(1);
    applyToValidator.setMax(applyToMaxValue);
    applyTo.setValidators(new IsIntegerValidator(), applyToValidator);

    applyFromFirst = new CheckboxItem("applyFromFirst", i18n.PageMetadataEditor_ApplyFromFirst_Title());
    applyFromFirst.setPrompt(i18n.PageMetadataEditor_ApplyFromFirst_Hint());

    formApply.setItems(applyTo, applyFromFirst);

    applyTo.addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {
            applyFromFirst.setDisabled("1".equals(applyTo.getValueAsString()));
        }
    });
}
 
Example #7
Source File: PageMetadataEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see #setPageTypeValueMapId
 */
private void createPageTypeUi() {
    formPageType = createForm();

    allowPageTypes = new CheckboxItem("fillPageTypes", i18n.PageMetadataEditor_CheckboxPageTypes_Title());
    allowPageTypes.setStartRow(true);
    allowPageTypes.setColSpan("*");
    allowPageTypes.setShowTitle(false);

    pageType = new SelectItem(ModsCustomDataSource.FIELD_PAGE_TYPE, i18n.PageForm_PageType_Title());
    pageType.setDefaultValue(ModsCustomDataSource.getDefaultPageType());
    pageType.setValue(ModsCustomDataSource.getDefaultPageType());
    
    allowPageTypes.addChangedHandler(new DisableStateHandler(pageType));
}
 
Example #8
Source File: DigitalObjectSearchView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private CheckboxItem createRememberModelItem(String title, FormItemIfFunction showIf) {
    CheckboxItem item = new CheckboxItem(DigitalObjectResourceApi.SEARCH_MODEL_PARAM_REMEMBER, title);
    item.setColSpan(2);
    if (showIf != null) {
        item.setShowIfCondition(showIf);
    }
    return item;
}
 
Example #9
Source File: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private FormItem createFormItem(DisplayType displayType, Record profile) {
    String name = profile.getAttribute(WorkflowParameterDataSource.FIELD_NAME);
    switch (displayType) {
        case SELECT:
            SelectItem si = new SelectItem();
            setOptions(si, profile);
            si.setWidth("*");
            return si;
        case COMBOBOX:
            ComboBoxItem cbi = new ComboBoxItem();
            setOptions(cbi, profile);
            cbi.setLength(2000);
            cbi.setWidth("*");
            return cbi;
        case CHECKBOX:
            CheckboxItem ci = new CheckboxItem();
            // the width must be set otherwise it overflows the form
            ci.setWidth(150);
            ci.setAllowEmptyValue(true);
            return ci;
        case TEXTAREA:
            TextAreaItem tai = new TextAreaItem();
            tai.setStartRow(true);
            tai.setEndRow(true);
            tai.setLength(2000);
            tai.setColSpan("*");
            tai.setWidth("*");
            tai.setHeight(30);
            return tai;
        case DATETIME:
            DateTimeItem di = new DateTimeItem();
            return di;
        case TEXT:
        default:
            TextItem ti = new TextItem(name);
            ti.setLength(2000);
            ti.setWidth("*");
            return ti;
    }
}
 
Example #10
Source File: DesaExportAction.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public ExportOptionsWidget() {
    i18n = GWT.create(ClientMessages.class);
    label = new Label();
    label.setMargin(5);
    label.setWidth100();
    label.setAutoHeight();
    label.setWrap(false);
    form = new DynamicForm();
    CheckboxItem hierarchy = new CheckboxItem(ExportResourceApi.DESA_HIERARCHY_PARAM,
            i18n.ExportOptionsWidget_Hierarchy_Title());
    hierarchy.setPrompt(i18n.ExportOptionsWidget_Hierarchy_Hint());
    form.setFields(hierarchy);
}
 
Example #11
Source File: StampDialog.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public StampDialog(final DocumentsGrid sourceGrid) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("applystamp"));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	setAutoSize(true);
	centerInPage();

	stamp = ItemFactory.newStampSelector();
	stamp.setTitle(I18N.message("choosestamp"));
	stamp.setWrapTitle(false);
	stamp.setRequired(true);

	visualPositioning = new CheckboxItem();
	visualPositioning.setName("visualpositioning");
	visualPositioning.setTitle(I18N.message("visualpositioning"));

	ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onApply(sourceGrid);
		}
	});

	form.setTitleOrientation(TitleOrientation.TOP);
	form.setFields(stamp, visualPositioning, apply);

	addItem(form);
}
 
Example #12
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 #13
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 #14
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static CheckboxItem newCheckbox(String name, String title) {
	CheckboxItem item = new CheckboxItem();
	item.setName(filterItemName(name));
	item.setTitle(I18N.message(title));
	return item;
}
 
Example #15
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 #16
Source File: PageMetadataEditor.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private void createPageNumberUi() {
    formPageNumber = createForm();

    allowPageNumbers = new CheckboxItem("fillPageNumbers", i18n.PageMetadataEditor_CheckboxPageNubers_Title());
    allowPageNumbers.setStartRow(true);
    allowPageNumbers.setColSpan("*");
    allowPageNumbers.setShowTitle(false);

    PageNumberChangeHandler pageNumberChangeHandler = new PageNumberChangeHandler();

    integerStartValidator = new IntegerRangeValidator();
    integerStartValidator.setMin(0);
    integerStartValidator.setMax(1000000);
    romanStartValidator = new RegExpValidator(
            "^[1-9][0-9]{0,6}$"
            + "|^[mM]{0,6}([cC][mM]|[cC][dD]|[dD]?[cC]{0,3})([xX][cC]|[xX][lL]|[lL]?[xX]{0,3})([iI][xX]|[iI][vV]|[vV]?[iI]{0,3})$");
    alphabetStartValidator = new RegExpValidator("^[a-zA-Z]{0,6}$");
    numberStartRequired = new RequiredIfValidator(new RequiredIfFunction() {

        @Override
        public boolean execute(FormItem formItem, Object value) {
            return true;
        }
    });
    numberStart = new TextItem("numberStart", i18n.PageMetadataEditor_NumberStartValue_Title());
    numberStart.addChangedHandler(pageNumberChangeHandler);

    prefix = new TextItem("prefix", i18n.PageMetadataEditor_NumberPrefix_Title());
    prefix.setLength(20);
    prefix.addChangedHandler(pageNumberChangeHandler);

    suffix = new TextItem("suffix", i18n.PageMetadataEditor_NumberSuffix_Title());
    suffix.setLength(20);
    suffix.addChangedHandler(pageNumberChangeHandler);

    integerIncrementValidator = new IntegerRangeValidator();
    integerIncrementValidator.setMin(-1000);
    integerIncrementValidator.setMax(1000);
    numberIncrement = new IntegerItem("numberIncrement", i18n.PageMetadataEditor_NumberIncrement_Title());
    numberIncrement.addChangedHandler(pageNumberChangeHandler);
    numberIncrement.setRequired(true);
    numberIncrement.setValidators(integerIncrementValidator);

    numberExample = new StaticTextItem("numberExample", i18n.PageMetadataEditor_NumberPreview_Title());
    numberExample.setClipValue(true);
    numberExample.setWidth(120); // enforce clip value

    seriesType = new SelectItem("seriesType", i18n.PageMetadataEditor_NumberSeriesType_Title());
    seriesType.setValueMap(ARABIC_SERIES, ROMAN_UPPER_SERIES,
            ROMAN_LOWER_SERIES, ALPHABET_UPPER_SERIES, ALPHABET_LOWER_SERIES);
    seriesType.setDefaultValue(ARABIC_SERIES);
    seriesType.setValue(ARABIC_SERIES);
    seriesType.addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {
            setSequenceType(seriesType.getValueAsString());
        }
    });

    allowPageNumbers.addChangedHandler(new DisableStateHandler(
            prefix, numberStart, numberIncrement, suffix, seriesType, numberExample));
}
 
Example #17
Source File: SignatureDialog.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SignatureDialog(long[] docIds) {
	super();

	this.docIds = docIds;

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

	VLayout layout = new VLayout();
	layout.setWidth100();
	layout.setHeight(40);

	form.setValuesManager(vm);
	form.setWrapItemTitles(false);
	form.setTitleOrientation(TitleOrientation.TOP);
	form.setNumCols(2);

	TextItem reason = ItemFactory.newTextItem("reason", "reason", null);
	reason.setRequired(true);
	reason.setWrapTitle(false);
	reason.setWidth(250);
	reason.setAutoComplete(AutoComplete.NONE);

	visualPositioning = new CheckboxItem();
	visualPositioning.setName("visualpositioning");
	visualPositioning.setTitle(I18N.message("visualpositioning"));
	visualPositioning.setDisabled(true);

	form.setItems(reason, visualPositioning);

	IButton sign = new IButton(I18N.message("sign"));
	sign.setAutoFit(true);
	sign.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onSign();
		}
	});

	HLayout buttons = new HLayout();
	buttons.setMembersMargin(5);
	buttons.setMargin(3);
	buttons.addMember(sign);

	layout.addMember(form);
	layout.addMember(buttons);

	addItem(layout);

	SignService.Instance.get().isVisualSignatureEnabled(new AsyncCallback<Boolean>() {

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

		@Override
		public void onSuccess(Boolean enabled) {
			visualPositioning.setDisabled(!enabled);
		}
	});
}
 
Example #18
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;
}
 
Example #19
Source File: ApplyTemplateDialog.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ApplyTemplateDialog() {
	super();
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("applytemplate"));
	setAutoSize(true);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();

	VLayout content = new VLayout();
	content.setWidth100();
	content.setHeight100();
	content.setMembersMargin(2);

	final TreeGrid folders = new FolderTree();
	folders.setWidth100();
	folders.setHeight100();

	final boolean inheritOptionEnabled = "true".equals(Session.get().getInfo()
			.getConfig("gui.security.inheritoption"));

	final DynamicForm form = new DynamicForm();

	CheckboxItem inheritSecurity = new CheckboxItem();
	inheritSecurity.setName("inheritSecurity");
	inheritSecurity.setTitle(I18N.message("inheritparentsec"));
	form.setItems(inheritSecurity);

	SelectItem templateSelector = ItemFactory.newFolderTemplateSelector();

	if (inheritOptionEnabled)
		form.setItems(templateSelector, inheritSecurity);

	Button apply = new Button(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.setMargin(1);
	apply.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			if (!form.validate())
				return;

			final TreeNode selectedNode = (TreeNode) FolderNavigator.get().getSelectedRecord();
			final long folderId = Long.parseLong(selectedNode.getAttributeAsString("folderId"));
			long templateId = Long.parseLong(form.getValueAsString("foldertemplate"));

			FolderService.Instance.get().applyTemplate(folderId, templateId,
					inheritOptionEnabled && "true".equals(form.getValueAsString("inheritSecurity")),
					new AsyncCallback<Void>() {

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

						@Override
						public void onSuccess(Void arg0) {
							FolderNavigator.get().getTree().reloadChildren(selectedNode);
							Log.info(I18N.message("templateapplied"), null);
							destroy();
						}
					});
		}
	});

	content.setMembers(form, apply);
	addItem(content);
}
 
Example #20
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);
}