List of usage examples for com.vaadin.ui Alignment MIDDLE_CENTER
Alignment MIDDLE_CENTER
To view the source code for com.vaadin.ui Alignment MIDDLE_CENTER.
Click Source Link
From source file:com.skysql.manager.ui.TopPanel.java
License:Open Source License
/** * Instantiates a new top panel.//from w ww . j a v a2 s. c o m */ public TopPanel() { setSpacing(true); addStyleName("titleLayout"); setWidth("100%"); Embedded logo = new Embedded(null, new ThemeResource("img/productlogo.png")); addComponent(logo); setComponentAlignment(logo, Alignment.BOTTOM_LEFT); // LINKS AREA (TOP-RIGHT) HorizontalLayout userSettingsLayout = new HorizontalLayout(); userSettingsLayout.setSizeUndefined(); userSettingsLayout.setSpacing(true); addComponent(userSettingsLayout); setComponentAlignment(userSettingsLayout, Alignment.MIDDLE_RIGHT); // User icon and name VerticalLayout userLayout = new VerticalLayout(); userSettingsLayout.addComponent(userLayout); userSettingsLayout.setComponentAlignment(userLayout, Alignment.BOTTOM_CENTER); UserObject userObject = VaadinSession.getCurrent().getAttribute(UserObject.class); String name = userObject.getAnyName(); userName = new Label("Welcome, " + name); userName.setSizeUndefined(); userLayout.addComponent(userName); // buttons HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSizeUndefined(); buttonsLayout.setSpacing(true); userSettingsLayout.addComponent(buttonsLayout); userSettingsLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_CENTER); // Settings button SettingsDialog settingsDialog = new SettingsDialog("Settings"); Button settingsButton = settingsDialog.getButton(); buttonsLayout.addComponent(settingsButton); buttonsLayout.setComponentAlignment(settingsButton, Alignment.MIDDLE_CENTER); // Logout Button logoutButton = new Button("Logout"); logoutButton.setSizeUndefined(); buttonsLayout.addComponent(logoutButton); buttonsLayout.setComponentAlignment(logoutButton, Alignment.MIDDLE_CENTER); logoutButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { UI.getCurrent().getPage().setLocation(""); UI.getCurrent().close(); getSession().setAttribute(UserObject.class, null); getSession().close(); } }); }
From source file:com.skysql.manager.ui.UsersSettings.java
License:Open Source License
/** * Instantiates a new users settings.//from w ww . jav a2 s .c o m */ UsersSettings() { addStyleName("usersTab"); setSizeFull(); setSpacing(true); setMargin(true); UserObject currentUser = VaadinSession.getCurrent().getAttribute(UserObject.class); currentUserID = currentUser.getUserID(); HorizontalLayout usersLayout = new HorizontalLayout(); addComponent(usersLayout); usersLayout.setSizeFull(); usersLayout.setSpacing(true); // make sure we're working with current info userInfo = new UserInfo(null); VaadinSession.getCurrent().setAttribute(UserInfo.class, userInfo); select = new ListSelect("Users"); select.setImmediate(true); for (UserObject user : userInfo.getUsersList().values()) { String id = user.getUserID(); select.addItem(id); if (id.equals(currentUserID)) { select.select(id); userName.setValue(user.getName()); selectedUserID = id; } } select.setNullSelectionAllowed(false); select.setWidth("14em"); usersLayout.addComponent(select); select.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { selectedUserID = (String) event.getProperty().getValue(); if (selectedUserID == null || selectedUserID.equals(currentUserID)) { removeUser.setEnabled(false); } else { removeUser.setEnabled(true); } if (selectedUserID == null) { editUser.setEnabled(false); userName.setEnabled(false); userName.setValue(""); } else { editUser.setEnabled(true); userName.setValue(userInfo.findNameByID(selectedUserID)); userName.setEnabled(true); } } }); usersLayout.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void layoutClick(LayoutClickEvent event) { Component child; if (event.isDoubleClick() && (child = event.getChildComponent()) != null && (child instanceof ListSelect)) { // Get the child component which was double-clicked ListSelect select = (ListSelect) child; String userID = (String) select.getValue(); new UserDialog(userInfo, userInfo.getUsersList().get(selectedUserID), thisObject); } } }); userLayout = new FormLayout(); usersLayout.addComponent(userLayout); usersLayout.setExpandRatio(userLayout, 1.0f); userLayout.setSpacing(false); userName.setCaption("Full Name:"); userLayout.addComponent(userName); HorizontalLayout userButtonsLayout = new HorizontalLayout(); userButtonsLayout.setSpacing(true); addComponent(userButtonsLayout); Button addUser = new Button("Add..."); addUser.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { new UserDialog(userInfo, null, thisObject); } }); userButtonsLayout.addComponent(addUser); userButtonsLayout.setComponentAlignment(addUser, Alignment.MIDDLE_LEFT); removeUser = new Button("Delete"); removeUser.setEnabled(false); removeUser.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { removeUser(event); } }); userButtonsLayout.addComponent(removeUser); userButtonsLayout.setComponentAlignment(removeUser, Alignment.MIDDLE_LEFT); editUser = new Button("Edit..."); editUser.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { new UserDialog(userInfo, userInfo.getUsersList().get(selectedUserID), thisObject); } }); userButtonsLayout.addComponent(editUser); userButtonsLayout.setComponentAlignment(editUser, Alignment.MIDDLE_CENTER); }
From source file:com.skysql.manager.ui.WarningWindow.java
License:Open Source License
/** * Instantiates a new warning window.//from www .j a va 2s. com * * @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. j a va2 s .c om 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 ww . j av a2 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.Login.java
@PostConstruct void init() {/*from w w w . j av a 2 s .c om*/ 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.UsersList.java
public UsersList(data d) { this.d = d;//from w w w .ja v a2s. 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 ww . ja va 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.swifta.mats.web.usermanagement.AddUserModule.java
public VerticalLayout aumModifier(HorizontalLayout contentC) { contentC.removeAllComponents();/*from w ww . j a v a2s . co m*/ VerticalLayout uf = getAddUserForm(); contentC.addComponent(uf); contentC.setComponentAlignment(uf, Alignment.MIDDLE_CENTER); contentC.setSpacing(false); contentC.setMargin(true); contentC.setSizeFull(); return uf; }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
public VerticalLayout getUserDetailsContainer(String strUID, String strAction, Window pop, Object xrid, IndexedContainer xcontainer) {//from ww w . j av a 2s . c om this.xrid = xrid; this.xcontainer = xcontainer; curUser = strUID; cpop = pop; cUDetails = new VerticalLayout(); cUDetails.setMargin(new MarginInfo(false, false, false, false)); cUDetails.setStyleName("c_u_details"); cUDetails.setSizeFull(); VerticalLayout cCHeader = new VerticalLayout(); cCHeader.setSizeUndefined(); cCHeader.setStyleName("c_c_header"); cCHeader.setMargin(new MarginInfo(false, true, false, false)); String strCHeader; if (boolEditStatus) { strCHeader = "Edit Details of " + strUID; } else { strCHeader = "Showing Details of " + strUID; } Label lbCHeader = new Label(strCHeader); lbCHeader.setStyleName("label_c_header"); lbCHeader.setSizeUndefined(); cCHeader.addComponent(lbCHeader); cPerAccAuthInfo = new HorizontalLayout(); cPerAccAuthInfo.setStyleName("c_per_acc_auth_info"); cPerAccAuthInfo.setSizeUndefined(); VerticalLayout cTabLike = null; cTabLike = getManageUserMenu(); cTabLike.setSizeUndefined(); cCHeader.addComponent(cTabLike); cUDetails.addComponent(cCHeader); cUDetails.setComponentAlignment(cCHeader, Alignment.MIDDLE_CENTER); cUDetails.addComponent(cPerAccAuthInfo); cUDetails.setComponentAlignment(cPerAccAuthInfo, Alignment.MIDDLE_CENTER); // cUDetails.setExpandRatio(cPerAccAuthInfo, 1.0f); HorizontalLayout cUDetailsAndOperations = setDetailsForm(strUID, strAction); cP = cUDetailsAndOperations; cPerAccAuthInfo.addComponent(cUDetailsAndOperations); return cUDetails; }