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

The following examples show how to use com.smartgwt.client.widgets.form.fields.TextItem#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: DeviceManager.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private DynamicForm createForm() {
    DynamicForm df = new DynamicForm();
    df.setMargin(4);
    df.setNumCols(1);
    df.setTitleOrientation(TitleOrientation.TOP);
    df.setBrowserSpellCheck(false);
    df.setDataSource(DeviceDataSource.getInstance());
    TextItem fieldId = new TextItem(DeviceDataSource.FIELD_ID);
    fieldId.setWidth(280);
    fieldId.setCanEdit(false);
    fieldId.setReadOnlyDisplay(ReadOnlyDisplayAppearance.STATIC);
    TextItem fieldModel = new TextItem(DeviceDataSource.FIELD_MODEL);
    fieldModel.setCanEdit(false);
    fieldModel.setRequired(true);
    TextItem fieldLabel = new TextItem(DeviceDataSource.FIELD_LABEL);
    fieldLabel.setRequired(true);
    fieldLabel.setWidth("*");
    df.setItems(fieldId, fieldModel,  fieldLabel);
    return df;
}
 
Example 2
Source File: Setup.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Prepares the repository form
 */
private Tab setupRepository(final ValuesManager vm, GUIInfo info) {
	// Prepare the tab used to configure the repository where documents and
	// other data will be stored
	Tab repositoryTab = new Tab();
	repositoryTab.setTitle(I18N.message("repository"));

	final DynamicForm repositoryForm = new DynamicForm();
	repositoryForm.setID("repositoryForm");
	repositoryForm.setValuesManager(vm);
	String dir = info.getConfig("store.1.dir");
	if (dir != null && dir.endsWith("docs"))
		dir = dir.substring(0, dir.length() - 4);
	TextItem repositoryItem = ItemFactory.newTextItem(REPOSITORY_FOLDER, "repofolder",
			dir);
	repositoryItem.setWidth(400);
	repositoryItem.setRequired(true);
	repositoryItem.setWrapTitle(false);
	repositoryItem.setDefaultValue(getDefaultFolder());
	repositoryForm.setFields(repositoryItem);
	repositoryForm.setDisabled(true);

	repositoryTab.setPane(repositoryForm);
	return repositoryTab;
}
 
Example 3
Source File: DigitalObjectChildrenEditor.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private DynamicForm createParamsForm() {
    ClientMessages i18n = GWT.create(ClientMessages.class);
    DynamicForm f = new DynamicForm();
    f.setAutoHeight();

    TextItem newPid = new TextItem(DigitalObjectDataSource.FIELD_PID);

    newPid.setTitle(i18n.NewDigObject_OptionPid_Title());
    newPid.setTooltip(i18n.NewDigObject_OptionPid_Hint());
    newPid.setRequired(true);
    newPid.setLength(36 + 5);
    newPid.setWidth((36 + 5) * 8);
    newPid.setValidators(new CustomUUIDValidator(i18n));
    f.setFields(newPid);
    f.setAutoFocus(true);
    return f;
}
 
Example 4
Source File: UploadFile.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private DynamicForm createForm() {
    DynamicForm form = new DynamicForm();
    form.setEncoding(Encoding.MULTIPART);
    form.setBrowserSpellCheck(false);
    form.setNumCols(2);
    form.setTitleOrientation(TitleOrientation.TOP);
    form.setCanSubmit(true);

    TextItem mimeItem = new TextItem(FIELD_MIMETYPE,
            i18n.DigitalObjectEditor_MediaEditor_Uploader_Mimetype_Title());
    mimeItem.setWidth(400);
    mimeItem.setColSpan(2);

    TextItem filenameItem = new TextItem(FIELD_FILE,
            i18n.DigitalObjectEditor_MediaEditor_Uploader_Filename_Title());
    filenameItem.setWidth(400);
    filenameItem.setColSpan(2);
    filenameItem.setRequired(Boolean.TRUE);

    HiddenItem pidItem = new HiddenItem(FIELD_PID);
    HiddenItem batchIdItem = new HiddenItem(FIELD_BATCHID);
    form.setFields(filenameItem, mimeItem, pidItem, batchIdItem);
    return form;
}
 
Example 5
Source File: IdentifierDataSource.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public IdentifierDataSource() {
    setID(ID);
    ClientMessages i18n = GWT.create(ClientMessages.class);
    SmartGwtMessages i18nSmartGwt = ClientUtils.createSmartGwtMessages();

    DataSourceField type = new DataSourceField(FIELD_TYPE, FieldType.TEXT,
            i18n.PageForm_IdentifierType_Title());
    type.setRequired(Boolean.TRUE);

    ComboBoxItem typeEditor = new ComboBoxItem(IdentifierDataSource.FIELD_TYPE);
    LocalizationDataSource.setOptionDataSource(typeEditor, BundleName.MODS_IDENTIFIER_TYPES);
    typeEditor.setType("comboBox");
    typeEditor.setCharacterCasing(CharacterCasing.LOWER);
    typeEditor.setBrowserSpellCheck(Boolean.FALSE);
    type.setEditorType(typeEditor);

    DataSourceField value = new DataSourceField(FIELD_VALUE, FieldType.TEXT,
            i18n.PageForm_IdentifierValue_Title());
    value.setRequired(Boolean.TRUE);
    TextItem valueEditor = new TextItem(IdentifierDataSource.FIELD_VALUE);
    valueEditor.setWidth("250");
    valueEditor.setBrowserSpellCheck(Boolean.FALSE);
    valueEditor.setRequired(Boolean.TRUE);
    valueEditor.setValidators(new IdentifierValidator(i18n, i18nSmartGwt));
    value.setEditorType(valueEditor);

    DataSourceField object = new DataSourceField(FIELD_VALUE, FieldType.ANY);
    object.setHidden(true);
    setFields(type, value);
    setClientOnly(true);
    setCacheAllData(true);
}
 
Example 6
Source File: PeriodicalVolumeForm.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public PeriodicalVolumeForm(ClientMessages i18n) {
    setWidth100();
    setHeight100();
    setTitleOrientation(TitleOrientation.TOP);
    setNumCols(1);

    TextItem volumeNumber = new TextItem(ModsCustomDataSource.FIELD_PER_VOLUME_NUMBER,
            i18n.PeriodicalVolumeForm_Number_Title());
    volumeNumber.setRequired(true);
    // javascript regexp ^([1-9]\d{0,4}(-[1-9]\d{0,4})?)$
    volumeNumber.setValidators(new StringTrimValidator(), new RegExpValidator("^([1-9]\\d{0,4}(-[1-9]\\d{0,4})?)$"));
    TextItem date = new TextItem(ModsCustomDataSource.FIELD_PER_VOLUME_YEAR,
            i18n.PeriodicalVolumeForm_Date_Title());
    date.setRequired(true);
    // issue 43; see https://docs.google.com/document/d/1zSriHPdnUY5d_tKv0M8a6nEym560DKh2H6XZ24tGAEw/edit?pli=1
    // javascript regexp ^([1-9]\d{3}(-[1-9]\d{3})?)$
    date.setValidators(new StringTrimValidator(), new RegExpValidator("^([1-9]\\d{3}(-[1-9]\\d{3})?)$"));
    date.setEndRow(true);

    // identifiers
    final RepeatableFormItem identifiers = new RepeatableFormItem(ModsCustomDataSource.FIELD_IDENTIFIERS,
            i18n.PeriodicalVolumeForm_Identifiers_Title());
    identifiers.setDataSource(IdentifierDataSource.getInstance());
    identifiers.setValidators(
            new IdentifiersValidator(i18n, Arrays.asList(IdentifierDataSource.TYPE_UUID)));
    DynamicForm identifierForm = new DynamicForm();
    identifierForm.setUseAllDataSourceFields(true);
    identifierForm.setNumCols(4);
    identifiers.setFormPrototype(identifierForm);
    identifiers.setEndRow(true);
    identifiers.setColSpan("2");

    TextAreaItem note = new TextAreaItem(ModsCustomDataSource.FIELD_NOTE,
            i18n.PeriodicalVolumeForm_Note_Title());
    note.setWidth("*");
    note.setHeight("*");
    note.setColSpan("*");

    setFields(volumeNumber, date, identifiers, note);
}
 
Example 7
Source File: WebcontentCreate.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WebcontentCreate() {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("createwebcontent"));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	setAutoSize(true);
	centerInPage();
	
	
	DynamicForm form = new DynamicForm();
	vm = new ValuesManager();
	form.setValuesManager(vm);
	form.setTitleOrientation(TitleOrientation.TOP);
	form.setNumCols(1);

	TextItem title = ItemFactory.newSimpleTextItem("title", "title", null);
	title.setRequired(true);
	title.setWidth(200);

	SelectItem template = ItemFactory.newTemplateSelector(true, null);

	create = new SubmitItem();
	create.setTitle(I18N.message("create"));
	create.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onCreate();
		}
	});

	form.setItems(title, template, create);

	addItem(form);
}
 
Example 8
Source File: ZonalOCRTemplateSettings.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void prepareForm() {
	form = new DynamicForm();
	form.setWidth100();
	form.setAlign(Alignment.LEFT);
	form.setColWidths("1px, 100%");
	vm = new ValuesManager();
	form.setValuesManager(vm);

	final StaticTextItem fileNameWaring = ItemFactory.newStaticTextItem("fileNameWarning",
			I18N.message("attention"), I18N.message("filenamewarning"));
	fileNameWaring.setRequired(true);

	TextItem name = ItemFactory.newTextItem("name", "name", ocrPanel.getSelectedOcrTemplate().getName());
	name.setRequired(true);
	name.setDisabled(ocrPanel.getSelectedOcrTemplate().getId() != 0L);

	StaticTextItem id = ItemFactory.newStaticTextItem("id", I18N.message("id"),
			"" + ocrPanel.getSelectedOcrTemplate().getId());
	id.setVisible(ocrPanel.getSelectedOcrTemplate().getId() != 0L);

	SpinnerItem batch = ItemFactory.newSpinnerItem("batch", "batch",
			Session.get().getConfigAsInt("zonalocr.batch"));
	batch.setStep(50);
	batch.setMin(1);

	TextAreaItem description = ItemFactory.newTextAreaItem("description", "description",
			ocrPanel.getSelectedOcrTemplate().getDescription());
	description.setHeight(200);

	if (Session.get().isDefaultTenant())
		form.setItems(id, name, description, batch);
	else
		form.setItems(id, name, description);
}
 
Example 9
Source File: AddForm.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public AddForm() {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);

	setTitle(I18N.message("addform"));
	setAutoSize(true);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();

	formSelector = ItemFactory.newFormSelector();
	formSelector.setWrapTitle(false);
	formSelector.setRequired(true);

	TextItem title = ItemFactory.newTextItem("title", "title", null);
	title.setRequired(true);

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

	form.setNumCols(2);
	form.setTitleOrientation(TitleOrientation.TOP);
	form.setFields(title, formSelector, save);
	addItem(form);
}
 
Example 10
Source File: ReplaceVersionFile.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ReplaceVersionFile(GUIDocument document, String fileVersion) {
	this.document = document;
	this.fileVersion = fileVersion;
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("replacefile"));
	setWidth(420);
	
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	setAutoSize(true);
	centerInPage();

	DynamicForm form = new DynamicForm();
	vm = new ValuesManager();
	form.setValuesManager(vm);

	TextItem commentItem = ItemFactory.newTextItem("comment", "comment", null);
	commentItem.setRequired(true);
	commentItem.setWidth(250);

	form.setItems(commentItem);

	// Create a new uploader panel and attach it to the window
	multiUploader = new MultiUploader();
	multiUploader.setStyleName("upload");
	multiUploader.setWidth("300px");
	multiUploader.setHeight("60px");
	multiUploader.setFileInputPrefix("LDOC");
	multiUploader.setMaximumFiles(1);
	multiUploader.addOnFinishUploadHandler(onFinishUploaderHandler);
	multiUploader.reset();

	saveButton = new IButton(I18N.message("save"));
	saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {

		@Override
		public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
			onSave();
		}
	});
	saveButton.setDisabled(true);

	VLayout layout = new VLayout();
	layout.setMembersMargin(5);
	layout.setMargin(2);

	layout.addMember(form);
	layout.addMember(multiUploader);
	layout.addMember(saveButton);

	addItem(layout);
}
 
Example 11
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 12
Source File: RetentionPolicyDetailsPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void refresh() {

		/*
		 * Prepare the standard properties tab
		 */
		if (tabSet != null) {
			tabSet.hideSave();
			removeMember(tabSet);
		}

		tabSet = new EditingTabSet(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				onSave();
			}
		}, new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				if (policy.getId() != 0) {
					RetentionPoliciesService.Instance.get().getPolicy(policy.getId(),
							new AsyncCallback<GUIRetentionPolicy>() {
								@Override
								public void onFailure(Throwable caught) {
									Log.serverError(caught);
								}

								@Override
								public void onSuccess(GUIRetentionPolicy policy) {
									setPolicy(policy);
								}
							});
				} else {
					GUIRetentionPolicy newsPolicy = new GUIRetentionPolicy();
					setPolicy(newsPolicy);
				}
				tabSet.hideSave();
			}
		});

		Tab propertiesTab = new Tab(I18N.message("properties"));
		propertiesTabPanel = new HLayout();
		propertiesTabPanel.setWidth100();
		propertiesTabPanel.setHeight100();
		propertiesTab.setPane(propertiesTabPanel);
		tabSet.addTab(propertiesTab);

		addMember(tabSet);

		ChangedHandler changedHandler = new ChangedHandler() {
			@Override
			public void onChanged(ChangedEvent event) {
				onModified();
			}
		};

		form = new DynamicForm();
		form.setNumCols(2);
		form.setTitleOrientation(TitleOrientation.TOP);

		TextItem name = ItemFactory.newSimpleTextItem("name", "name", policy.getName());
		name.addChangedHandler(changedHandler);
		name.setWidth(200);
		name.setRequired(true);

		IntegerItem days = ItemFactory.newIntegerItem("days", "retentiondays", policy.getRetentionDays());
		days.addChangedHandler(changedHandler);
		days.setWidth(100);
		days.setRequired(true);

		SelectItem dateOption = ItemFactory.newRetentionDateOption(policy.getDateOption());
		dateOption.addChangedHandler(changedHandler);

		SelectItem template = ItemFactory.newTemplateSelector(true, policy.getTemplateId());
		template.addChangedHandler(changedHandler);

		folder = new FolderSelector(null, true);
		folder.setFolder(policy.getFolderId(), policy.getFolderName());
		folder.addFolderChangeListener(RetentionPolicyDetailsPanel.this);

		SelectItem action = ItemFactory.newRetentionAction(policy.getAction());
		action.addChangedHandler(changedHandler);

		form.setItems(name, days, dateOption, template, action, folder);

		propertiesTab.setPane(form);
	}
 
Example 13
Source File: TemplatePropertiesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void prepareTemplateForm() {
	templateForm = new DynamicForm();
	templateForm.setNumCols(1);
	templateForm.setValuesManager(vm);
	templateForm.setTitleOrientation(TitleOrientation.LEFT);

	StaticTextItem id = ItemFactory.newStaticTextItem("id", "id", Long.toString(template.getId()));
	id.setDisabled(true);

	TextItem name = ItemFactory.newSimpleTextItem("name", I18N.message("name"), template.getName());
	name.setRequired(true);
	name.setDisabled(template.isReadonly());
	if (!template.isReadonly())
		name.addChangedHandler(changedHandler);

	TextAreaItem description = ItemFactory.newTextAreaItem("description", "description", template.getDescription());
	description.setDisabled(template.isReadonly());

	PickerIcon computeStat = new PickerIcon(PickerIconName.REFRESH, new FormItemClickHandler() {
		public void onFormItemClick(final FormItemIconClickEvent event) {
			event.getItem().setValue(I18N.message("computing") + "...");
			TemplateService.Instance.get().countDocuments(template.getId(), new AsyncCallback<Long>() {

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

				@Override
				public void onSuccess(Long count) {
					event.getItem().setValue(Util.formatLong(count));
				}
			});
		}
	});
	computeStat.setPrompt(I18N.message("calculatestats"));

	StaticTextItem docs = ItemFactory.newStaticTextItem("docs", "documents", "-");
	docs.setIconHSpace(2);
	docs.setIconWidth(16);
	docs.setIconHeight(16);
	docs.setIcons(computeStat);
	docs.setWidth("1%");

	if (!template.isReadonly())
		description.addChangedHandler(changedHandler);

	templateForm.setItems(id, name, description, docs);

	container.addMember(templateForm);
}
 
Example 14
Source File: PeriodicalIssueForm.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
public PeriodicalIssueForm(ClientMessages i18n) {
    setWidth100();
    setHeight100();
    setTitleOrientation(TitleOrientation.TOP);
    setNumCols(1);

    ComboBoxItem issueSequenceNumber = new ComboBoxItem(ModsCustomDataSource.FIELD_PER_ISSUE_NUMBER_SORTING,
            i18n.PeriodicalIssueForm_NumberSorting_Title());
    issueSequenceNumber.setRequired(true);
    issueSequenceNumber.setValidators(new StringTrimValidator(), new RegExpValidator(
            "^([1-9]\\d{0,4}(-[1-9]\\d{0,4})?|mimořádné|zvláštní|na ukázku)$"));
    issueSequenceNumber.setValueMap("mimořádné", "na ukázku", "zvláštní");
    issueSequenceNumber.setHideEmptyPickList(true);

    TextItem date = new TextItem(ModsCustomDataSource.FIELD_PER_ISSUE_DATE, i18n.PeriodicalIssueForm_Date_Title());
    date.setRequired(true);
    // issue 43, see https://docs.google.com/document/d/1zSriHPdnUY5d_tKv0M8a6nEym560DKh2H6XZ24tGAEw/edit?pli=1
    // YYYY|YYYY-YYYY|MM.YYYY|MM.-MM.YYYY|DD.MM.YYYY|DD.-DD.MM.YYYY
    // javascript regex ^([1-9]\d{3}(-[1-9]\d{3})?|(1\d|[1-9])\.(-(1\d|[1-9])\.)?[1-9]\d{3}|([123]\d|[1-9])\.(1\d|[1-9])\.(-([123]\d|[1-9])\.(1\d|[1-9])\.)?[1-9]\d{3})$
    date.setValidators(new StringTrimValidator(), new RegExpValidator(
            "^([1-9]\\d{3}(-[1-9]\\d{3})?|(1\\d|[1-9])\\.(-(1\\d|[1-9])\\.)?[1-9]\\d{3}|([123]\\d|[1-9])\\.(1\\d|[1-9])\\.(-([123]\\d|[1-9])\\.(1\\d|[1-9])\\.)?[1-9]\\d{3})$"));

    // identifiers
    final RepeatableFormItem identifiers = new RepeatableFormItem(ModsCustomDataSource.FIELD_IDENTIFIERS,
            i18n.PeriodicalIssueForm_Identifiers_Title());
    identifiers.setDataSource(IdentifierDataSource.getInstance());
    identifiers.setValidators(
            new IdentifiersValidator(i18n, Arrays.asList(IdentifierDataSource.TYPE_UUID)));
    DynamicForm identifierForm = new DynamicForm();
    identifierForm.setUseAllDataSourceFields(true);
    identifierForm.setNumCols(4);
    identifiers.setFormPrototype(identifierForm);
    identifiers.setEndRow(true);
    identifiers.setColSpan("2");

    TextAreaItem note = new TextAreaItem(ModsCustomDataSource.FIELD_NOTE, i18n.PeriodicalIssueForm_Note_Title());
    note.setWidth("*");
    note.setHeight("*");
    note.setColSpan("*");

    setFields(issueSequenceNumber, date, identifiers, note);
}
 
Example 15
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 16
Source File: PageForm.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
/**
     * Create a new form.
     * @param i18n I18N
     * @param typeValueMapId {@link ValueMapDataSource#getOptionDataSource}
     *          reference to bundle with page types.
     */
    public PageForm(ClientMessages i18n, String typeValueMapId) {
        // save on Enter is supposed mainly for ImportBatchItemEditor
        // see submit handler in ModsMultiEditor
        setSaveOnEnter(true);
        setWidth100();
        setHeight100();
        setTitleOrientation(TitleOrientation.TOP);
        SelectItem pageType = new SelectItem(ModsCustomDataSource.FIELD_PAGE_TYPE, i18n.PageForm_PageType_Title());
        pageType.setOptionDataSource(ValueMapDataSource.getInstance().getOptionDataSource(typeValueMapId));
        pageType.setValueField(BundleValue.KEY);
        pageType.setDisplayField(BundleValue.VALUE);
        pageType.setDefaultValue(ModsCustomDataSource.getDefaultPageType());
        pageType.setWidth(200);
        pageType.setEndRow(true);

        IntegerItem pageIndex = new IntegerItem(ModsCustomDataSource.FIELD_PAGE_INDEX);
        pageIndex.setTitle(i18n.PageForm_PageIndex_Title());
        pageIndex.setValidators(new IsIntegerValidator());
        pageIndex.setRequired(true);
        pageIndex.setEndRow(true);

        TextItem pageNumber = new TextItem(ModsCustomDataSource.FIELD_PAGE_NUMBER);
        pageNumber.setTitle(i18n.PageForm_PageNumber_Title());
        pageNumber.setEndRow(true);
        pageNumber.setRequired(true);
        pageNumber.setValidators(new StringTrimValidator());
//        pageNumber.setLength(5);

        final RepeatableFormItem identifiers = new RepeatableFormItem(ModsCustomDataSource.FIELD_IDENTIFIERS,
                i18n.PageForm_Identifiers_Title());
        identifiers.setDataSource(IdentifierDataSource.getInstance());
        identifiers.setRequired(true);
        identifiers.setValidators(
                new IdentifiersValidator(i18n, Arrays.asList(IdentifierDataSource.TYPE_UUID)));
        DynamicForm identifierForm = new DynamicForm();
        identifierForm.setUseAllDataSourceFields(true);
        identifierForm.setNumCols(4);
        identifiers.setFormPrototype(identifierForm);
        identifiers.setEndRow(true);
        identifiers.setColSpan("3");

//        TextAreaItem note = new AutoFitTextAreaItem(ModsCustomDataSource.FIELD_NOTE, "Note");
        TextAreaItem note = new TextAreaItem(ModsCustomDataSource.FIELD_NOTE, i18n.PageForm_Note_Title());
        note.setWidth("*");
        //https://github.com/proarc/proarc/issues/645 GWT v.6.0-p20161023 form draw issue
        note.setHeight("*");
        note.setColSpan("*");

        setFields(pageType, pageIndex, pageNumber, identifiers, note);

        IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
        integerRangeValidator.setMin(0);
        integerRangeValidator.setMax(Integer.MAX_VALUE);

        pageIndex.setValidators(integerRangeValidator);
    }
 
Example 17
Source File: ContactDetails.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ContactDetails(final GUIContact contact, final Contacts parent) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("contact"));
	setWidth(500);
	setAutoHeight();
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setMargin(5);
	form.setNumCols(3);
	form.setTitleOrientation(TitleOrientation.TOP);

	TextItem firstName = ItemFactory.newTextItem("firstname", "firstname", contact.getFirstName());
	TextItem lastName = ItemFactory.newTextItem("lastname", "lastname", contact.getLastName());
	TextItem email = ItemFactory.newEmailItem("email", "email", false);
	email.setRequired(true);
	email.setValue(contact.getEmail());
	TextItem address = ItemFactory.newTextItem("address", "address", contact.getAddress());
	TextItem phone = ItemFactory.newTextItem("phone", "phone", contact.getPhone());
	TextItem cell = ItemFactory.newTextItem("cell", "cell", contact.getMobile());
	TextItem company = ItemFactory.newTextItem("company", "company", contact.getCompany());
	company.setWidth(180);

	ButtonItem save = new ButtonItem();
	save.setTitle(I18N.message("save"));
	save.setAutoFit(true);
	save.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {

				GUIContact c = new GUIContact();
				c.setId(contact.getId());
				c.setUserId(Session.get().getUser().getId());
				c.setFirstName(vm.getValueAsString("firstname"));
				c.setLastName(vm.getValueAsString("lastname"));
				c.setEmail(vm.getValueAsString("email"));
				c.setAddress(vm.getValueAsString("address"));
				c.setPhone(vm.getValueAsString("phone"));
				c.setMobile(vm.getValueAsString("cell"));
				c.setCompany(vm.getValueAsString("company"));

				ContactService.Instance.get().save(c, new AsyncCallback<Void>() {
					@Override
					public void onFailure(Throwable caught) {
						SC.warn(caught.getMessage());
					}

					@Override
					public void onSuccess(Void ret) {
						ContactDetails.this.destroy();
						if (parent != null)
							parent.refresh();
					}
				});
			}
		}
	});

	form.setFields(email, firstName, lastName, company, address, phone, cell, save);

	addItem(form);
}
 
Example 18
Source File: NdkAudioPageForm.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
/**
     * Create a new form.
     * @param i18n I18N
     * @param typeValueMapId {@link ValueMapDataSource#getOptionDataSource}
     *          reference to bundle with page types.
     */
    public NdkAudioPageForm(ClientMessages i18n, String typeValueMapId) {
        // save on Enter is supposed mainly for ImportBatchItemEditor
        // see submit handler in ModsMultiEditor
        setSaveOnEnter(true);
        setWidth100();
        setHeight100();
        setTitleOrientation(TitleOrientation.TOP);

        TextItem pageType = new TextItem(ModsCustomDataSource.FIELD_PAGE_TYPE);
        pageType.setTitle(i18n.PageForm_PageType_Title());
        pageType.setEndRow(true);
        pageType.setRequired(true);
        pageType.setReadOnly();
        pageType.disable();

        IntegerItem pageIndex = new IntegerItem(ModsCustomDataSource.FIELD_PAGE_INDEX);
        pageIndex.setTitle(i18n.PageForm_PageIndex_Title());
        pageIndex.setValidators(new IsIntegerValidator());
        pageIndex.setRequired(true);
        pageIndex.setEndRow(true);

        TextItem pageNumber = new TextItem(ModsCustomDataSource.FIELD_PAGE_NUMBER);
        pageNumber.setTitle(i18n.PageForm_PageNumber_Title());
        pageNumber.setEndRow(true);
        pageNumber.setRequired(true);
        pageNumber.setValidators(new StringTrimValidator());
//        pageNumber.setLength(5);

        final RepeatableFormItem identifiers = new RepeatableFormItem(ModsCustomDataSource.FIELD_IDENTIFIERS,
                i18n.PageForm_Identifiers_Title());
        identifiers.setDataSource(IdentifierDataSource.getInstance());
        identifiers.setRequired(true);
        identifiers.setValidators(
                new IdentifiersValidator(i18n, Arrays.asList(IdentifierDataSource.TYPE_UUID)));
        DynamicForm identifierForm = new DynamicForm();
        identifierForm.setUseAllDataSourceFields(true);
        identifierForm.setNumCols(4);
        identifiers.setFormPrototype(identifierForm);
        identifiers.setEndRow(true);
        identifiers.setColSpan("3");

//        TextAreaItem note = new AutoFitTextAreaItem(ModsCustomDataSource.FIELD_NOTE, "Note");
        TextAreaItem note = new TextAreaItem(ModsCustomDataSource.FIELD_NOTE, i18n.PageForm_Note_Title());
        note.setWidth("*");
        //https://github.com/proarc/proarc/issues/645 GWT v.6.0-p20161023 form draw issue
        note.setHeight("*");
        note.setColSpan("*");

        setFields(pageType, pageIndex, pageNumber, identifiers, note);

        IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
        integerRangeValidator.setMin(0);
        integerRangeValidator.setMax(Integer.MAX_VALUE);

        pageIndex.setValidators(integerRangeValidator);
    }
 
Example 19
Source File: GDriveCreate.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public GDriveCreate() {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("createdoc"));
	setWidth(300);
	setHeight(120);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setPadding(5);
	setMembersMargin(3);

	DynamicForm form = new DynamicForm();
	vm = new ValuesManager();
	form.setValuesManager(vm);
	form.setTitleOrientation(TitleOrientation.TOP);

	TextItem fileName = ItemFactory.newTextItem("fileName", "filename", null);
	fileName.setRequired(true);
	fileName.setWidth(200);

	SelectItem type = ItemFactory.newSelectItem("type", I18N.message("type"));
	LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
	map.put("doc", "doc");
	map.put("docx", "docx");
	map.put("odt", "odt");
	map.put("txt", "txt");
	map.put("xls", "xls");
	map.put("xlsx", "xlsx");
	map.put("ods", "ods");
	map.put("ppt", "ppt");
	map.put("pptx", "pptx");
	map.put("odp", "odp");
	type.setValueMap(map);
	type.setValue("doc");
	type.setWidth(50);
	type.setEndRow(true);
	type.setRequired(true);

	create = new SubmitItem();
	create.setTitle(I18N.message("create"));
	create.setAlign(Alignment.RIGHT);
	create.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onCreate();
		}
	});

	form.setItems(fileName, type, create);

	addItem(form);
}
 
Example 20
Source File: SaveDialog.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SaveDialog() {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("savesearch"));
	setWidth(350);
	setHeight(100);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setPadding(5);
	setAutoSize(true);

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

	TextItem name = ItemFactory.newTextItem("name", "name", null);
	name.setRequired(true);
	name.setValidators(new SimpleTextValidator());
	name.setWidth(100);

	TextItem description = ItemFactory.newTextItem("description", "description", null);
	description.setWidth(300);

	ButtonItem save = new ButtonItem();
	save.setTitle(I18N.message("save"));
	save.setAutoFit(true);
	save.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				final GUISearchOptions options = Search.get().getOptions();
				options.setName(vm.getValueAsString("name"));
				options.setDescription(vm.getValueAsString("description"));
				SearchService.Instance.get().save(Search.get().getOptions(), new AsyncCallback<Boolean>() {

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

					@Override
					public void onSuccess(Boolean b) {
						if (!b)
							SC.warn(I18N.message("duplicateelement"));
						else {
							SavedSearchesPanel.get().addEntry(
									vm.getValueAsString("name"),
									vm.getValueAsString("description"),
									options.getType() == GUISearchOptions.TYPE_FULLTEXT ? I18N.message("fulltext")
											: I18N.message("parametric"));
							destroy();
						}
					}
				});
			}
		}
	});

	form.setFields(name, description, save);
	addItem(form);
}