List of usage examples for com.vaadin.ui HorizontalLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:com.skysql.manager.ui.UsersSettings.java
License:Open Source License
/** * Removes the user.//from w ww. j a va 2 s . c o m * * @param event the event */ public void removeUser(Button.ClickEvent event) { secondaryDialog = new ModalWindow("Delete User", null); UI.getCurrent().addWindow(secondaryDialog); secondaryDialog.addCloseListener(this); final VerticalLayout formContainer = new VerticalLayout(); formContainer.setMargin(new MarginInfo(true, true, false, true)); formContainer.setSpacing(false); final Form form = new Form(); formContainer.addComponent(form); form.setFooter(null); form.setDescription("Delete user " + userInfo.completeNamesByID(selectedUserID) + " from the system"); HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Cancel"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { form.discard(); secondaryDialog.close(); } }); Button okButton = new Button("Delete User"); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { try { form.setComponentError(null); form.commit(); boolean success = userInfo.deleteUser(selectedUserID); if (success) { select.removeItem(selectedUserID); } else { return; } } catch (EmptyValueException e) { return; } catch (Exception e) { ManagerUI.error(e.getMessage()); return; } secondaryDialog.close(); } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(formContainer); windowLayout.addComponent(buttonsBar); }
From source file:com.skysql.manager.ui.WarningWindow.java
License:Open Source License
/** * Instantiates a new warning window./*from w ww . j a v a 2 s. co m*/ * * @param caption the caption * @param message the message * @param label the label * @param okListener the ok listener */ public WarningWindow(String caption, String message, String label, Button.ClickListener okListener) { super(caption, "60%"); HorizontalLayout wrapper = new HorizontalLayout(); wrapper.setWidth("100%"); wrapper.setMargin(true); VerticalLayout iconLayout = new VerticalLayout(); iconLayout.setWidth("100px"); wrapper.addComponent(iconLayout); Embedded image = new Embedded(null, new ThemeResource("img/warning.png")); iconLayout.addComponent(image); VerticalLayout textLayout = new VerticalLayout(); textLayout.setSizeFull(); wrapper.addComponent(textLayout); wrapper.setExpandRatio(textLayout, 1.0f); Label msgLabel = new Label(message); msgLabel.addStyleName("warning"); textLayout.addComponent(msgLabel); textLayout.setComponentAlignment(msgLabel, Alignment.MIDDLE_CENTER); HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Cancel"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(Button.ClickEvent event) { warningWindow.close(); } }); Button okButton = new Button(label); okButton.addClickListener(okListener); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) this.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.addComponent(buttonsBar); }
From source file:com.snowy.Login.java
@PostConstruct void init() {/* w w w.j av a 2s. co m*/ d = ((MyVaadinUI) UI.getCurrent()).getDataObject(); //Logger.getLogger(Login.class.getName()).info(d); this.setSizeFull(); this.setSpacing(false); this.setMargin(true); Label MainL = new Label("<h1>Connect 4</h1?>", ContentMode.HTML); //layout.addComponent(MainL); MainL.setSizeUndefined(); VerticalLayout lay = new VerticalLayout(); lay.setMargin(false); lay.addComponent(MainL); lay.setComponentAlignment(MainL, Alignment.TOP_CENTER); HorizontalLayout hz = new HorizontalLayout(); hz.setMargin(false); hz.setSpacing(false); LoginForm lf = new LoginForm(); lf.addLoginListener((e) -> { String token = d.genToken(e.getLoginParameter("username"), e.getLoginParameter("password")); //String token="true"; if (!token.equals("false")) { Cookie c = new Cookie("token", token); VaadinService.getCurrentResponse().addCookie(c); //https://vaadin.com/wiki/-/wiki/Main/Setting+and+reading+Cookies //Notification.show(VaadinService.getCurrentRequest().getCookies()[1].getValue(),Notification.Type.ERROR_MESSAGE); //this.getNavigator().navigateTo("main"); //this.getUI().get this.getUI().getNavigator().navigateTo("main"); } else { Label l = new Label("<h4 style=\"color:red\">Invalid Username or Password</h4>", ContentMode.HTML); l.setId("created"); if (lay.getComponent(lay.getComponentIndex(lf) + 1).getId() == null) { //lay.addComponent(new Label(String.valueOf(lay.getComponentIndex(l)))); lay.addComponent(l, lay.getComponentIndex(lf) + 1); l.setSizeUndefined(); lay.setComponentAlignment(l, Alignment.TOP_CENTER); } } }); lay.addComponent(lf); Button newUser = new Button("New User"); newUser.addClickListener((e) -> { this.getUI().addWindow(new NewUserSubWindow(d)); }); //newUser.setWidth((float)5.5, Unit.EM); Button forgotPass = new Button("Forgot Password"); //temp forgotPass.addClickListener((e) -> { //Notification.show(, Notification.Type.ERROR_MESSAGE); }); forgotPass.setEnabled(false); forgotPass.setDescription("Feature Disabled, Contact Administrator for Assistance"); //forgotPass.setWidth((float) 8.5,Unit.EM); forgotPass.setStyleName(ValoTheme.BUTTON_LINK); newUser.setStyleName(ValoTheme.BUTTON_LINK); hz.addComponent(newUser); hz.addComponent(forgotPass); lay.addComponent(hz); lay.setComponentAlignment(lf, Alignment.TOP_CENTER); lay.setComponentAlignment(hz, Alignment.MIDDLE_CENTER); this.addComponent(lay); this.setComponentAlignment(lay, Alignment.MIDDLE_CENTER); }
From source file:com.snowy.PostLoginView.java
@PostConstruct void init() {// w w w . j a v a2 s. c o m //Logger.getLogger(PostLoginView.class.getName()).info(d); d = ((MyVaadinUI) UI.getCurrent()).getDataObject(); //Logger.getLogger(PostLoginView.class.getName()).info(d); g = new GameWindow(d); c = new ChatWindow(d); HorizontalLayout hl = new HorizontalLayout(); setMargin(true); /*this.getUI().addPollListener(new UIEvents.PollListener(){ @Override public void poll(UIEvents.PollEvent event) { c.getUsersList().retrieveActiveUsers(); } });*/ this.setSizeFull(); Button b = new Button("Logout"); b.addClickListener(e -> { d.logout(VaadinSession.getCurrent().getCsrfToken()); VaadinSession.getCurrent().close(); Page.getCurrent().setLocation("/"); }); Button ccc = new Button("Unpause polling"); ccc.setEnabled(false); Button cc = new Button("Pause polling"); cc.addClickListener(e -> { if (ccc.isEnabled() == false) { UI.getCurrent().setPollInterval(1000000000); cc.setEnabled(false); ccc.setEnabled(true); } }); ccc.addClickListener(e -> { if (cc.isEnabled() == false) { UI.getCurrent().setPollInterval(1000); cc.setEnabled(true); ccc.setEnabled(false); } }); hl.setSizeFull(); hl.setSpacing(true); //whdjwandjawd //this.addComponent(cc); //this.addComponent(ccc); this.addComponent(b); //this.setHeightUndefined(); this.setSpacing(true); this.setComponentAlignment(b, Alignment.TOP_RIGHT); //this.addComponent(c); //this.addComponent(ul); hl.addComponent(g); hl.addComponent(c); //this.addComponent(c); hl.setExpandRatio(c, 1); hl.setExpandRatio(g, 3); g.setSizeFull(); c.setSizeFull(); this.addComponent(hl); //this.setExpandRatio(g, 2); this.setExpandRatio(hl, 1); }
From source file:com.snowy.Requests.java
public void updateRequests() { if (this.getComponentCount() > 0) { x = Integer.parseInt(this.getSelectedTab().getId().substring(3)); //Logger.getLogger(Requests.class.getName()).info(this.getSelectedTab().getId()); }//from ww w.java 2s .c om if (this.getComponentCount() < d.retriveChallenges().size()) { Notification.show("New Game Request", Notification.Type.TRAY_NOTIFICATION); } this.removeAllComponents(); ArrayList<ArrayList<String>> al = d.retriveChallenges(); int i = 0; for (ArrayList<String> ss : al) { VerticalLayout vl = new VerticalLayout(); HorizontalLayout hl = new HorizontalLayout(); if ((!d.getUsernameFromToken().equals(ss.get(0)) || (d.getUsernameFromToken().equals(ss.get(0)) && d.getUsernameFromToken().equals(ss.get(1)))) && Integer.parseInt(ss.get(3)) == 0) { vl.addComponent(new Label("You have been challenged by " + ss.get(0) + " on " + new java.sql.Timestamp(Long.parseLong(ss.get(2))).toString())); //Notification.show("New Game Reqest from "+ss.get(0), Notification.Type.TRAY_NOTIFICATION); hl.addComponent(new Button("Accept", ee -> { d.acceptRefuse(Integer.parseInt(ss.get(4)), true); })); hl.addComponent(new Button("Refuse", rr -> { d.acceptRefuse(Integer.parseInt(ss.get(4)), false); })); vl.addComponent(hl); } else { vl.addComponent(new Label("You challenged " + ss.get(1) + " on " + new java.sql.Timestamp(Long.parseLong(ss.get(2))).toString())); switch (Integer.parseInt(ss.get(3))) { case 0: vl.addComponent(new Label("Status: Awaiting Response")); break; case 1: PostLoginView plv = ((PostLoginView) this.getUI().getContent()); vl.addComponent(new Label("Status: Accepted")); plv.getGameWindow().initGame(ss.get(0), ss.get(1), Integer.parseInt(ss.get(4))); //Logger.getLogger(Requests.class.getName()).info(ss.get(4)); int gameId = d.getGameIdfromRequest(Integer.parseInt(ss.get(4))); if (plv.getGameWindow().gameIds().contains(gameId) != true && plv.getChatWindow().getChatIds().contains(gameId) != true) { plv.getChatWindow().addChat(gameId); //add game } //Logger.getLogger(Requests.class.getName()).info(plv.getGameWindow().gameIds().get(0)+" | "+ss.get(4)); break; case 2: vl.addComponent(new Label("Status: Refused")); break; } } vl.setSpacing(true); hl.setSpacing(true); vl.setMargin(true); vl.setId("set" + al.indexOf(ss)); this.addTab(vl, ss.get(0) + "\t" + new java.sql.Timestamp(Long.parseLong(ss.get(2))).toString()); //this.getTab(vl).setId("set"+i); i++; } this.setSelectedTab(x); }
From source file:com.snowy.UsersList.java
public UsersList(data d) { this.d = d;/*from ww w.j av a2s . co m*/ c.addContainerProperty("id", Integer.class, ""); retrieveActiveUsers(); //this.addItem("Chase"); //this.addItem("Cole"); //ll.addComponent(ll); //PopupView pop = new PopupView(null,ll); //pop.s //pop.addPopupVisibilityListener(e->{ // ll.addComponent(hl); //}); //TODO add the select listener ls.addValueChangeListener(e -> { if (e.getProperty().getValue() != null) { Window w = new Window("Confirm Challenge"); int id = Integer.parseInt(c.getItem(e.getProperty().getValue().toString()).getItemProperty("id") .getValue().toString()); String Username = e.getProperty().getValue().toString(); //Logger.getLogger(UsersList.class.getName()).info(Username); //Logger.getLogger(UsersList.class.getName()).info(id+""); VerticalLayout ll = new VerticalLayout(); VerticalLayout bb = new VerticalLayout(); HorizontalLayout hl = new HorizontalLayout(); Label la = new Label("Send challenge to " + Username + "?"); bb.addComponent(la); ll.addComponent(bb); ll.setSizeUndefined(); bb.setComponentAlignment(la, Alignment.MIDDLE_CENTER); ll.addComponent(hl); ll.setSpacing(true); ll.setMargin(new MarginInfo(true, true, false, true)); hl.setMargin(new MarginInfo(false, true, true, true)); hl.setSpacing(true); Button cancle = new Button("Cancel", b -> { w.close(); }); Button send = new Button("Send", c -> { if (d.sendChallenge(id)) { ll.removeAllComponents(); ll.addComponent(new Label("Challenge Sent Succesfully!")); ll.addComponent(new Button("Close", dd -> { w.close(); })); w.setCaption("Success"); ll.setSpacing(true); ll.setMargin(true); } else { ll.removeAllComponents(); ll.addComponent(new Label("Challenge Dend Failed")); ll.addComponent(new Button("Close", dd -> { w.close(); })); w.setCaption("Failure"); ll.setSpacing(true); ll.setMargin(true); } }); hl.addComponents(cancle, send); // this.addComponent(pop); // ll.addComponent(la); // pop.setPopupVisible(true); //w.setPosition(null, null); w.center(); w.setModal(true); w.setClosable(false); w.setResizable(false); w.setContent(ll); this.getUI().addWindow(w); } }); this.setSizeFull(); this.addStyleName("mine"); this.addComponent(ls); ls.setContainerDataSource(c); //ls.setContainerDataSource((Container) hm.keySet()); ls.setSizeFull(); ls.setImmediate(true); }
From source file:com.squadd.UI.EditInfoLayout.java
private void configureLayout() { addComponents(grName, place, date, descr); HorizontalLayout hor = new HorizontalLayout(cancel, submit); hor.setSpacing(true); addComponents(hor);/*from w ww.j a v a 2s. c o m*/ }
From source file:com.squadd.UI.EditVersionLayout.java
private void buildLayout() { HorizontalLayout knopki = new HorizontalLayout(save, cancel); knopki.setSizeUndefined();//w w w. ja va 2 s. c o m knopki.setSpacing(true); HorizontalLayout hor = new HorizontalLayout(knopki); hor.setWidth(0.4 * Display.width + "px"); hor.setComponentAlignment(knopki, Alignment.TOP_RIGHT); FormLayout data = new FormLayout(groupName, placeName, date, description); HorizontalLayout first = new HorizontalLayout(); groupPhoto.setWidth(0.2 * Display.width + "px"); groupPhoto.setHeight(0.2 * Display.width + "px"); first.addComponent(groupPhoto); VerticalLayout lst = new VerticalLayout(); lst.setSpacing(true); lst.addComponents(hor, data); HorizontalLayout uploadAndUsers = new HorizontalLayout(uploadPhoto); uploadAndUsers.setWidth(0.2 * Display.width + "px"); uploadPhoto.setSizeUndefined(); uploadAndUsers.setComponentAlignment(uploadPhoto, Alignment.MIDDLE_CENTER); VerticalLayout vert = new VerticalLayout(groupPhoto, uploadAndUsers); HorizontalLayout second = new HorizontalLayout(vert); HorizontalLayout photoAndInfo = new HorizontalLayout(second, lst); addComponent(photoAndInfo); }
From source file:com.squadd.UI.GroupMainInfoLayout.java
private void buildLayout() { HorizontalLayout knopki = new HorizontalLayout(edit); knopki.setSizeUndefined();//from w w w . ja v a 2 s. c o m knopki.setSpacing(true); HorizontalLayout hor = new HorizontalLayout(knopki); hor.setWidth(0.4 * Display.width + "px"); hor.setComponentAlignment(knopki, Alignment.TOP_RIGHT); description.setWidth(0.2 * Display.width + "px"); FormLayout data = new FormLayout(groupName, placeName, date, description); HorizontalLayout first = new HorizontalLayout(); groupPhoto.setWidth(0.2 * Display.width + "px"); groupPhoto.setHeight(0.2 * Display.width + "px"); first.addComponent(groupPhoto); HorizontalLayout seventh = new HorizontalLayout(); seventh.setWidth(0.2 * Display.width + "px"); seventh.addComponents(uploadPhoto); uploadPhoto.setSizeUndefined(); seventh.setComponentAlignment(uploadPhoto, Alignment.TOP_CENTER); VerticalLayout lst = new VerticalLayout(); lst.setSpacing(true); lst.addComponents(hor, data); VerticalLayout photoAndUpload = new VerticalLayout(first, seventh); HorizontalLayout photoAndInfo = new HorizontalLayout(photoAndUpload, lst); VerticalLayout content = new VerticalLayout(photoAndInfo); addComponent(content); }
From source file:com.squadd.UI.MessageLayout.java
private void configureLayout() { VerticalLayout all = new VerticalLayout(); HorizontalLayout dates = new HorizontalLayout(when); dates.setSpacing(true); when.setSizeUndefined();// w w w .ja va 2s .com Panel panel = new Panel(); panel.setWidth(Display.width * 0.3 + "px"); panel.setContent(text); groupPhoto.setWidth(Display.width * 0.05 + "px"); groupPhoto.setHeight(Display.height * 0.05 + "px"); HorizontalLayout other = new HorizontalLayout(groupPhoto, panel); all.addComponents(dates, other); Panel wrap = new Panel(); wrap.setContent(all); addComponent(wrap); }