Java Code Examples for com.smartgwt.client.widgets.form.DynamicForm#setIsGroup()

The following examples show how to use com.smartgwt.client.widgets.form.DynamicForm#setIsGroup() . 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: TwoFactorsAuthenticationSettings.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void init(GUIParameter[] parameters) {
	DynamicForm form = new DynamicForm();
	form.setWidth(1);
	form.setValuesManager(vm);
	form.setTitleOrientation(TitleOrientation.LEFT);
	form.setNumCols(1);

	Map<String, String> settings = Util.convertToMap(parameters);
	final RadioGroupItem enable2fa = ItemFactory.newBooleanSelector("enable2fa", I18N.message("enable2fa"));
	enable2fa.setValue("true".equals(settings.get("enabled")) ? "yes" : "no");
	enable2fa.setWrapTitle(false);
	enable2fa.setWrap(false);
	enable2fa.setRequired(true);
	enable2fa.setDisabled(Session.get().isDemo());
	form.setFields(enable2fa);

	/*
	 * GoogleAuthenticator section
	 */
	DynamicForm googleForm = new DynamicForm();
	googleForm.setValuesManager(vm);
	googleForm.setTitleOrientation(TitleOrientation.TOP);
	googleForm.setIsGroup(true);
	googleForm.setGroupTitle("Google Authenticator");
	googleForm.setNumCols(1);

	final RadioGroupItem enableGoolge = ItemFactory.newBooleanSelector("enableGoolge",
			I18N.message("enablegoogleauthenticator"));
	enableGoolge.setValue("true".equals(settings.get(Constants.TWOFA_GOOGLE_AUTHENTICATOR + ".enabled")) ? "yes"
			: "no");
	enableGoolge.setWrapTitle(false);
	enableGoolge.setWrap(false);
	enableGoolge.setRequired(true);
	enableGoolge.setDisabled(Session.get().isDemo());
	googleForm.setFields(enableGoolge);

	/*
	 * Yubikey section
	 */
	DynamicForm yubikeyForm = new DynamicForm();
	yubikeyForm.setValuesManager(vm);
	yubikeyForm.setTitleOrientation(TitleOrientation.TOP);
	yubikeyForm.setIsGroup(true);
	yubikeyForm.setGroupTitle("YubiKey");
	yubikeyForm.setNumCols(1);

	final RadioGroupItem enableYubikey = ItemFactory.newBooleanSelector("enableYubikey",
			I18N.message("enableyubikey"));
	enableYubikey.setValue("true".equals(settings.get("yubikey.enabled")) ? "yes" : "no");
	enableYubikey.setWrapTitle(false);
	enableYubikey.setWrap(false);
	enableYubikey.setRequired(true);
	enableYubikey.setDisabled(Session.get().isDemo());
	yubikeyForm.setFields(enableYubikey);

	IButton save = new IButton();
	save.setTitle(I18N.message("save"));
	save.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			if (vm.validate()) {
				String tenant = Session.get().getTenantName();
				final List<GUIParameter> params = new ArrayList<GUIParameter>();
				params.add(new GUIParameter(tenant + ".2fa.enabled",
						vm.getValueAsString("enable2fa").equals("yes") ? "true" : "false"));
				params.add(new GUIParameter(tenant + ".2fa." + Constants.TWOFA_GOOGLE_AUTHENTICATOR + ".enabled",
						vm.getValueAsString("enableGoolge").equals("yes") ? "true" : "false"));
				params.add(new GUIParameter(tenant + ".2fa." + Constants.TWOFA_YUBIKEY + ".enabled",
						vm.getValueAsString("enableYubikey").equals("yes") ? "true" : "false"));
				SettingService.Instance.get().saveSettings(params.toArray(new GUIParameter[0]),
						new AsyncCallback<Void>() {

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

							@Override
							public void onSuccess(Void arg) {
								Session.get().updateConfig(params);
								Log.info(I18N.message("settingssaved"), null);
							}
						});
			}
		}
	});

	VLayout panel = new VLayout();
	panel.setWidth100();
	panel.setMembers(form, googleForm, yubikeyForm);

	body.setMembers(panel);
	addMember(save);
}
 
Example 2
Source File: ExternalAppsPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Tab prepareExternalCall(GUIParameter[] settings) {
	VLayout pane = new VLayout();

	Tab extCall = new Tab();
	extCall.setTitle(I18N.message("externalcall"));
	DynamicForm extCallForm = new DynamicForm();
	extCallForm.setWidth(400);
	extCallForm.setIsGroup(true);
	extCallForm.setNumCols(2);
	extCallForm.setPadding(2);
	extCallForm.setGroupTitle(I18N.message("externalcall"));
	extCallForm.setValuesManager(vm);
	extCallForm.setTitleOrientation(TitleOrientation.LEFT);
	final RadioGroupItem extCallEnabled = ItemFactory.newBooleanSelector("extCallEnabled", "enabled");
	extCallEnabled.setRequired(true);
	extCallEnabled.setRedrawOnChange(true);
	extCallEnabled.setValue("no");

	TextItem extCallName = ItemFactory.newTextItem("extCallName", I18N.message("name"), null);
	TextItem extCallBaseUrl = ItemFactory.newTextItem("extCallBaseUrl", I18N.message("baseurl"), null);
	extCallBaseUrl.setWidth(300);
	TextItem extCallSuffix = ItemFactory.newTextItem("extCallSuffix", I18N.message("suffix"), null);
	extCallSuffix.setWidth(300);
	TextItem extCallWindow = ItemFactory.newTextItem("extCallWindow", I18N.message("targetwindow"), "_blank");

	extCallForm.setItems(extCallEnabled, extCallName, extCallBaseUrl, extCallSuffix, extCallWindow);

	// Use a second form to group the parameters section
	DynamicForm parametersForm = new DynamicForm();
	parametersForm.setWidth(400);
	parametersForm.setIsGroup(true);
	parametersForm.setGroupTitle(I18N.message("parameters"));
	parametersForm.setNumCols(4);
	extCallForm.setPadding(2);
	parametersForm.setValuesManager(vm);
	extCallParamUser = ItemFactory.newCheckbox("extCallParamUser", "user");
	extCallParamTitle = ItemFactory.newCheckbox("extCallParamTitle", "filename");
	parametersForm.setItems(extCallParamUser, extCallParamTitle);

	pane.setMembers(extCallForm, parametersForm);
	extCall.setPane(pane);

	String tenant = Session.get().getTenantName();
	for (GUIParameter s : settings) {
		if ((tenant + ".extcall.enabled").equals(s.getName()))
			extCallEnabled.setValue("true".equals(s.getValue()) ? "yes" : "no");
		else if ((tenant + ".extcall.name").equals(s.getName()))
			extCallName.setValue(s.getValue());
		else if ((tenant + ".extcall.baseurl").equals(s.getName()))
			extCallBaseUrl.setValue(s.getValue());
		else if ((tenant + ".extcall.suffix").equals(s.getName()))
			extCallSuffix.setValue(s.getValue());
		else if ((tenant + ".extcall.window").equals(s.getName()))
			extCallWindow.setValue(s.getValue());
		else if ((tenant + ".extcall.params").equals(s.getName())) {
			String[] tokens = s.getValue().split(",");
			for (String param : tokens) {
				if ("user".equals(param.trim()))
					extCallParamUser.setValue("true");
				else if ("filename".equals(param.trim()))
					extCallParamTitle.setValue("true");
			}
		}
	}

	return extCall;
}
 
Example 3
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;
}