Java Code Examples for com.smartgwt.client.widgets.layout.VLayout#setMembers()
The following examples show how to use
com.smartgwt.client.widgets.layout.VLayout#setMembers() .
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: PopupMessage.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
public PopupMessage(String title, String messageText) { setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(title); setAlign(Alignment.CENTER); setAutoSize(true); centerInPage(); Label label=new Label(messageText); label.setMinWidth(350); VLayout layout= new VLayout(); layout.setMembersMargin(2); layout.setMembers(label); addItem(layout); Scheduler.get().scheduleFixedDelay(new RepeatingCommand() { @Override public boolean execute() { PopupMessage.this.destroy(); return false; } }, Session.get().getConfigAsInt("gui.popup.timeout") * 1000); }
Example 2
Source File: DesaExportAction.java From proarc with GNU General Public License v3.0 | 6 votes |
public ExportResultWidget() { i18n = GWT.create(ClientMessages.class); VLayout vLayout = new VLayout(); vLayout.setWidth100(); vLayout.setHeight100(); grid = new ListGrid(); grid.setSelectionType(SelectionStyle.SINGLE); grid.setFixedRecordHeights(false); grid.setWrapCells(true); ListGridField pidField = new ListGridField(ExportResourceApi.RESULT_ERROR_PID, i18n.ExportResultWidget_PID_Title()); ListGridField errorField = new ListGridField(ExportResourceApi.RESULT_ERROR_MESSAGE, i18n.ExportResultWidget_Message_Title()); grid.setFields(pidField, errorField); grid.addSelectionUpdatedHandler(new SelectionUpdatedHandler() { @Override public void onSelectionUpdated(SelectionUpdatedEvent event) { logForm.editSelectedData(grid); } }); logForm = createLogForm(); vLayout.setMembers(grid, logForm); this.widget = vLayout; }
Example 3
Source File: ContactingServer.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
private ContactingServer() { setHeaderControls(HeaderControls.HEADER_LABEL); setTitle(" "); setCanDragResize(false); setIsModal(true); setShowModalMask(true); centerInPage(); setAutoSize(true); setShowStatusBar(false); setBodyColor("white"); setMembersMargin(0); HTMLFlow message = new HTMLFlow(AwesomeFactory.getSpinnerIconHtml("pulse", I18N.message("contactingserver"))); message.setAlign(Alignment.CENTER); message.setStyleName("contactingserver"); message.setLayoutAlign(Alignment.CENTER); message.setLayoutAlign(VerticalAlignment.CENTER); message.setBackgroundColor("white"); message.setHeight(50); VLayout container = new VLayout(); container.setWidth100(); container.setMembersMargin(5); container.setMargin(3); container.setAlign(Alignment.CENTER); container.setDefaultLayoutAlign(Alignment.CENTER); container.setMembers(message); addItem(container); }
Example 4
Source File: ApplicationRestarting.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
private ApplicationRestarting() { setHeaderControls(HeaderControls.HEADER_LABEL); setTitle(" "); setCanDragResize(false); setIsModal(true); setShowModalMask(true); centerInPage(); setAutoSize(true); setShowStatusBar(false); setBodyColor("white"); setMembersMargin(0); messageFlow = new HTMLFlow(); messageFlow.setAlign(Alignment.CENTER); messageFlow.setStyleName("contactingserver"); messageFlow.setLayoutAlign(Alignment.CENTER); messageFlow.setLayoutAlign(VerticalAlignment.CENTER); messageFlow.setBackgroundColor("white"); messageFlow.setHeight(50); VLayout container = new VLayout(); container.setWidth100(); container.setMembersMargin(5); container.setMargin(3); container.setAlign(Alignment.CENTER); container.setDefaultLayoutAlign(Alignment.CENTER); container.setMembers(messageFlow); addItem(container); }
Example 5
Source File: LoginPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
protected void prepareSwitchViewLink() { String url = "mobile".equals(Util.getJavascriptVariable("j_layout")) ? (Util.contextPath() + "login.jsp") : (Util.contextPath() + "login-mobile.jsp"); url += "?tenant=" + Util.detectTenant(); String label = "mobile".equals(Util.getJavascriptVariable("j_layout")) ? I18N.message("viewclassicweb") : I18N.message("viewmobileweb"); /* * A link to the alternative login page */ HTMLFlow switchLink = new HTMLFlow("<a href='" + url + "' class='login-switchview'>" + label + "</a>"); switchLink.setHeight(16); switchLink.setWidth(COLUMN_WIDTH + 20); switchLink.setStyleName("login-switchview"); HLayout spacer10 = new HLayout(); spacer10.setHeight(10); spacer10.setWidth(10); VLayout link = new VLayout(); link.setMembersMargin(0); link.setMargin(0); link.setStyleName("login-switchview"); link.setMembers(spacer10, switchLink); link.setLayoutAlign(VerticalAlignment.TOP); link.setLayoutAlign(Alignment.CENTER); link.setWidth(COLUMN_WIDTH + 20); link.setHeight(18); mainPanel.addMember(link); }
Example 6
Source File: ImportPresenter.java From proarc with GNU General Public License v3.0 | 5 votes |
@Override public Canvas asWidget() { if (widget == null) { widget = new ImportParentChooser(i18n); widget.setParentOwnerCheck(true); widget.getUI().setMargin(4); container = new VLayout(); container.setMembers(buildToolbar(), widget.getUI()); } return container; }
Example 7
Source File: FillForm.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
public FillForm(GUIDocument frm) { setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("form") + " - " + Util.getBaseName(frm.getFileName())); setWidth(500); setHeight(400); setCanDragResize(true); setIsModal(true); setShowModalMask(true); centerInPage(); IButton save = new IButton(); save.setTitle(I18N.message("save")); save.setAutoFit(true); save.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) { onSave(); } }); HLayout buttonsBar = new HLayout(); buttonsBar.setWidth100(); buttonsBar.setHeight(25); buttonsBar.setMembers(save); propertiesPanel = new ExtendedPropertiesPanel(frm, null, true, true, false); VLayout layout = new VLayout(); layout.setMargin(3); layout.setMembersMargin(3); layout.setMembers(propertiesPanel, buttonsBar); addItem(layout); }
Example 8
Source File: CopyPageMetadataWidget.java From proarc with GNU General Public License v3.0 | 5 votes |
public CopyPageMetadataWidget() { this.i18n = GWT.create(ClientMessages.class); form = createForm(); formPanel = new VLayout(10); formPanel.setAutoHeight(); formPanel.setMembers(form); }
Example 9
Source File: CreateAliasDialog.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public CreateAliasDialog() { super(); setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("createalias")); setWidth(470); setHeight(280); setCanDragResize(true); setIsModal(true); setShowModalMask(true); centerInPage(); setPadding(3); VLayout content = new VLayout(); content.setTop(10); content.setWidth100(); content.setHeight100(); content.setMembersMargin(3); final TreeGrid folders = new FolderTree(); folders.setWidth100(); folders.setHeight100(); HLayout buttons = new HLayout(); buttons.setWidth100(); buttons.setHeight(30); Button create = new Button(I18N.message("create")); create.setAutoFit(true); create.setMargin(1); create.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { FolderNavigator.get().createAlias( Long.parseLong(folders.getSelectedRecord().getAttributeAsString("folderId"))); destroy(); } }); buttons.setMembers(create); content.setMembers(folders, buttons); addItem(content); }
Example 10
Source File: MoveDialog.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public MoveDialog() { super(); setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("move")); setWidth(250); setHeight(270); setCanDragResize(true); setIsModal(true); setShowModalMask(true); centerInPage(); setPadding(3); VLayout content = new VLayout(); content.setTop(10); content.setWidth100(); content.setHeight100(); content.setMembersMargin(3); final TreeGrid folders = new FolderTree(); folders.setWidth100(); folders.setHeight100(); VLayout buttons = new VLayout(); buttons.setWidth100(); buttons.setHeight(30); Button move = new Button(I18N.message("move")); move.setAutoFit(true); move.setMargin(1); move.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String shownName = FolderNavigator.get().getSelectedRecord().getAttributeAsString("name"); long[] selection = FolderNavigator.get().getSelectedIds(); if (selection.length > 1) shownName = selection.length + " " + I18N.message("folders").toLowerCase(); LD.ask(I18N.message("move"), I18N.message("moveask", new String[] { shownName, folders.getSelectedRecord().getAttributeAsString("name") }), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { FolderNavigator.get() .moveTo(Long.parseLong(folders.getSelectedRecord().getAttributeAsString( "folderId"))); } destroy(); } }); } }); buttons.setMembers(move); content.setMembers(folders, buttons); addItem(content); }
Example 11
Source File: DigitalObjectChildrenEditor.java From proarc with GNU General Public License v3.0 | 4 votes |
public DigitalObjectChildrenEditor(ClientMessages i18n, PlaceController places, OptionalEditor preview) { this.i18n = i18n; this.places = places; this.preview = preview; this.actionSource = new ActionSource(this); this.goDownAction = DigitalObjectNavigateAction.child(i18n, places); relationDataSource = RelationDataSource.getInstance(); childrenListGrid = initChildrenListGrid(); this.selectionCache = SelectionCache.selector(childrenListGrid); VLayout childrenLayout = new VLayout(); childrenLayout.setMembers(childrenListGrid); childrenLayout.setWidth("40%"); childrenLayout.setShowResizeBar(true); SimpleEventBus eventBus = new SimpleEventBus(); childPlaces = new PlaceController(eventBus); childEditor = new DigitalObjectEditor(i18n, childPlaces, true); ActivityManager activityManager = new ActivityManager( new ChildActivities(childEditor), eventBus); VLayout editorsLayout = new VLayout(); VLayout editorsOuterLayout = new VLayout(); // editorsLayout.setBorder("1px solid grey"); editorsLayout.addStyleName("defaultBorder"); editorsOuterLayout.setLayoutLeftMargin(4); editorsOuterLayout.setMembers(editorsLayout); activityManager.setDisplay(new ChildEditorDisplay(editorsLayout)); widget = new HLayout(); widget.setMembers(childrenLayout, editorsOuterLayout); relationDataSource.addRelationChangeHandler(new RelationChangeHandler() { @Override public void onRelationChange(RelationChangeEvent event) { // issue 262: isVisible seems to be always true and isAttached is always null. // Add test isDrawn that seems to change for dettached widgets. if (digitalObject != null && childrenListGrid.isVisible() && childrenListGrid.isDrawn()) { String changedPid = event.getPid(); if (changedPid != null) { Record changedRecord = childrenListGrid.getDataAsRecordList() .find(RelationDataSource.FIELD_PID, changedPid); if (changedRecord == null) { // moved object(s) // ListGrid does not remove selection of removed/moved rows // and it does not fire selection change // issue 246: clear selection of moved row childrenListGrid.deselectAllRecords(); DigitalObjectCopyMetadataAction.resetSelection(); showCopySelection(new Record[0]); return ; } } final ListGridRecord[] selection = childrenListGrid.getSelectedRecords(); relationDataSource.updateCaches(digitalObject.getPid(), new BooleanCallback() { @Override public void execute(Boolean value) { // refresh the copy selection as updated records are missing the copy attribute showCopySelection(DigitalObjectCopyMetadataAction.getSelection()); // refresh the list selection selectChildren(selection); } }); } } }); }
Example 12
Source File: TwoFactorsAuthenticationDialog.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public TwoFactorsAuthenticationDialog(final GUIUser user, boolean allowNotify) { super(); setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("twofactorsauth")); setIsModal(true); setShowModalMask(true); centerInPage(); setAutoSize(true); final TwoFactorsAuthenticationPanel panel = new TwoFactorsAuthenticationPanel(user, allowNotify); panel.setWidth(350); IButton save = new IButton(I18N.message("save")); save.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (panel.validate()) { TwoFactorsAuthenticationService.Instance.get().changeTwoFactorsAuthentication(user.getId(), panel.getFactor(), panel.getKey(), panel.getAccount(), panel.isNotify(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { Log.serverError(caught); } @Override public void onSuccess(Void arg) { user.setSecondFactor(panel.getFactor()); user.setKey(panel.getKey()); TwoFactorsAuthenticationDialog.this.destroy(); } }); } } }); VLayout body = new VLayout(); body.setMembers(panel, save); addItem(body); }
Example 13
Source File: ExternalAppsPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
private Tab prepareExternalCall(GUIParameter[] settings) { VLayout pane = new VLayout(); Tab extCall = new Tab(); extCall.setTitle(I18N.message("externalcall")); DynamicForm extCallForm = new DynamicForm(); extCallForm.setWidth(400); extCallForm.setIsGroup(true); extCallForm.setNumCols(2); extCallForm.setPadding(2); extCallForm.setGroupTitle(I18N.message("externalcall")); extCallForm.setValuesManager(vm); extCallForm.setTitleOrientation(TitleOrientation.LEFT); final RadioGroupItem extCallEnabled = ItemFactory.newBooleanSelector("extCallEnabled", "enabled"); extCallEnabled.setRequired(true); extCallEnabled.setRedrawOnChange(true); extCallEnabled.setValue("no"); TextItem extCallName = ItemFactory.newTextItem("extCallName", I18N.message("name"), null); TextItem extCallBaseUrl = ItemFactory.newTextItem("extCallBaseUrl", I18N.message("baseurl"), null); extCallBaseUrl.setWidth(300); TextItem extCallSuffix = ItemFactory.newTextItem("extCallSuffix", I18N.message("suffix"), null); extCallSuffix.setWidth(300); TextItem extCallWindow = ItemFactory.newTextItem("extCallWindow", I18N.message("targetwindow"), "_blank"); extCallForm.setItems(extCallEnabled, extCallName, extCallBaseUrl, extCallSuffix, extCallWindow); // Use a second form to group the parameters section DynamicForm parametersForm = new DynamicForm(); parametersForm.setWidth(400); parametersForm.setIsGroup(true); parametersForm.setGroupTitle(I18N.message("parameters")); parametersForm.setNumCols(4); extCallForm.setPadding(2); parametersForm.setValuesManager(vm); extCallParamUser = ItemFactory.newCheckbox("extCallParamUser", "user"); extCallParamTitle = ItemFactory.newCheckbox("extCallParamTitle", "filename"); parametersForm.setItems(extCallParamUser, extCallParamTitle); pane.setMembers(extCallForm, parametersForm); extCall.setPane(pane); String tenant = Session.get().getTenantName(); for (GUIParameter s : settings) { if ((tenant + ".extcall.enabled").equals(s.getName())) extCallEnabled.setValue("true".equals(s.getValue()) ? "yes" : "no"); else if ((tenant + ".extcall.name").equals(s.getName())) extCallName.setValue(s.getValue()); else if ((tenant + ".extcall.baseurl").equals(s.getName())) extCallBaseUrl.setValue(s.getValue()); else if ((tenant + ".extcall.suffix").equals(s.getName())) extCallSuffix.setValue(s.getValue()); else if ((tenant + ".extcall.window").equals(s.getName())) extCallWindow.setValue(s.getValue()); else if ((tenant + ".extcall.params").equals(s.getName())) { String[] tokens = s.getValue().split(","); for (String param : tokens) { if ("user".equals(param.trim())) extCallParamUser.setValue("true"); else if ("filename".equals(param.trim())) extCallParamTitle.setValue("true"); } } } return extCall; }
Example 14
Source File: InheritRightsDialog.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public InheritRightsDialog(final FolderSecurityPanel panel) { super(); setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("inheritrights")); setWidth(250); setHeight(270); setCanDragResize(true); setIsModal(true); setShowModalMask(true); centerInPage(); setPadding(3); VLayout content = new VLayout(); content.setTop(10); content.setWidth100(); content.setHeight100(); content.setMembersMargin(3); final TreeGrid folders = new FolderTree(); folders.setWidth100(); folders.setHeight100(); VLayout buttons = new VLayout(); buttons.setWidth100(); buttons.setHeight(30); Button inheritRights = new Button(I18N.message("inheritrights")); inheritRights.setAutoFit(true); inheritRights.setMargin(1); inheritRights.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { LD.ask(I18N.message("inheritrights"), I18N.message("inheritrightsask", new String[] { FolderNavigator.get().getSelectedRecord().getAttributeAsString("name"), folders.getSelectedRecord().getAttributeAsString("name") }), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { FolderService.Instance.get() .inheritRights( panel.getFolder().getId(), Long.parseLong(folders.getSelectedRecord().getAttributeAsString( "folderId")), new AsyncCallback<GUIFolder>() { @Override public void onFailure(Throwable caught) { Log.serverError(caught); destroy(); } @Override public void onSuccess(GUIFolder arg) { panel.refresh(arg); destroy(); } }); } destroy(); } }); } }); buttons.setMembers(inheritRights); content.setMembers(folders, buttons); addItem(content); }
Example 15
Source File: ZoneEditor.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public ZoneEditor(GUIZone zone) { setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("zone") + " - " + zone.getName()); setCanDragResize(true); setIsModal(true); setShowModalMask(true); centerInPage(); setAutoSize(true); this.zone = zone; IButton save = new IButton(I18N.message("save")); save.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) { onSave(); } }); prepareForm(); ImageWithCanvases sample = new ImageWithCanvases(zone.getSampleUrl(), 300, null, null); HLayout body = new HLayout(); body.setMembers(form, sample); VLayout layout = new VLayout(); layout.setMembersMargin(5); layout.setWidth100(); layout.setMembers(body, save); addItem(layout); // Just to clean the upload folder DocumentService.Instance.get().cleanUploadedFileFolder(new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Void result) { } }); }
Example 16
Source File: DropboxDialog.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public DropboxDialog(boolean export) { super(); this.export = export; setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("dropbox")); setWidth(350); setHeight(300); setCanDragResize(true); setIsModal(true); setShowModalMask(true); centerInPage(); setPadding(3); VLayout content = new VLayout(); content.setTop(10); content.setWidth100(); content.setHeight100(); content.setMembersMargin(3); tree = new DropboxTree(export); tree.setWidth100(); tree.setHeight100(); VLayout buttons = new VLayout(); buttons.setWidth100(); buttons.setHeight(30); Button select = new Button(I18N.message("select")); select.setAutoFit(true); select.setMargin(1); select.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (DropboxDialog.this.export) onExport(); else onImport(); } }); buttons.setMembers(select); content.setMembers(tree, buttons); addItem(content); }
Example 17
Source File: TaskNotificationPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void onDraw() { VLayout notificationsPane = new VLayout(); setMembers(notificationsPane); final DynamicForm notificationsForm = new DynamicForm(); notificationsForm.setColWidths(1, "*"); notificationsForm.setMargin(3); List<FormItem> items = new ArrayList<FormItem>(); // Enable/Disable notifications CheckboxItem sendReport = new CheckboxItem(); sendReport.setName("sendReport"); sendReport.setTitle(I18N.message("sendactivityreport")); sendReport.setRedrawOnChange(true); sendReport.setWidth(50); sendReport.setValue(task.isSendActivityReport()); sendReport.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { task.setSendActivityReport("true".equals(notificationsForm.getValue("sendReport").toString())); // Notify the external handler changedHandler.onChanged(event); } }); items.add(sendReport); Long[] ids = new Long[task.getReportRecipients().length]; for (int i = 0; i < ids.length; i++) ids[i] = task.getReportRecipients()[i].getId(); recipients = ItemFactory.newMultiComboBoxItem("recipients", "recipients", new UsersDS(null, false), ids); recipients.setValueField("id"); recipients.setDisplayField("username"); recipients.addChangedHandler(changedHandler); items.add(recipients); notificationsForm.setItems(items.toArray(new FormItem[0])); notificationsPane.setMembers(notificationsForm); }
Example 18
Source File: ShareFileDialog.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public ShareFileDialog(boolean export) { super(); this.export = export; setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON); setTitle(I18N.message("sharefile")); setWidth(350); setHeight(300); setCanDragResize(true); setIsModal(true); setShowModalMask(true); centerInPage(); setPadding(3); VLayout content = new VLayout(); content.setTop(10); content.setWidth100(); content.setHeight100(); content.setMembersMargin(3); tree = new ShareFileTree(export); tree.setWidth100(); tree.setHeight100(); VLayout buttons = new VLayout(); buttons.setWidth100(); buttons.setHeight(30); Button select = new Button(I18N.message("select")); select.setAutoFit(true); select.setMargin(1); select.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (ShareFileDialog.this.export) onExport(); else onImport(); } }); buttons.setMembers(select); content.setMembers(tree, buttons); addItem(content); }
Example 19
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 20
Source File: GoogleAuthenticatorSetup.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
private void init(String account, String key, String qrUrl) { // Prepare the form with account informations StaticTextItem accountItem = ItemFactory.newStaticTextItem("account", I18N.message("account"), account); accountItem.setWrap(false); accountItem.setWrapTitle(false); StaticTextItem keyItem = ItemFactory.newStaticTextItem("key", I18N.message("key"), key); keyItem.setWrap(false); keyItem.setWrapTitle(false); DynamicForm form = new DynamicForm(); form.setTitleOrientation(TitleOrientation.LEFT); form.setItems(accountItem, keyItem); Label formTitle = new Label("<b>" + I18N.message(Constants.TWOFA_GOOGLE_AUTHENTICATOR+".hint1") + "</b>"); formTitle.setWrap(true); formTitle.setMinWidth(250); VLayout formLayout = new VLayout(); formLayout.setMembersMargin(2); formLayout.setMembers(formTitle, form); formLayout.setAlign(VerticalAlignment.TOP); // Prepare the QR Code HTMLFlow qrCode = new HTMLFlow("<img width='200' height='200' src='" + qrUrl + "'/>"); qrCode.setOverflow(Overflow.VISIBLE); Label qrCodeTitle = new Label("<b>" + I18N.message(Constants.TWOFA_GOOGLE_AUTHENTICATOR+".hint2") + "</b>"); qrCodeTitle.setWrap(true); qrCodeTitle.setMinWidth(250); VLayout qrCodeLayout = new VLayout(); qrCodeLayout.setWidth100(); qrCodeLayout.setHeight100(); qrCodeLayout.setMembers(qrCodeTitle, qrCode); VLayout separator = new VLayout(); separator.setWidth(20); HLayout body = new HLayout(); body.setMembersMargin(2); body.setMembers(formLayout, separator, qrCodeLayout); setMembers(body); }