List of usage examples for com.vaadin.ui VerticalLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:com.skysql.manager.ui.UsersSettings.java
License:Open Source License
/** * Removes the user./*from www. j a va 2s . 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./* www .j a v a 2s . c o 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.Game.java
public Game(int id, data d) { Notification.show("Game/Chat Created", Notification.Type.TRAY_NOTIFICATION); this.d = d;//from w ww . jav a2 s . com gameId = id; CheckForUpdate(); selfGame = p1 == p2; this.setId("GameForMe"); js.addFunction("sendMove", (e) -> { int clickPos = (int) e.getNumber(0); for (int i = 0; i < e.getArray(1).length(); i++) { int circle = (int) e.getArray(1).getArray(i).getNumber(0); int center = (int) e.getArray(1).getArray(i).getNumber(1); if (clickPos <= (center + 30) && clickPos >= (center - 30)) { //Logger.getLogger(Game.class.getName()).info("Played "+circle); boolean win = d.move(circle, (currentTurn == p1 ? p2 : p1), this.gameId); if (win == true) { /*Notification nn = new Notification("Game Over You Win","",Notification.Type.WARNING_MESSAGE); nn.setDelayMsec(5000); nn.show(Page.getCurrent());*/ js.execute("if(document.getElementById('GameForMe')!=null && " + "document.getElementById('GameForMe').hasChildNodes() &&" + "document.getElementById('GameForMe').lastChild.hasChildNodes()){" + "var bb = document.getElementsByTagName('svg')[0];" + "bb.parentNode.removeChild(bb);" + "}"); VerticalLayout winLayout = new VerticalLayout(); Label winMessage = new Label("<h1>Congratulations You Win!</h1>", ContentMode.HTML); Label winCloseMessage = new Label( "<h3>Game and Chat Tabs will stay open till next Login</h3>", ContentMode.HTML); Notification.show("Game Won", Notification.Type.TRAY_NOTIFICATION); winLayout.addComponent(winMessage); winLayout.addComponent(winCloseMessage); winLayout.setSizeFull(); winLayout.setMargin(true); winLayout.setSpacing(false); winLayout.setComponentAlignment(winMessage, Alignment.MIDDLE_CENTER); winLayout.setComponentAlignment(winCloseMessage, Alignment.MIDDLE_CENTER); this.addComponent(winLayout); this.setComponentAlignment(winLayout, Alignment.MIDDLE_CENTER); notDisp = true; //Logger.getLogger(Game.class.getName()).info("go win"); } currentTurn = currentTurn == p1 ? p2 : p1; rendered = false; break; } } }); /*this.addComponent(new Button("c",e->{ create(); //js.execute("hello();"); }));*/ this.setSizeFull(); }
From source file:com.snowy.Game.java
public void CheckForUpdate() { if (d.isGameActive(gameId) == 0) { ArrayList<ArrayList<Integer>> tempGameBoard = d.getGameBoard(gameId); if (!tempGameBoard.equals(gameBoard)) { hasUpdate = true;/*from w w w.ja v a 2 s . co m*/ gameBoard = tempGameBoard; p1 = d.getPlayerOne(gameId); p2 = d.getPlayerTwo(gameId); currentTurn = d.getLastTurn(gameId) == 0 ? p1 : d.getLastTurn(gameId); } //Logger.getLogger(Game.class.getName()).info(hasUpdate+"|"+this.isConnectorEnabled()+"|"+rendered+"|"+jj++); if (this.isConnectorEnabled() && hasUpdate) {//&& !rendered){ Update(); hasUpdate = false; //Logger.getLogger(Game.class.getName()).info("has update"); rendered = true; } else if (this.isConnectorEnabled() && !rendered) { Update(); //Logger.getLogger(Game.class.getName()).info("rendering"); this.rendered = true; } else if (!this.isConnectorEnabled() && rendered) { rendered = false; //Logger.getLogger(Game.class.getName()).info("mark as need to render"); } } else { //Logger.getLogger(Game.class.getName()).info("go lose"); if (this.isConnectorEnabled() && notDisp == false) { //Logger.getLogger(Game.class.getName()).info("go lose " +((d.getLastTurn(gameId)==p1?p2:p1))+" | "+d.getUserIdFromToken()); if ((d.getLastTurn(gameId) == p1 ? p2 : p1) != d.getUserIdFromToken()) { /*Notification nn = new Notification("Game Over You Lose","",Notification.Type.WARNING_MESSAGE); nn.setDelayMsec(5000); nn.show(Page.getCurrent());*/ js.execute("if(document.getElementById('GameForMe')!=null && " + "document.getElementById('GameForMe').hasChildNodes() &&" + "document.getElementById('GameForMe').lastChild.hasChildNodes()){" + "var bb = document.getElementsByTagName('svg')[0];" + "bb.parentNode.removeChild(bb);" + "}"); VerticalLayout loseLayout = new VerticalLayout(); Label loseMessage = new Label("<h1>Unfortunately You Have Lost</h1>", ContentMode.HTML); Label loseCloseMessage = new Label("<h3>Game and Chat Tabs will stay open till next Login</h3>", ContentMode.HTML); loseLayout.addComponent(loseMessage); loseLayout.addComponent(loseCloseMessage); loseLayout.setSizeFull(); loseLayout.setComponentAlignment(loseMessage, Alignment.MIDDLE_CENTER); Notification.show("Game Lost", Notification.Type.TRAY_NOTIFICATION); loseLayout.setComponentAlignment(loseCloseMessage, Alignment.MIDDLE_CENTER); loseLayout.setMargin(true); loseLayout.setSpacing(false); this.addComponent(loseLayout); this.setComponentAlignment(loseLayout, Alignment.MIDDLE_CENTER); //Logger.getLogger(Game.class.getName()).info("go lose"); notDisp = true; } } //n. } }
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. jav a2 s. com*/ 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 w w w .j a v a2 s . c o 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.EditVersionLayout.java
private void buildLayout() { HorizontalLayout knopki = new HorizontalLayout(save, cancel); knopki.setSizeUndefined();// w w w . j av a 2 s .c om 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 www . j a v a 2 s . co 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.studiodojo.qwikinvoice.ui.AboutWindow.java
License:Apache License
/** * //from ww w .j a v a 2s.c om */ public void init() { super.setCaption("About"); super.setModal(true); super.setWidth("600px"); super.setHeight("600px"); VerticalLayout layout = (VerticalLayout) this.getContent(); layout.setMargin(true); layout.setSpacing(true); layout.addComponent(new com.vaadin.ui.Label(ABOUT, Label.CONTENT_XHTML)); }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private void addLinkUserContainer() { VerticalLayout cDeletePrompt = new VerticalLayout(); cPlaceholder.addComponent(cDeletePrompt); cPlaceholder.setComponentAlignment(cDeletePrompt, Alignment.MIDDLE_CENTER); // cDeletePrompt.setWidth("100%"); cDeletePrompt.setStyleName("c_link"); cDeletePrompt.setSpacing(true); String username = curUser;//from w ww. j a v a 2 s . co m Label lbActivationPrompt = new Label( "<span style='text-align: center;'>Please enter Child Username to link to " + username + "'s Account</span>"); lbActivationPrompt.setContentMode(ContentMode.HTML); lbActivationPrompt.setWidth("300px"); lbActivationPrompt.setStyleName("lb_link_user"); cDeletePrompt.addComponent(lbActivationPrompt); cDeletePrompt.setComponentAlignment(lbActivationPrompt, Alignment.TOP_LEFT); VerticalLayout frmDeleteReason = new VerticalLayout(); frmDeleteReason.setSizeUndefined(); frmDeleteReason.setSpacing(true); frmDeleteReason.setMargin(true); cDeletePrompt.addComponent(frmDeleteReason); cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.TOP_CENTER); tFU = new TextField("Child Username"); tFU.setRequired(true); final ComboBox comboUProf = new ComboBox("Select Profile"); comboUProf.setNullSelectionAllowed(false); comboUProf.setRequired(true); comboUProf.addItem(8); comboUProf.setItemCaption(8, "DEPOSIT_ONLY"); comboUProf.addItem(9); comboUProf.setItemCaption(9, "DEPOSIT_AND_WITHDRAWAL"); comboUProf.select(8); final TextField tFP = new TextField("Parent Account ID"); tFP.setValue(username); tFP.setEnabled(false); final TextField tFInitUser = new TextField("Initiating User"); tFInitUser.setValue(UI.getCurrent().getSession().getAttribute("user").toString()); tFInitUser.focus(); tFInitUser.setEnabled(false); frmDeleteReason.addComponent(tFU); frmDeleteReason.addComponent(comboUProf); frmDeleteReason.addComponent(tFP); frmDeleteReason.addComponent(tFInitUser); HorizontalLayout cPopupBtns = new HorizontalLayout(); cPopupBtns.setSizeUndefined(); cPopupBtns.setSpacing(true); final Button btnCancel = new Button(); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName("btn_link"); btnCancel.setDescription("Cancel"); final Button btnSet = new Button("Link"); btnSet.setDescription("Link specified account."); btnSet.setIcon(FontAwesome.LINK); cPopupBtns.addComponent(btnSet); cPopupBtns.addComponent(btnCancel); frmDeleteReason.addComponent(cPopupBtns); cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.MIDDLE_CENTER); btnSet.setClickShortcut(KeyCode.ENTER, null); btnSet.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -6318666715385643538L; @Override public void buttonClick(ClickEvent event) { tFU.validate(); btnSet.setEnabled(false); btnCancel.setEnabled(false); Button btn = event.getButton(); if (ums == null) ums = new UserManagementService(); btn.setEnabled(false); String strResponse = null; try { strResponse = UserManagementService.linkUser(tFP.getValue(), new Integer(comboUProf.getValue().toString()), tFInitUser.getValue(), tFU.getValue()); if (strResponse.equals("The operation was successful and completed")) { updateLinksTable(tFU.getValue()); cPlaceholder.setVisible(false); tFU.setValue(""); btnLink.setVisible(true); NotifCustom.show("Link", strResponse); } else { NotifCustom.show("Link", strResponse); } } catch (RemoteException e) { e.printStackTrace(); } btnSet.setEnabled(true); btnCancel.setEnabled(true); } }); btnCancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 7161821652386306043L; @Override public void buttonClick(ClickEvent event) { btnLink.setVisible(true); cPlaceholder.setVisible(false); } }); }