Java Code Examples for com.smartgwt.client.widgets.form.fields.ComboBoxItem#setValueMap()

The following examples show how to use com.smartgwt.client.widgets.form.fields.ComboBoxItem#setValueMap() . 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: FormGenerator.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public ComboBoxItem getComboBoxItem(Field f, String lang) {
    ComboBoxItem item = new ComboBoxItem(f.getName(), f.getTitle(lang));
    if (f.getOptionDataSource() != null) {
        setOptionDataSource(item, f, lang);
    } else {
        item.setValueMap(f.getValueMap());
    }
    item.setDefaultValue(f.getDefaultValue());
    return item;
}
 
Example 2
Source File: PageMetadataEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private void createApplyToUi() {
    formApply = createForm();

    applyTo = new ComboBoxItem("applyTo", i18n.PageMetadataEditor_ApplyTo_Title());
    applyTo.setPrompt(i18n.PageMetadataEditor_ApplyTo_Hint());
    applyTo.setRequired(true);

    LinkedHashMap<String, String> vals = new LinkedHashMap<String, String>();
    vals.put("1", i18n.PageMetadataEditor_ApplyToEachItem_Title());
    for (int i = 2; i <= 20; i++) {
        String nth = String.valueOf(i);
        vals.put(nth, i18n.PageMetadataEditor_ApplyToEachNthItem_Title(nth));
    }
    applyTo.setValueMap(vals);
    applyTo.setDefaultValue(1);
    applyTo.setValue(1);

    applyToValidator = new IntegerRangeValidator();
    applyToValidator.setMin(1);
    applyToValidator.setMax(applyToMaxValue);
    applyTo.setValidators(new IsIntegerValidator(), applyToValidator);

    applyFromFirst = new CheckboxItem("applyFromFirst", i18n.PageMetadataEditor_ApplyFromFirst_Title());
    applyFromFirst.setPrompt(i18n.PageMetadataEditor_ApplyFromFirst_Hint());

    formApply.setItems(applyTo, applyFromFirst);

    applyTo.addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {
            applyFromFirst.setDisabled("1".equals(applyTo.getValueAsString()));
        }
    });
}
 
Example 3
Source File: DigitalObjectAdministrationEditor.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
public PlainEditor(ClientMessages i18n) {
    widget = new VLayout();
    form = new DynamicForm();
    form.setDataSource(DigitalObjectAdministrationDataSource.getInstance());
    form.setBrowserSpellCheck(false);

    TextItem pid = new TextItem(DigitalObjectAdministrationDataSource.FIELD_PID,
            i18n.DigitalObjectEditor_AdministrationEditor_Pid_Title());
    pid.setWidth("*");
    pid.setCanEdit(Boolean.FALSE);
    TextItem model = new TextItem(DigitalObjectAdministrationDataSource.FIELD_MODEL,
            i18n.DigitalObjectEditor_AdministrationEditor_Model_Title());
    model.setCanEdit(Boolean.FALSE);
    TextItem owner = new TextItem(DigitalObjectAdministrationDataSource.FIELD_OWNER,
            i18n.DigitalObjectEditor_AdministrationEditor_Owner_Title());
    owner.setCanEdit(Boolean.FALSE);
    TextItem creationDate = new TextItem(DigitalObjectAdministrationDataSource.FIELD_CREATED,
            i18n.DigitalObjectEditor_AdministrationEditor_Created_Title());
    creationDate.setCanEdit(Boolean.FALSE);
    TextItem modificationDate = new TextItem(DigitalObjectAdministrationDataSource.FIELD_MODIFIED,
            i18n.DigitalObjectEditor_AdministrationEditor_Modified_Title());
    modificationDate.setCanEdit(Boolean.FALSE);

    SelectItem device = new SelectItem(DigitalObjectAdministrationDataSource.FIELD_DEVICE,
            i18n.DigitalObjectEditor_AdministrationEditor_Device_Title());
    device.setWidth(250);
    DeviceDataSource.setOptionDataSource(device);
    device.setAllowEmptyValue(true);
    device.setEmptyDisplayValue(ClientUtils.format("<i>&lt;%s&gt;</i>",
            i18n.DigitalObjectEditor_AdministrationEditor_NoDeviceSelection_Title()));

    TextItem filename = new TextItem(DigitalObjectAdministrationDataSource.FIELD_FILENAME,
            i18n.DigitalObjectEditor_AdministrationEditor_File_Title());
    filename.setWidth("*");
    filename.setCanEdit(Boolean.FALSE);

    TextItem export = new TextItem(DigitalObjectAdministrationDataSource.FIELD_EXPORT,
            i18n.DigitalObjectEditor_AdministrationEditor_Export_Title());
    export.setWidth("*");
    export.setCanEdit(Boolean.FALSE);

    TextItem ndkExport = new TextItem(DigitalObjectAdministrationDataSource.FIELD_NDK_EXPORT,
            i18n.DigitalObjectEditor_AdministrationEditor_Ndk_Export_Title());
    ndkExport.setWidth("*");
    ndkExport.setCanEdit(Boolean.FALSE);

    TextItem archiveExport = new TextItem(DigitalObjectAdministrationDataSource.FIELD_ARCHIVE_EXPORT,
            i18n.DigitalObjectEditor_AdministrationEditor_Archive_Export_Title());
    archiveExport.setWidth("*");
    archiveExport.setCanEdit(Boolean.FALSE);

    TextItem krameriusExport = new TextItem(DigitalObjectAdministrationDataSource.FIELD_KRAMERIUS_EXPORT,
            i18n.DigitalObjectEditor_AdministrationEditor_Kramerius_Export_Title());
    krameriusExport.setWidth("*");
    krameriusExport.setCanEdit(Boolean.FALSE);

    TextItem crossrefExport = new TextItem(DigitalObjectAdministrationDataSource.FIELD_CROSSREF_EXPORT,
            i18n.DigitalObjectEditor_AdministrationEditor_Crossref_Export_Title());
    crossrefExport.setWidth("*");
    crossrefExport.setCanEdit(Boolean.FALSE);

    ComboBoxItem organization = new ComboBoxItem(DigitalObjectAdministrationDataSource.FIELD_ORGANIZATION,
            i18n.UsersView_ListHeader_Organization_Title());
    organization.setWidth(250);
    organization.setValueMap(Organization.getMap());

    ComboBoxItem user = new ComboBoxItem(DigitalObjectAdministrationDataSource.FIELD_USER,
            i18n.UsersView_ListHeader_Proccesor_Title());
    user.setWidth(250);
    user.setOptionDataSource(UserDataSource.getInstance());
    user.setValueField(UserDataSource.FIELD_USERNAME);
    user.setDisplayField(UserDataSource.FIELD_USERNAME);

    ComboBoxItem status = new ComboBoxItem(DigitalObjectAdministrationDataSource.FIELD_STATUS,
            i18n.DigitalObjectEditor_AdministrationEditor_Status_Title());
    status.setWidth(250);
    status.setValueMap(DigitalObjectState.getMap(i18n));

    form.setItems(pid, model, owner, creationDate, modificationDate, device, filename, export,  ndkExport, krameriusExport, archiveExport, crossrefExport, organization, user, status);
    widget.setMembers(form);
}
 
Example 4
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 5
Source File: DataControlsTimeSeries.java    From SensorWebClient with GNU General Public License v2.0 4 votes vote down vote up
private Canvas createJumpToTimeIntervalForm() {
   	ComboBoxItem jumpToCombo = new ComboBoxItem();
       jumpToCombo.setTitle(i18n.jumpTo());
   	jumpToCombo.setDefaultToFirstOption(true);
       jumpToCombo.setWrapTitle(false);
       jumpToCombo.setShowTitle(true);
       jumpToCombo.setWidth(100);

       String[] jumpToTypes = i18n.jumpToTypes().split(",");
       LinkedHashMap<String, String> jumpToValues = new LinkedHashMap<String, String>();
       for (int i = 0; i < jumpToTypes.length; i += 2) {
           jumpToValues.put(jumpToTypes[i], jumpToTypes[i + 1]);
       }
       jumpToCombo.setValueMap(jumpToValues);
       jumpToCombo.addChangedHandler(new ChangedHandler() {
           public void onChanged(ChangedEvent event) {
               RecentTimeTerm type = RecentTimeTerm.valueOf((String) event.getValue());
               final Date now = new Date();
               long interval = 1000 * 60;
               // FIXME validierung mit overview
               switch (type) {
               case TODAY:
				long dayInMillis = 1000 * 60 * 60 * 24;
               	long lastmidnight = now.getTime() / dayInMillis * dayInMillis;
               	EventBus.getMainEventBus().fireEvent(new DatesChangedEvent(lastmidnight, lastmidnight + (dayInMillis)));
				return;
               case LASTHOUR:
                   interval *= 60;
                   break;
               case LASTFIVEHOURS:
                   interval *= 60 * 5;
                   break;
               case LASTDAY:
                   interval *= 60 * 24;
                   break;
               case LASTMONTH:
                   interval *= 60 * 24 * 30;
                   break;
               case LASTWEEK:
                   interval *= 60 * 24 * 7;
                   break;
               default:
                   break;
               }
               final long start = now.getTime() - interval;
               final long end = now.getTime();

               EventBus.getMainEventBus().fireEvent(new DatesChangedEvent(start,end));
           }
       });
       
   	DynamicForm jumpToForm = new DynamicForm();
   	jumpToForm.setStyleName("n52_sensorweb_client_jumpToTimeIntervalForm");
       jumpToForm.setNumCols(2);
       jumpToForm.setFields(jumpToCombo);
       jumpToForm.setHeight("*");
       return jumpToForm;
}