private Button genBut(String name) { Button b = new Button(name); b.addStyleName("user-select"); b.setIcon(userIcon); b.addClickListener( e -> { if (loginBox.isVisible()) { hidePass(); return; } loginField.setValue(""); String t = e.getButton().getCaption(); if (Globals.control.hasPassword(t)) { selected = Globals.control.getUser(t); showPassField(); } else { User s = Globals.control.getUser(t); if (s == null) { return; } Globals.user = s; Globals.root.changeScreen(Globals.user); } }); return b; }
private void initLayout() { FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined(); loginForm.addComponent(userName = new TextField("Username")); loginForm.addComponent(passwordField = new PasswordField("Password")); loginForm.addComponent(login = new Button("Login")); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { login(); } }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSizeUndefined(); loginLayout.addComponent(loginFailedLabel = new Label()); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(rootLayout); setSizeFull(); }
private Component buildFooter() { HorizontalLayout footer = new HorizontalLayout(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Unit.PERCENTAGE); Button ok = new Button("OK"); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.addClickListener( event -> { try { fieldGroup.commit(); // Updated user should also be persisted to database. But // not in this demo. Notification success = new Notification("Profile updated successfully"); success.setDelayMsec(2000); success.setStyleName("bar success small"); success.setPosition(Position.BOTTOM_CENTER); success.show(Page.getCurrent()); // DashboardEventBus.post(new ProfileUpdatedEvent()); close(); } catch (CommitException e) { Notification.show("Error while updating profile", Type.ERROR_MESSAGE); } }); ok.focus(); footer.addComponent(ok); footer.setComponentAlignment(ok, Alignment.TOP_RIGHT); return footer; }
private com.vaadin.ui.Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); final TextField username = new TextField("Username"); username.setIcon(FontAwesome.USER); username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final PasswordField password = new PasswordField("Password"); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(ShortcutAction.KeyCode.ENTER); signin.focus(); fields.addComponents(username, password, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); signin.addClickListener( new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { DashboardEventBus.post( new UserLoginRequestedEvent(username.getValue(), password.getValue())); } }); return fields; }
/** This is the entry point method. */ public void onModuleLoad() { sendButton = new Button("Send"); nameField = new TextBox(); nameField.setText("GWT User"); errorLabel = new Label(); // We can add style names to widgets sendButton.addStyleName("sendButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create the popup dialog box dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); textToServerLabel = new Label(); serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending name to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Server replies:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox final ClickHandler buttonClickHandler = new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }; closeButton.addClickHandler(buttonClickHandler); // Add a handler to send the name to the server ChangeEventHandler handler = new ChangeEventHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); }
public UserSelect() { loginInfo = new Label(""); loginInfo.addStyleName("error-font"); loginInfo.addStyleName("margin15"); loginInfo.addStyleName("margin-top40"); loginInfo.setVisible(false); selected = null; loginField = new PasswordField(""); loginField.setWidth("200px"); loginField.addStyleName("margin15"); loginField.addStyleName("margin-bot40"); loginBut = new Button("login"); loginBut.addStyleName("margin15"); loginBut.addClickListener( e -> { if (loginField.getValue().equals(selected.getPassword())) { hidePass(); Globals.user = selected; Globals.root.changeScreen(Globals.user); } else { loginInfo.setVisible(true); loginInfo.setValue("Wrong password"); loginField.setValue(""); } }); loginBox = new HorizontalLayout(); loginBox.addStyleName("popup-box"); loginBox.addComponents(loginField, loginBut, loginInfo); loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_LEFT); loginBox.setComponentAlignment(loginBut, Alignment.MIDDLE_CENTER); loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_RIGHT); loginBox.setVisible(false); userIcon = new ThemeResource("icons/user.png"); users = Globals.control.usersData(); vbox = new VerticalLayout(); // vbox.setSizeUndefined(); vbox.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); Panel p = new Panel(); p.setSizeFull(); p.setContent(vbox); // vbox.addStyleName("border-l-r"); this.addComponent(p, "left: 25%; right: 25%; top: 15px"); this.addComponent(loginBox, "left: 25%; right: 25%; top: 40%"); this.addLayoutClickListener( e -> { if (!loginBox.isVisible()) return; System.out.println(e.getClickedComponent()); if (e.getClickedComponent() == null || e.getClickedComponent().equals(vbox)) hidePass(); }); }
private void queryAndDisplayTasks() { wrapBody.removeAllComponents(); if (GROUP_DUE_DATE.equals(groupByState)) { baseCriteria.setOrderFields( Arrays.asList(new SearchCriteria.OrderField("deadline", sortDirection))); taskGroupOrderComponent = new DueDateOrderComponent(); } else if (GROUP_START_DATE.equals(groupByState)) { baseCriteria.setOrderFields( Arrays.asList(new SearchCriteria.OrderField("startdate", sortDirection))); taskGroupOrderComponent = new StartDateOrderComponent(); } else if (PLAIN_LIST.equals(groupByState)) { baseCriteria.setOrderFields( Arrays.asList(new SearchCriteria.OrderField("lastupdatedtime", sortDirection))); taskGroupOrderComponent = new SimpleListOrderComponent(); } else { throw new MyCollabException("Do not support group view by " + groupByState); } wrapBody.addComponent(taskGroupOrderComponent); final ProjectTaskService projectTaskService = ApplicationContextUtil.getSpringBean(ProjectTaskService.class); int totalTasks = projectTaskService.getTotalCount(baseCriteria); taskSearchPanel.setTotalCountNumber(totalTasks); currentPage = 0; int pages = totalTasks / 20; if (currentPage < pages) { Button moreBtn = new Button( "More", new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { int totalTasks = projectTaskService.getTotalCount(baseCriteria); int pages = totalTasks / 20; currentPage++; List<SimpleTask> otherTasks = projectTaskService.findPagableListByCriteria( new SearchRequest<>(baseCriteria, currentPage + 1, 20)); taskGroupOrderComponent.insertTasks(otherTasks); if (currentPage == pages) { wrapBody.removeComponent(wrapBody.getComponent(1)); } } }); moreBtn.addStyleName(UIConstants.THEME_GREEN_LINK); wrapBody.addComponent(moreBtn); } List<SimpleTask> tasks = projectTaskService.findPagableListByCriteria( new SearchRequest<>(baseCriteria, currentPage + 1, 20)); taskGroupOrderComponent.insertTasks(tasks); }
private HorizontalLayout getButtons() { final HorizontalLayout layout = new HorizontalLayout(); layout.setSizeUndefined(); layout.setSpacing(true); save.addStyleName(Reindeer.BUTTON_DEFAULT); save.setClickShortcut(ShortcutAction.KeyCode.ENTER); layout.addComponent(save); layout.addComponent(edit); layout.addComponent(update); layout.addComponent(cancel); layout.addComponent(exit); return layout; }
private Layout createBottomPanel() { final HorizontalLayout controlPanel = new HorizontalLayout(); controlPanel.setMargin(true); controlPanel.setStyleName("more-info"); controlPanel.setHeight("40px"); controlPanel.setWidth("100%"); Button moreInfoBtn = new Button( "More information...", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { editUserForm.displayAdvancedForm(user); } }); moreInfoBtn.addStyleName(UIConstants.THEME_LINK); controlPanel.addComponent(moreInfoBtn); controlPanel.setComponentAlignment(moreInfoBtn, Alignment.MIDDLE_LEFT); return controlPanel; }
public DescriptionCellEditor() { super(); ensureResources(); setStyleName(""); addCloseHandler( new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (event.isAutoClosed()) { commit(); hide(); } } }); VerticalPanel verticalPanel = new VerticalPanel(); textArea = new RichTextArea(); textArea.setTabIndex(0); textArea.addStyleName(resources.style().bDescriptionCellEditor__editor()); textArea.addKeyDownHandler( new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { int keyCode = event.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_ESCAPE) { cancelButton.setFocus(true); // or grid did not get back focus hide(); } else if (keyCode == KeyCodes.KEY_ENTER && event.isControlKeyDown()) { okButton.setFocus(true); // or grid did not get back focus okButton.click(); } } }); VerticalPanel textAreaPanel = new VerticalPanel(); textAreaPanel.add(textArea); HorizontalPanel buttonPanel = new HorizontalPanel(); okButton = new Button(strings.ok()); okButton.addStyleName(resources.style().bDescriptionCellEditor__ok()); okButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { commit(); hide(); } }); buttonPanel.add(okButton); cancelButton = new Button(strings.cancel()); cancelButton.addStyleName(resources.style().bDescriptionCellEditor__cancel()); cancelButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); buttonPanel.add(cancelButton); textAreaPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); textAreaPanel.add(buttonPanel); RichTextToolbar textToolbar = new RichTextToolbar(textArea); SimplePanel toolBarPanel = new SimplePanel(textToolbar); toolBarPanel.addStyleName(resources.style().bDescriptionCellEditor__toolbar()); verticalPanel.add(toolBarPanel); verticalPanel.add(textAreaPanel); add(verticalPanel); }
public AddNewModuleDialog( final ApplicationModel model, final List<String> types, final NewModuleCreatedCallback callback, final Context errorDisplay) { super(false, true); okButton = new Button("Ok"); okButton.addStyleName("btn"); cancelButton = new Button("Cancel"); okButton.addStyleName("btn"); this.errorDisplay = errorDisplay; setTitle("Add new module"); final Panel radioPanel = new HorizontalPanel(); { final Panel daemonPanel; daemonPanel = new VerticalPanel(); boolean wasChecked = false; for (final DaemonModel daemonModel : model.getDaemons()) { final RadioButton radio = new RadioButton("daemonRadioGroup", "Add to " + daemonModel.getName() + " daemon."); if (!wasChecked) { radio.setValue(true); wasChecked = true; } daemonPanel.add(radio); daemonRadios.put(daemonModel, radio); } if (daemonRadios.size() > 1) { radioPanel.add(daemonPanel); } } { final Panel typePanel = new VerticalPanel(); boolean wasChecked = false; for (final String type : types) { if (!UiBuilderClient.NONE_TYPE.equals(type)) { final RadioButton radio = new RadioButton("typeRadioGroup", "Create " + type + " module."); if (!wasChecked) { radio.setValue(true); wasChecked = true; } typePanel.add(radio); typeRadios.put(type, radio); } } if (typeRadios.size() > 1) { radioPanel.add(typePanel); } } // If the user has no choice, just do the job if (skipDisplay()) { okClicked(callback); return; } final Panel buttonPanel = new HorizontalPanel(); buttonPanel.add(okButton); buttonPanel.add(cancelButton); okButton.addClickHandler( new ClickHandler() { @Override public void onClick(final ClickEvent event) { okClicked(callback); } }); cancelButton.addClickHandler( new ClickHandler() { @Override public void onClick(final ClickEvent event) { hide(); } }); final Panel allPanel = new VerticalPanel(); allPanel.add(radioPanel); allPanel.add(buttonPanel); add(allPanel); }
private Component buildProfileTab() { HorizontalLayout root = new HorizontalLayout(); root.setCaption("Profile"); root.setIcon(FontAwesome.USER); root.setWidth(100.0f, Unit.PERCENTAGE); root.setSpacing(true); root.setMargin(true); root.addStyleName("profile-form"); VerticalLayout pic = new VerticalLayout(); pic.setSizeUndefined(); pic.setSpacing(true); Image profilePic = new Image(null, new ThemeResource("img/profile-pic-300px.jpg")); profilePic.setWidth(100.0f, Unit.PIXELS); pic.addComponent(profilePic); Button upload = new Button( "Changeā¦", event -> { Notification.show("Not implemented in this demo"); }); upload.addStyleName(ValoTheme.BUTTON_TINY); pic.addComponent(upload); root.addComponent(pic); FormLayout details = new FormLayout(); details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(details); root.setExpandRatio(details, 1); firstNameField = new TextField("First Name"); details.addComponent(firstNameField); lastNameField = new TextField("Last Name"); details.addComponent(lastNameField); titleField = new ComboBox("Title"); titleField.setInputPrompt("Please specify"); titleField.addItem("Mr."); titleField.addItem("Mrs."); titleField.addItem("Ms."); titleField.setNewItemsAllowed(true); details.addComponent(titleField); sexField = new OptionGroup("Sex"); sexField.addItem(Boolean.FALSE); sexField.setItemCaption(Boolean.FALSE, "Female"); sexField.addItem(Boolean.TRUE); sexField.setItemCaption(Boolean.TRUE, "Male"); sexField.addStyleName("horizontal"); details.addComponent(sexField); Label section = new Label("Contact Info"); section.addStyleName(ValoTheme.LABEL_H4); section.addStyleName(ValoTheme.LABEL_COLORED); details.addComponent(section); emailField = new TextField("Email"); emailField.setWidth("100%"); emailField.setRequired(true); emailField.setNullRepresentation(""); details.addComponent(emailField); locationField = new TextField("Location"); locationField.setWidth("100%"); locationField.setNullRepresentation(""); locationField.setComponentError(new UserError("This address doesn't exist")); details.addComponent(locationField); phoneField = new TextField("Phone"); phoneField.setWidth("100%"); phoneField.setNullRepresentation(""); details.addComponent(phoneField); newsletterField = new OptionalSelect<>(); newsletterField.addOption(0, "Daily"); newsletterField.addOption(1, "Weekly"); newsletterField.addOption(2, "Monthly"); details.addComponent(newsletterField); section = new Label("Additional Info"); section.addStyleName(ValoTheme.LABEL_H4); section.addStyleName(ValoTheme.LABEL_COLORED); details.addComponent(section); websiteField = new TextField("Website"); websiteField.setInputPrompt("http://"); websiteField.setWidth("100%"); websiteField.setNullRepresentation(""); details.addComponent(websiteField); bioField = new TextArea("Bio"); bioField.setWidth("100%"); bioField.setRows(4); bioField.setNullRepresentation(""); details.addComponent(bioField); return root; }
public static FormPanel getLoginPanel() { // Create a FormPanel and point it at a service. final FormPanel form = new FormPanel(); form.setAction("/loginFormHandler"); form.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. VerticalPanel panel = new VerticalPanel(); form.setWidget(panel); panel.setSpacing(20); final Label emailLabel = new Label("UnityID:"); final TextBox emailBox = new TextBox(); final Label passwordLabel = new Label("Password:"******"Log in", new ClickHandler() { public void onClick(ClickEvent event) { form.submit(); } }); panel.add(loginButton); Anchor signUpLabel = new Anchor("-- New User: Sign up --"); signUpLabel.addStyleName("gwt-RegisterAnchor"); panel.addStyleName("gwt-LoginPanel"); loginButton.addStyleName("gwt-LoginButton"); signUpLabel.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { RootPanel.get("leftnav").clear(); RootPanel.get("header").clear(); RootPanel.get("content").clear(); RootPanel.get("content").add(CustomWidgets.getRegisterForm()); final Label titleLabel = new Label("Register"); titleLabel.addStyleName("gwt-Heading"); RootPanel.get("header").add(titleLabel); } }); panel.add(signUpLabel); // Add an event handler to the form. form.addSubmitHandler( new FormPanel.SubmitHandler() { public void onSubmit(FormPanel.SubmitEvent event) { if (emailBox.getText().length() == 0 || passwordBox.getText().length() == 0) { Window.alert("Username and Password must not be empty"); rootLogger.log(Level.SEVERE, "LOGIN ATTEMPT FAIL"); event.cancel(); } } }); form.addSubmitCompleteHandler( new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) { final String userid = emailBox.getText(); String password = passwordBox.getText(); loginService.login( userid, password, new AsyncCallback<String>() { public void onFailure(Throwable caught) { rootLogger.log(Level.SEVERE, "LOGIN ATTEMPT FAIL"); } public void onSuccess(String result) { if (result.equals("success")) { RootPanel.get("leftnav").clear(); RootPanel.get("header").clear(); RootPanel.get("content").clear(); dbService.readUserData( "ssharm20", new AsyncCallback<HashMap<String, String>>() { public void onFailure(Throwable caught) { rootLogger.log(Level.SEVERE, "Failed reading data from server"); } public void onSuccess(HashMap<String, String> result) { RootPanel.get("content").add(CustomWidgets.getHomeDataForm(userid)); } }); RootPanel.get("leftnav").add(CustomWidgets.getNavBar(userid)); final Label titleLabel = new Label("Home"); titleLabel.addStyleName("gwt-Heading"); RootPanel.get("header").add(titleLabel); } else { Window.alert(result); rootLogger.log(Level.SEVERE, "LOGIN ATTEMPT FAIL"); } } }); } }); return form; }
public UpgradeConfirmWindow( final String version, String manualDownloadLink, final String installerFilePath) { super("A new update is ready to install"); this.setModal(true); this.setResizable(false); this.center(); this.setWidth("600px"); this.installerFilePath = installerFilePath; currentUI = UI.getCurrent(); MVerticalLayout content = new MVerticalLayout(); this.setContent(content); Div titleDiv = new Div().appendText(String.format(headerTemplate, version)).setStyle("font-weight:bold"); content.with(new Label(titleDiv.write(), ContentMode.HTML)); Div manualInstallLink = new Div() .appendText(" Manual install: ") .appendChild(new A(manualDownloadLink, "_blank").appendText("Download link")); content.with(new Label(manualInstallLink.write(), ContentMode.HTML)); Div releaseNoteLink = new Div() .appendText(" Release Notes: ") .appendChild( new A("https://community.mycollab.com/release-notes/", "_blank") .appendText("Link")); content.with(new Label(releaseNoteLink.write(), ContentMode.HTML)); MHorizontalLayout buttonControls = new MHorizontalLayout().withMargin(true); Button skipBtn = new Button( "Skip", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { UpgradeConfirmWindow.this.close(); } }); skipBtn.addStyleName(UIConstants.BUTTON_OPTION); Button autoUpgradeBtn = new Button( "Auto Upgrade", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { UpgradeConfirmWindow.this.close(); navigateToWaitingUpgradePage(); } }); if (installerFilePath == null) { autoUpgradeBtn.setEnabled(false); } autoUpgradeBtn.addStyleName(UIConstants.BUTTON_ACTION); buttonControls.with(skipBtn, autoUpgradeBtn); content.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT); }