Java Code Examples for com.smartgwt.client.widgets.form.DynamicForm#setFields()
The following examples show how to use
com.smartgwt.client.widgets.form.DynamicForm#setFields() .
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: CopyPageMetadataWidget.java From proarc with GNU General Public License v3.0 | 6 votes |
private DynamicForm createForm() { DynamicForm form = new DynamicForm(); form.setWrapItemTitles(false); // form.setAutoWidth(); form.setAutoHeight(); form.setBrowserSpellCheck(false); allowPageIndexes = new CheckboxItem("fillPageIndexes", i18n.PageMetadataEditor_CheckboxPageIndices_Title()); allowPageIndexes.setStartRow(true); allowPageIndexes.setColSpan("*"); allowPageIndexes.setShowTitle(false); allowPageNumbers = new CheckboxItem("fillPageNumbers", i18n.PageMetadataEditor_CheckboxPageNubers_Title()); allowPageNumbers.setStartRow(true); allowPageNumbers.setColSpan("*"); allowPageNumbers.setShowTitle(false); allowPageTypes = new CheckboxItem("fillPageTypes", i18n.PageMetadataEditor_CheckboxPageTypes_Title()); allowPageTypes.setStartRow(true); allowPageTypes.setColSpan("*"); allowPageTypes.setShowTitle(false); form.setFields(allowPageTypes, allowPageIndexes, allowPageNumbers); return form; }
Example 2
Source File: DigitalObjectPreview.java From proarc with GNU General Public License v3.0 | 6 votes |
/** * Gets widget to zoom image in the preview panel. * @return */ public Canvas getPreviewZoomer() { SelectItem zoomItem = createZoomForm(); zoomItem.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { onZoomChange(event); } }); DynamicForm form = new DynamicForm(); form.setValuesManager(zoomValues); form.setFields(zoomItem); form.setLayoutAlign(Alignment.CENTER); return form; }
Example 3
Source File: UploadFile.java From proarc with GNU General Public License v3.0 | 6 votes |
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 4
Source File: ExportAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private final DynamicForm createOptionsForm() { DynamicForm f = new DynamicForm(); f.setAutoHeight(); f.setLayoutAlign(Alignment.CENTER); f.setWidth(350); formItems = createExportFormOptions(); if (formItems == null || formItems.isEmpty()) { return null; } FormItem fields[] = new FormItem[formItems.size()]; for (int i = 0; i < formItems.size(); i++) { fields[i] = formItems.get(i); formItems.get(i); } f.setFields(fields); return f; }
Example 5
Source File: UrnNbnAction.java From proarc with GNU General Public License v3.0 | 6 votes |
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 6
Source File: DcEditor.java From proarc with GNU General Public License v3.0 | 6 votes |
private DynamicForm createFullForm() { DynamicForm f = new DynamicForm(); f.setWidth100(); f.setNumCols(2); f.setBrowserSpellCheck(false); f.setWrapItemTitles(false); f.setTitleOrientation(TitleOrientation.TOP); ArrayList<FormItem> items = new ArrayList<FormItem>(); addElement(items, DcConstants.CONTRIBUTOR, null, true); addElement(items, DcConstants.COVERAGE, null, true); addElement(items, DcConstants.CREATOR, null, true); addElement(items, DcConstants.DATE, null, true); addElement(items, DcConstants.DESCRIPTION, null, true); addElement(items, DcConstants.FORMAT, null, true); addElement(items, DcConstants.IDENTIFIER, null, true); addElement(items, DcConstants.LANGUAGE, null, true); addElement(items, DcConstants.PUBLISHER, null, true); addElement(items, DcConstants.RELATION, null, true); addElement(items, DcConstants.RIGHTS, null, true); addElement(items, DcConstants.SOURCE, null, true); addElement(items, DcConstants.SUBJECT, null, true); addElement(items, DcConstants.TITLE, null, true); addElement(items, DcConstants.TYPE, null, true); f.setFields(items.toArray(new FormItem[items.size()])); return f; }
Example 7
Source File: PersonFormFactory.java From proarc with GNU General Public License v3.0 | 5 votes |
@Override public DynamicForm create() { DynamicForm form = new DynamicForm(); form.setNumCols(4); TextItem family = new TextItem(ModsCustomDataSource.FIELD_NAME_FAMILY, i18n.PeriodicalForm_FamilyName_Title()); family.setPrompt(i18n.PeriodicalForm_FamilyName_Hint()); family.setValidators(new StringTrimValidator()); TextItem given = new TextItem(ModsCustomDataSource.FIELD_NAME_GIVEN, i18n.PeriodicalForm_GivenName_Title()); given.setPrompt(i18n.PeriodicalForm_GivenName_Hint()); given.setValidators(new StringTrimValidator()); form.setFields(family, given); return form; }
Example 8
Source File: DesaExportAction.java From proarc with GNU General Public License v3.0 | 5 votes |
public ExportOptionsWidget() { i18n = GWT.create(ClientMessages.class); label = new Label(); label.setMargin(5); label.setWidth100(); label.setAutoHeight(); label.setWrap(false); form = new DynamicForm(); CheckboxItem hierarchy = new CheckboxItem(ExportResourceApi.DESA_HIERARCHY_PARAM, i18n.ExportOptionsWidget_Hierarchy_Title()); hierarchy.setPrompt(i18n.ExportOptionsWidget_Hierarchy_Hint()); form.setFields(hierarchy); }
Example 9
Source File: CreateComplexRuleLayout.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
private HLayout createSingle(String ruleName){ this.singleCount++; DynamicForm block1 = new DynamicForm(); block1.setWidth("50%"); block1.setNumCols(1); DynamicForm block2 = new DynamicForm(); block2.setWidth("50%"); block2.setNumCols(1); SelectItem rule1Item = new SelectItem(); rule1Item.setShowTitle(false); rule1Item.setValueMap(this.rulesHashMap); rule1Item.setWidth(this.selectItemWidth); if (ruleName != null) { rule1Item.setValue(ruleName); } SpacerItem spacerItem = new SpacerItem(); spacerItem.setShowTitle(false); spacerItem.setHeight(20); block2.setFields(rule1Item); HLayout layout = new HLayout(); layout.setWidth(200); layout.setHeight(25); layout.addMember(block1); layout.addMember(block2); // save tree this.tempTree = this.rootTree; Tree right = new Tree(rule1Item, null, null); this.rootTree = new Tree(this.singleOperator, this.tempTree, right); return layout; }
Example 10
Source File: ChangePassword.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public ChangePassword() { super(); GUIUser user = Session.get().getUser(); setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("changepassword")); setWidth(300); setIsModal(true); setShowModalMask(true); centerInPage(); setAutoSize(true); final ValuesManager vm = new ValuesManager(); final DynamicForm form = new DynamicForm(); form.setValuesManager(vm); form.setWidth(350); form.setMargin(5); PasswordItem password = new PasswordItem(); password.setName(PASSWORD); password.setTitle(I18N.message(PASSWORD)); password.setRequired(true); MatchesFieldValidator equalsValidator = new MatchesFieldValidator(); equalsValidator.setOtherField(NEWPASSWORDAGAIN); equalsValidator.setErrorMessage(I18N.message("passwordnotmatch")); LengthRangeValidator sizeValidator = new LengthRangeValidator(); sizeValidator .setErrorMessage(I18N.message("errorfieldminlenght", Integer.toString(user.getPasswordMinLenght()))); sizeValidator.setMin(user.getPasswordMinLenght()); PasswordItem newPass = new PasswordItem(); newPass.setName(NEWPASSWORD); newPass.setTitle(I18N.message(NEWPASSWORD)); newPass.setRequired(true); newPass.setValidators(equalsValidator, sizeValidator); PasswordItem newPassAgain = new PasswordItem(); newPassAgain.setName(NEWPASSWORDAGAIN); newPassAgain.setTitle(I18N.message(NEWPASSWORDAGAIN)); newPassAgain.setWrapTitle(false); newPassAgain.setRequired(true); final ButtonItem apply = new ButtonItem(); apply.setTitle(I18N.message("apply")); apply.setAutoFit(true); apply.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { vm.validate(); if (!vm.hasErrors()) { if (vm.getValueAsString(PASSWORD).equals(vm.getValueAsString(NEWPASSWORD))) { Map<String, String> errors = new HashMap<String, String>(); errors.put(NEWPASSWORD, I18N.message("useanotherpassword")); vm.setErrors(errors, true); return; } apply.setDisabled(true); SecurityService.Instance.get().changePassword(user.getId(), user.getId(), vm.getValueAsString(PASSWORD), vm.getValueAsString(NEWPASSWORD), false, new AsyncCallback<Integer>() { @Override public void onFailure(Throwable caught) { apply.setDisabled(false); SC.warn(caught.getMessage()); } @Override public void onSuccess(Integer ret) { apply.setDisabled(false); if (ret.intValue() > 0) { // Alert the user and maintain the popup // opened if (ret == 1) SC.warn(I18N.message("wrongpassword")); else if (ret == 2) SC.warn(I18N.message("passwdnotnotified")); else SC.warn(I18N.message("genericerror")); } else { SC.say(I18N.message("yourpasswordhaschanged")); Log.info(I18N.message("event.user.passwordchanged"), null); } // Close the popup ChangePassword.this.destroy(); } }); } } }); form.setFields(password, newPass, newPassAgain, apply); addItem(form); }
Example 11
Source File: SetAdminPassword.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public SetAdminPassword(final String tenantName) { super(); setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("changepassword")); setIsModal(true); setShowModalMask(true); centerInPage(); setAutoSize(true); final ValuesManager vm = new ValuesManager(); final DynamicForm form = new DynamicForm(); form.setValuesManager(vm); MatchesFieldValidator equalsValidator = new MatchesFieldValidator(); equalsValidator.setOtherField(NEWPASSWORDAGAIN); equalsValidator.setErrorMessage(I18N.message("passwordnotmatch")); LengthRangeValidator sizeValidator = new LengthRangeValidator(); sizeValidator.setErrorMessage(I18N.message("errorfieldminlenght", Integer.toString(Session.get().getUser().getPasswordMinLenght()))); sizeValidator.setMin(Session.get().getUser().getPasswordMinLenght()); PasswordItem newPass = new PasswordItem(); newPass.setName(NEWPASSWORD); newPass.setTitle(I18N.message(NEWPASSWORD)); newPass.setRequired(true); newPass.setValidators(equalsValidator, sizeValidator); PasswordItem newPassAgain = new PasswordItem(); newPassAgain.setName(NEWPASSWORDAGAIN); newPassAgain.setTitle(I18N.message(NEWPASSWORDAGAIN)); newPassAgain.setWrapTitle(false); newPassAgain.setRequired(true); final ButtonItem apply = new ButtonItem(); apply.setTitle(I18N.message("apply")); apply.setAutoFit(true); apply.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { vm.validate(); if (!vm.hasErrors()) { apply.setDisabled(true); TenantService.Instance.get().changeAdminPassword(vm.getValueAsString(NEWPASSWORD).trim(), tenantName, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { SC.warn(caught.getMessage()); apply.setDisabled(false); } @Override public void onSuccess(Void arg) { apply.setDisabled(false); SetAdminPassword.this.destroy(); Log.info(I18N.message("event.user.passwordchanged"), null); } }); } } }); form.setFields(newPass, newPassAgain, apply); addItem(form); }
Example 12
Source File: ContactDetails.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
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 13
Source File: Registration.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public Registration(String[] reg) { super(); setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("registration")); setWidth(350); setHeight(150); setIsModal(true); setShowModalMask(true); centerInPage(); setAutoSize(true); final DynamicForm form = new DynamicForm(); form.setValuesManager(vm); form.setMargin(5); form.setNumCols(2); form.setTitleOrientation(TitleOrientation.TOP); TextItem regName = ItemFactory.newTextItem("reg_name", "name", null); regName.setWrapTitle(false); regName.setValue(reg[0]); TextItem regEmail = ItemFactory.newEmailItem("reg_email", "email", false); regEmail.setWrapTitle(false); regEmail.setValue(reg[1]); TextItem regOrganization = ItemFactory.newTextItem("reg_organization", "organization", null); regOrganization.setWrapTitle(false); regOrganization.setValue(reg[2]); TextItem regWebsite = ItemFactory.newTextItem("reg_website", "website", null); regWebsite.setWidth(180); regWebsite.setWrapTitle(false); regWebsite.setValue(reg[3]); ButtonItem apply = new ButtonItem(); apply.setTitle(I18N.message("apply")); apply.setAutoFit(true); apply.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { vm.validate(); if (!vm.hasErrors()) { SettingService.Instance.get().saveRegistration(form.getValueAsString("reg_name"), form.getValueAsString("reg_email"), form.getValueAsString("reg_organization"), form.getValueAsString("reg_website"), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { SC.warn(caught.getMessage()); } @Override public void onSuccess(Void ret) { afterSave(); Registration.this.destroy(); } }); } } }); form.setFields(regName, regEmail, regOrganization, regWebsite, apply); addItem(form); }
Example 14
Source File: CreateComplexRuleLayout.java From SensorWebClient with GNU General Public License v2.0 | 4 votes |
private void addSingle(String op, String ruleName){ // get all members from mainLayout and clear the layout Canvas[] members = this.ruleBlockLayout.getMembers(); this.ruleBlockLayout.removeMembers(this.ruleBlockLayout.getMembers()); LinkedHashMap<String, String> operatorHashMap = getLogicalOperators(); VLayout v2 = new VLayout(); v2.setWidth("70%"); v2.addMember(members[0]); v2.addMember(createSingle(ruleName)); DynamicForm block1 = new DynamicForm(); block1.setWidth("30%"); block1.setNumCols(1); this.singleOperator = new SelectItem(); this.singleOperator.setShowTitle(false); this.singleOperator.setWidth(this.operatorWidth); this.singleOperator.setValueMap(operatorHashMap); this.singleOperator.setTextAlign(Alignment.CENTER); if (op != null) { this.singleOperator.setValue(op); } else { this.singleOperator.setValue(LogicalOperator.AND.toString()); } SpacerItem spacerItem = new SpacerItem(); spacerItem.setShowTitle(false); spacerItem.setHeight(20); block1.setFields(spacerItem, spacerItem, this.singleOperator); HLayout layout = new HLayout(); layout.setWidth(200); layout.setHeight(25); layout.setEdgeMarginSize(1); layout.setEdgeSize(2); layout.setShowEdges(true); layout.addMember(block1); layout.addMember(v2); this.ruleBlockLayout.addMember(layout); }
Example 15
Source File: DataControlsTimeSeries.java From SensorWebClient with GNU General Public License v2.0 | 4 votes |
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; }
Example 16
Source File: SaveDialog.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
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); }
Example 17
Source File: TwoFactorsAuthenticationSettings.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
private void init(GUIParameter[] parameters) { DynamicForm form = new DynamicForm(); form.setWidth(1); form.setValuesManager(vm); form.setTitleOrientation(TitleOrientation.LEFT); form.setNumCols(1); Map<String, String> settings = Util.convertToMap(parameters); final RadioGroupItem enable2fa = ItemFactory.newBooleanSelector("enable2fa", I18N.message("enable2fa")); enable2fa.setValue("true".equals(settings.get("enabled")) ? "yes" : "no"); enable2fa.setWrapTitle(false); enable2fa.setWrap(false); enable2fa.setRequired(true); enable2fa.setDisabled(Session.get().isDemo()); form.setFields(enable2fa); /* * GoogleAuthenticator section */ DynamicForm googleForm = new DynamicForm(); googleForm.setValuesManager(vm); googleForm.setTitleOrientation(TitleOrientation.TOP); googleForm.setIsGroup(true); googleForm.setGroupTitle("Google Authenticator"); googleForm.setNumCols(1); final RadioGroupItem enableGoolge = ItemFactory.newBooleanSelector("enableGoolge", I18N.message("enablegoogleauthenticator")); enableGoolge.setValue("true".equals(settings.get(Constants.TWOFA_GOOGLE_AUTHENTICATOR + ".enabled")) ? "yes" : "no"); enableGoolge.setWrapTitle(false); enableGoolge.setWrap(false); enableGoolge.setRequired(true); enableGoolge.setDisabled(Session.get().isDemo()); googleForm.setFields(enableGoolge); /* * Yubikey section */ DynamicForm yubikeyForm = new DynamicForm(); yubikeyForm.setValuesManager(vm); yubikeyForm.setTitleOrientation(TitleOrientation.TOP); yubikeyForm.setIsGroup(true); yubikeyForm.setGroupTitle("YubiKey"); yubikeyForm.setNumCols(1); final RadioGroupItem enableYubikey = ItemFactory.newBooleanSelector("enableYubikey", I18N.message("enableyubikey")); enableYubikey.setValue("true".equals(settings.get("yubikey.enabled")) ? "yes" : "no"); enableYubikey.setWrapTitle(false); enableYubikey.setWrap(false); enableYubikey.setRequired(true); enableYubikey.setDisabled(Session.get().isDemo()); yubikeyForm.setFields(enableYubikey); IButton save = new IButton(); save.setTitle(I18N.message("save")); save.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (vm.validate()) { String tenant = Session.get().getTenantName(); final List<GUIParameter> params = new ArrayList<GUIParameter>(); params.add(new GUIParameter(tenant + ".2fa.enabled", vm.getValueAsString("enable2fa").equals("yes") ? "true" : "false")); params.add(new GUIParameter(tenant + ".2fa." + Constants.TWOFA_GOOGLE_AUTHENTICATOR + ".enabled", vm.getValueAsString("enableGoolge").equals("yes") ? "true" : "false")); params.add(new GUIParameter(tenant + ".2fa." + Constants.TWOFA_YUBIKEY + ".enabled", vm.getValueAsString("enableYubikey").equals("yes") ? "true" : "false")); 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 arg) { Session.get().updateConfig(params); Log.info(I18N.message("settingssaved"), null); } }); } } }); VLayout panel = new VLayout(); panel.setWidth100(); panel.setMembers(form, googleForm, yubikeyForm); body.setMembers(panel); addMember(save); }
Example 18
Source File: SubscriptionTemplate.java From SensorWebClient with GNU General Public License v2.0 | 4 votes |
protected DynamicForm assembleEditConditionForm(FormItem... formItems) { DynamicForm form = new DynamicForm(); form.setNumCols(formItems.length + 1); form.setFields(formItems); return form; }
Example 19
Source File: ImportSourceChooser.java From proarc with GNU General Public License v3.0 | 4 votes |
private DynamicForm createOptionsForm() { DynamicForm form = new DynamicForm(); form.setNumCols(10); form.setGroupTitle(i18n.ImportSourceChooser_Options_Title()); form.setIsGroup(true); form.setWrapItemTitles(false); final CheckboxItem cbiPageIndexes = new CheckboxItem(ImportBatchDataSource.FIELD_INDICES, i18n.ImportSourceChooser_OptionPageIndices_Title()); cbiPageIndexes.setValue(true); final SelectItem selectScanner = createScannerSelection(); final SelectItem selectProfile = ProfileChooser.createProfileSelection(ProfileGroup.IMPORTS, i18n); selectProfile.setName(ImportBatchDataSource.FIELD_PROFILE_ID); selectProfile.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { String profile = getImportProfile(); Criteria criteria = new Criteria(); if (profile != null) { criteria.addCriteria(ImportTreeDataSource.FIELD_PROFILE, profile); } treeGrid.setCriteria(criteria); boolean isArchive= BatchRecord.isArchive(profile); boolean isKramerius = BatchRecord.isKramerius(profile); selectScanner.setRequired(!isArchive); if (isKramerius) { selectScanner.show(); cbiPageIndexes.hide(); } else if (isArchive) { selectScanner.hide(); cbiPageIndexes.hide(); } else { selectScanner.show(); cbiPageIndexes.show(); } } }); form.setFields(selectProfile, selectScanner, cbiPageIndexes); return form; }
Example 20
Source File: FormGenerator.java From proarc with GNU General Public License v3.0 | 4 votes |
public static void addFormItems(DynamicForm df, List<? extends FormItem> t) { FormItem[] items = t.toArray(new FormItem[t.size()]); df.setFields(items); }