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

The following examples show how to use com.smartgwt.client.widgets.form.fields.SelectItem#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: UrnNbnAction.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private DynamicForm createOptionResolver() {
    DynamicForm form = new DynamicForm();
    SelectItem selection = new SelectItem(UrnNbnResourceApi.FIND_RESOLVER_PARAM,
            i18n.UrnNbnAction_Window_Select_Title());
    selection.setRequired(true);
    selection.setOptionDataSource(UrnNbnResolverDataSource.getInstance());
    selection.setValueField(UrnNbnResourceApi.RESOLVER_ID);
    selection.setDisplayField(UrnNbnResourceApi.RESOLVER_NAME);
    selection.setAutoFetchData(true);
    selection.setDefaultToFirstOption(true);
    selection.setWidth(350);
    selection.setAutoFetchData(true);
    form.setFields(selection);
    form.setBrowserSpellCheck(false);
    form.setWrapItemTitles(false);
    form.setTitleOrientation(TitleOrientation.TOP);
    return form;
}
 
Example 2
Source File: NewIssueEditor.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private SelectItem createDayChooser(String fName) {
        SelectItem issueDays = new SelectItem(fName, i18n.NewIssueEditor_daysIncluded_Title());
        issueDays.setTooltip(i18n.NewIssueEditor_daysIncluded_Hint());
        issueDays.setWidth("*");
        issueDays.setHeight(105);
//        issueDays.setMultiple(true);
        issueDays.setRequired(true);
        issueDays.setMultipleAppearance(MultipleAppearance.GRID);
        LinkedHashMap<Integer, String> weekMap = new LinkedHashMap<>();
        weekMap.put(1, i18nSGwt.date_dayNames_2());
        weekMap.put(2, i18nSGwt.date_dayNames_3());
        weekMap.put(3, i18nSGwt.date_dayNames_4());
        weekMap.put(4, i18nSGwt.date_dayNames_5());
        weekMap.put(5, i18nSGwt.date_dayNames_6());
        weekMap.put(6, i18nSGwt.date_dayNames_7());
        weekMap.put(7, i18nSGwt.date_dayNames_1());
        issueDays.setValueMap(weekMap);
        return issueDays;
    }
 
Example 3
Source File: Setup.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Prepares the registration form
 */
private Tab setupRegistration(final ValuesManager vm) {
	Tab registrationTab = new Tab();
	registrationTab.setTitle(I18N.message("registration"));

	TextItem regName = ItemFactory.newTextItem(REG_NAME, "name", null);
	regName.setWrapTitle(false);
	regName.setWidth(300);

	TextItem regOrganization = ItemFactory.newTextItem(REG_ORGANIZATION, "organization", null);
	regOrganization.setWrapTitle(false);
	regOrganization.setWidth(300);

	TextItem regWebsite = ItemFactory.newTextItem(REG_WEBSITE, "website", null);
	regWebsite.setWrapTitle(false);
	regWebsite.setWidth(300);

	TextItem regEmail = ItemFactory.newEmailItem(REG_EMAIL, "email", false);
	regEmail.setWrapTitle(false);
	regEmail.setWidth(300);

	SelectItem languageItem = ItemFactory.newLanguageSelector(LANGUAGE, false, true);
	languageItem.setTitle(I18N.message("language"));
	languageItem.setRequired(true);

	final DynamicForm regForm = new DynamicForm();
	regForm.setID("regForm");
	regForm.setValuesManager(vm);
	regForm.setFields(languageItem, regName, regEmail, regOrganization, regWebsite);

	registrationTab.setPane(regForm);
	return registrationTab;
}
 
Example 4
Source File: SendToArchiveDialog.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructor
 * 
 * @param ids Identifiers of the elements that have to be archived
 * @param document True if the ids refers to documents, False in case of
 *        folders
 */
public SendToArchiveDialog(final long[] ids, final boolean document) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);

	setTitle(I18N.message("sendtoexparchive"));
	setWidth(380);
	setHeight(100);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();

	SelectItem archive = ItemFactory.newArchiveSelector(GUIArchive.MODE_EXPORT, GUIArchive.STATUS_OPENED);
	archive.setTitle(I18N.message("selectopenarchive"));
	archive.setWrapTitle(false);
	archive.setRequired(true);

	ButtonItem send = new ButtonItem();
	send.setStartRow(false);
	send.setTitle(I18N.message("sendtoexparchive"));
	send.setAutoFit(true);
	send.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onSend(ids, document);
		}
	});

	form.setFields(archive, send);
	addItem(form);
}
 
Example 5
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static SelectItem newRecipientTypeSelector(String name) {
	SelectItem selector = new SelectItem();
	LinkedHashMap<String, String> opts = new LinkedHashMap<String, String>();
	opts.put("to", I18N.message("to").toUpperCase());
	opts.put("cc", I18N.message("cc").toUpperCase());
	opts.put("bcc", I18N.message("bcc").toUpperCase());
	selector.setValueMap(opts);
	selector.setName(filterItemName(name));
	selector.setShowTitle(false);
	selector.setValue("to");
	selector.setRequired(true);
	return selector;
}
 
Example 6
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static SelectItem newUserTypeSelector(String name, int userType) {
	SelectItem selector = new SelectItem();
	LinkedHashMap<String, String> opts = new LinkedHashMap<String, String>();
	opts.put("" + GUIUser.TYPE_DEFAULT, I18N.message("default"));
	opts.put("" + GUIUser.TYPE_READONLY, I18N.message("readonly"));
	selector.setValueMap(opts);
	selector.setName(filterItemName(name));
	selector.setTitle(I18N.message("usertype"));
	selector.setValue("" + userType);
	selector.setRequired(true);
	selector.setWidth(120);
	return selector;
}
 
Example 7
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static SelectItem newDashletTypeSelector(String value) {
	SelectItem selector = new SelectItem();
	LinkedHashMap<String, String> opts = new LinkedHashMap<String, String>();
	opts.put("document", I18N.message("dashlet.type.document"));
	opts.put("docevent", I18N.message("dashlet.type.docevent"));
	opts.put("note", I18N.message("dashlet.type.note"));
	opts.put("content", I18N.message("dashlet.type.content"));
	selector.setValueMap(opts);
	selector.setName("type");
	selector.setTitle(I18N.message("type"));
	selector.setValue(value);
	selector.setRequired(true);
	selector.setWidth(120);
	return selector;
}
 
Example 8
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static SelectItem newRunlevelSelector() {
	SelectItem item = new SelectItem("runlevel", I18N.message("currentrunlevel"));
	LinkedHashMap<String, String> opts = new LinkedHashMap<String, String>();
	opts.put("default", I18N.message("default"));
	opts.put("bulkload", I18N.message("bulkload"));
	opts.put("slave", I18N.message("slave"));
	opts.put("devel", I18N.message("devel"));
	item.setValueMap(opts);
	item.setWrapTitle(false);
	item.setValue(Session.get().getConfig("runlevel"));
	item.setRequired(true);
	item.setWidth(150);
	item.setDisabled("demo".equals(Session.get().getConfig("runlevel")));
	return item;
}
 
Example 9
Source File: NewDigObject.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private DynamicForm createOptionsForm() {
        SelectItem selectModel = new SelectItem(DigitalObjectDataSource.FIELD_MODEL,
                i18n.NewDigObject_OptionModel_Title());
        selectModel.setRequired(true);
        selectModel.setWidth(300);
        // issue 46: always start with empty model
        selectModel.setAllowEmptyValue(true);
        selectModel.setEmptyDisplayValue(ClientUtils.format("<i>&lt;%s&gt;</i>", i18n.NewDigObject_OptionModel_EmptyValue_Title()));
        selectModel.setOptionDataSource(MetaModelDataSource.getInstance());
//        selectModel.setShowOptionsFromDataSource(true);
        selectModel.setValueField(MetaModelDataSource.FIELD_PID);
        selectModel.setDisplayField(MetaModelDataSource.FIELD_DISPLAY_NAME);
        selectModel.setAutoFetchData(true);
        selectModel.setValidators(new CustomValidator() {

            @Override
            protected boolean condition(Object value) {
                boolean valid = getFormItem().getSelectedRecord() != null;
                return valid;
            }
        });

        TextItem newPid = new TextItem(DigitalObjectDataSource.FIELD_PID);
        newPid.setTitle(i18n.NewDigObject_OptionPid_Title());
        newPid.setTooltip(i18n.NewDigObject_OptionPid_Hint());
        newPid.setLength(36 + 5);
        newPid.setWidth((36 + 5) * 8);
        newPid.setValidators(new CustomUUIDValidator(i18n));
        //newPid.setValidators(new RegExpValidator(
        //        "uuid:[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}"));
        DynamicForm form = new DynamicForm();
        form.setWrapItemTitles(false);
        form.setAutoFocus(true);
        form.setNumCols(4);
        form.setBrowserSpellCheck(false);
        form.setFields(selectModel, newPid);
        form.setAutoWidth();
        form.setMargin(4);
        return form;
    }
 
Example 10
Source File: ImportSourceChooser.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private SelectItem createScannerSelection() {
    final SelectItem selectScanner = new SelectItem(ImportBatchDataSource.FIELD_DEVICE,
            i18n.ImportSourceChooser_OptionScanner_Title());
    DeviceDataSource.setOptionDataSource(selectScanner);
    selectScanner.setAllowEmptyValue(true);
    selectScanner.setEmptyDisplayValue(
            ClientUtils.format("<i>&lt;%s&gt;</i>", i18n.NewDigObject_OptionModel_EmptyValue_Title()));
    selectScanner.setRequired(true);
    selectScanner.setWidth(300);
    selectScanner.addDataArrivedHandler(new DataArrivedHandler() {

        @Override
        public void onDataArrived(DataArrivedEvent event) {
            if (event.getStartRow() == 0) {
                ResultSet data = event.getData();
                int length = data.getLength();
                if (length == 1) {
                    // issue 190: select in case of single device
                    Record device = data.get(0);
                    String deviceId = device.getAttribute(DeviceDataSource.FIELD_ID);
                    selectScanner.setValue(deviceId);
                    selectScanner.setDefaultValue(deviceId);
                }
            }
        }
    });
    return selectScanner;
}
 
Example 11
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 12
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);
				}
			});
}
 
Example 13
Source File: WorkflowNewJobView.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private SelectItem createProfileSelector() {
    final SelectItem profile = new SelectItem(WorkflowResourceApi.NEWJOB_PROFILE, i18n.WorkflowJob_NewJobView_Field_Profile_Title());
    profile.setOptionDataSource(WorkflowProfileDataSource.getInstance());
    profile.setValueField(WorkflowProfileDataSource.FIELD_ID);
    profile.setDisplayField(WorkflowProfileDataSource.FIELD_LABEL);
    profile.setOptionCriteria(new Criteria(WorkflowProfileDataSource.FIELD_DISABLED, Boolean.FALSE.toString()));
    profile.setFilterLocally(true);
    profile.setRequired(true);
    profile.setWidth(300);
    profile.setAllowEmptyValue(true);
    ListGrid profilePickListProperties = new ListGrid();
    profilePickListProperties.setCanHover(true);
    profilePickListProperties.setShowHover(true);
    profilePickListProperties.setHoverWidth(300);
    profilePickListProperties.setHoverCustomizer(new HoverCustomizer() {

        @Override
        public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
            String hint = record.getAttribute(WorkflowProfileDataSource.FIELD_HINT);
            return hint;
        }
    });
    profile.setPickListProperties(profilePickListProperties);
    profile.addDataArrivedHandler(new DataArrivedHandler() {

        @Override
        public void onDataArrived(DataArrivedEvent event) {
            if (event.getStartRow() == 0) {
                ResultSet data = event.getData();
                int length = data.getLength();
                if (length == 1) {
                    Record r = data.get(0);
                    String profileId = r.getAttribute(WorkflowProfileDataSource.FIELD_ID);
                    profile.setValue(profileId);
                    profile.setDefaultValue(profileId);

                    fetchModelMenu(r); // fill up model menu on init
                }
            }
        }
    });
    return profile;
}