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

The following examples show how to use com.smartgwt.client.widgets.form.fields.SelectItem#addDataArrivedHandler() . 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: 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 2
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;
}