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

The following examples show how to use com.smartgwt.client.widgets.form.DynamicForm#setPadding() . 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: TagsSettingsPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onDraw() {
	DynamicForm parametersForm = new DynamicForm();
	parametersForm.setValuesManager(vm);
	parametersForm.setTitleOrientation(TitleOrientation.LEFT);
	parametersForm.setNumCols(2);
	parametersForm.setColWidths(1, "*");
	parametersForm.setPadding(5);

	SelectItem mode = ItemFactory.newTagInputMode("mode", "inputmode");

	SpinnerItem maxsize = ItemFactory.newSpinnerItem("maxsize", I18N.message("maxsize"), (Long) null);
	maxsize.setRequired(true);

	SpinnerItem minsize = ItemFactory.newSpinnerItem("minsize", I18N.message("minsize"), (Long) null);
	minsize.setRequired(true);

	SpinnerItem cloudElements = ItemFactory.newSpinnerItem("cloudElements", I18N.message("tagcloudelements"),
			(Long) null);
	cloudElements.setRequired(true);
	cloudElements.setWrapTitle(false);

	TextItem vocabulary = ItemFactory.newTextItem("vocabulary", I18N.message("vocabulary"), null);
	vocabulary.setRequired(true);
	vocabulary.setWidth(300);

	parametersForm.setItems(mode, maxsize, minsize, cloudElements, vocabulary);
	addMember(parametersForm);

	for (GUIParameter p : settings) {
		if (p.getName().endsWith("tag.mode"))
			mode.setValue(p.getValue());
		if (p.getName().endsWith("tag.maxsize"))
			maxsize.setValue(p.getValue());
		if (p.getName().endsWith("tag.minsize"))
			minsize.setValue(p.getValue());
		if (p.getName().endsWith("tag.vocabulary"))
			vocabulary.setValue(p.getValue());
		if (p.getName().endsWith("tagcloud.maxtags"))
			cloudElements.setValue(p.getValue());
	}

	IButton save = new IButton();
	save.setTitle(I18N.message("save"));
	save.addClickHandler(new ClickHandler() {
		@SuppressWarnings("unchecked")
		public void onClick(ClickEvent event) {
			final Map<String, Object> values = (Map<String, Object>) vm.getValues();

			if (vm.validate()) {
				List<GUIParameter> params = new ArrayList<GUIParameter>();

				params.add(new GUIParameter(Session.get().getTenantName() + ".tag.mode", values.get("mode")
						.toString()));
				params.add(new GUIParameter(Session.get().getTenantName() + ".tag.maxsize", values.get("maxsize")
						.toString()));
				params.add(new GUIParameter(Session.get().getTenantName() + ".tag.minsize", values.get("minsize")
						.toString()));
				params.add(new GUIParameter(Session.get().getTenantName() + ".tag.vocabulary", values.get(
						"vocabulary").toString()));
				params.add(new GUIParameter(Session.get().getTenantName() + ".tagcloud.maxtags", values.get(
						"cloudElements").toString()));

				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 ret) {
								Session.get()
										.getInfo()
										.setConfig(Session.get().getTenantName() + ".tag.mode",
												values.get("mode").toString());
								Session.get()
										.getInfo()
										.setConfig(Session.get().getTenantName() + ".tag.maxsize",
												values.get("maxsize").toString());

								Session.get()
										.getInfo()
										.setConfig(Session.get().getTenantName() + ".tag.minsize",
												values.get("minsize").toString());

								Session.get()
										.getInfo()
										.setConfig(Session.get().getTenantName() + ".tagcloud.maxtags",
												values.get("cloudElements").toString());

								Log.info(I18N.message("settingssaved"), null);
							}
						});
			}
		}
	});

	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;
}