Java Code Examples for com.smartgwt.client.widgets.form.fields.RadioGroupItem#setRequired()

The following examples show how to use com.smartgwt.client.widgets.form.fields.RadioGroupItem#setRequired() . 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: AntivirusPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void initGUI(GUIParameter[] settings) {
	final DynamicForm form = new DynamicForm();
	form.setTitleOrientation(TitleOrientation.LEFT);
	form.setAlign(Alignment.LEFT);

	RadioGroupItem enabled = ItemFactory.newBooleanSelector("enabled", I18N.message("enabled"));
	enabled.setWrapTitle(false);
	enabled.setRequired(true);

	TextItem command = ItemFactory.newTextItem("command", "ClamAV", null);
	command.setWidth(400);

	TextItem includes = ItemFactory.newTextItem("includes", "include", null);
	includes.setWidth(400);

	TextItem excludes = ItemFactory.newTextItem("excludes", "exclude", null);
	excludes.setWidth(400);

	TextItem timeout = ItemFactory.newSpinnerItem("timeout", "timeout", (Integer) null);
	timeout.setHint(I18N.message("seconds"));

	for (GUIParameter setting : settings) {
		if ((Session.get().getTenantName() + ".antivirus.enabled").equals(setting.getName()))
			enabled.setValue("true".equals(setting.getValue()) ? "yes" : "no");
		else if ("antivirus.command".equals(setting.getName()))
			command.setValue(setting.getValue());
		else if ((Session.get().getTenantName() + ".antivirus.excludes").equals(setting.getName()))
			excludes.setValue(setting.getValue());
		else if ((Session.get().getTenantName() + ".antivirus.includes").equals(setting.getName()))
			includes.setValue(setting.getValue());
		else if ((Session.get().getTenantName() + ".antivirus.timeout").equals(setting.getName()))
			timeout.setValue(Integer.parseInt(setting.getValue()));
	}

	IButton save = new IButton();
	save.setTitle(I18N.message("save"));
	save.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			if (form.validate()) {
				GUIParameter[] params = new GUIParameter[Session.get().isDefaultTenant() ? 4 : 3];
				params[0] = new GUIParameter(Session.get().getTenantName() + ".antivirus.enabled",
						"" + ("yes".equals(form.getValueAsString("enabled"))));
				params[1] = new GUIParameter(Session.get().getTenantName() + ".antivirus.excludes",
						form.getValueAsString("excludes").trim());
				params[2] = new GUIParameter(Session.get().getTenantName() + ".antivirus.includes",
						form.getValueAsString("includes").trim());
				params[3] = new GUIParameter(Session.get().getTenantName() + ".antivirus.timeout",
						form.getValueAsString("timeout").trim());

				if (Session.get().isDefaultTenant())
					params[4] = new GUIParameter("antivirus.command", form.getValueAsString("command").trim());

				SettingService.Instance.get().saveSettings(params, new AsyncCallback<Void>() {

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

					@Override
					public void onSuccess(Void ret) {
						Log.info(I18N.message("settingssaved"), null);
					}
				});
			}
		}
	});
	if (Session.get().isDefaultTenant())
		form.setFields(enabled, command, includes, excludes, timeout);
	else
		form.setFields(enabled, includes, excludes, timeout);

	Tab tab = new Tab();
	tab.setTitle(I18N.message("antivirus"));
	tab.setPane(form);

	TabSet tabs = new TabSet();
	tabs.setWidth100();
	tabs.setHeight100();
	tabs.setTabs(tab);

	setMembers(tabs, save);
}
 
Example 2
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 3
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 4
Source File: ConversionDialog.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ConversionDialog(GUIDocument document) {
	this.document = document;
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);

	setTitle(I18N.message("convert") + " - " + document.getFileName());
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final RadioGroupItem action = ItemFactory.newRadioGroup("action", I18N.message("action"));
	action.setRequired(true);
	action.setEndRow(true);

	final SelectItem format = ItemFactory.newConversionFormatItem(document.getFileName());
	format.setEndRow(true);
	format.setRequired(true);

	final ButtonItem convert = new ButtonItem();
	convert.setStartRow(false);
	convert.setTitle(I18N.message("convert"));
	convert.setAutoFit(true);
	convert.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onConvert();
		}
	});

	FolderService.Instance.get().getFolder(document.getFolder().getId(), false, false, false, 
			new AsyncCallback<GUIFolder>() {

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

				@Override
				public void onSuccess(GUIFolder folder) {
					convert.setDisabled(!folder.isDownload() && !folder.isWrite());

					LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
					if (folder.isDownload())
						map.put("download", I18N.message("download"));
					if (folder.isWrite())
						map.put("save", I18N.message("save"));
					action.setValueMap(map);
					action.setValue("download");

					form.setFields(format, action, convert);
					addItem(form);
				}
			});
}