List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:com.skysql.manager.ui.CalendarDialog.java
License:Open Source License
/** * Show delete popup.//from w ww . jav a2 s .c o m * * @param event the event */ private void showDeletePopup(final CalendarCustomEvent event) { if (event == null) { return; } VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); deleteSchedulePopup = new Window("Delete Recurring Event", layout); deleteSchedulePopup.setWidth("740px"); deleteSchedulePopup.setModal(true); deleteSchedulePopup.center(); deleteSchedulePopup.setContent(layout); deleteSchedulePopup.addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; public void windowClose(CloseEvent e) { UI.getCurrent().removeWindow(deleteSchedulePopup); } }); Label warning = new Label( "Do you want to delete the original event, or this and all future occurrences of the event, or only the selected occurrence?"); layout.addComponent(warning); Button cancel = new Button("Cancel", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(deleteSchedulePopup); } }); Button deleteAll = new Button("Delete Original Event", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent dummy) { String scheduleID = (String) event.getData(); Schedule.delete(scheduleID); schedule.getScheduleList().remove(scheduleID); ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID); for (CalendarCustomEvent removeEvent : eventsList) { if (dataSource.containsEvent(removeEvent)) { dataSource.removeEvent(removeEvent); } } UI.getCurrent().removeWindow(deleteSchedulePopup); UI.getCurrent().removeWindow(scheduleEventPopup); } }); Button deleteFuture = new Button("Delete All Future Events", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent dummy) { String scheduleID = (String) event.getData(); ScheduleRecord scheduleRecord = schedule.getScheduleList().get(scheduleID); VEvent vEvent = iCalSupport.readVEvent(scheduleRecord.getICal()); ManagerUI.log("before Delete All Future Events\n" + vEvent); iCalSupport.deleteAllFuture(vEvent, event.getStart()); ManagerUI.log("after Delete All Future Events\n" + vEvent); scheduleRecord.setICal(vEvent.toString()); Schedule.update(scheduleID, vEvent.toString()); ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID); for (CalendarCustomEvent removeEvent : eventsList) { if (dataSource.containsEvent(removeEvent)) { dataSource.removeEvent(removeEvent); } } schedule.getScheduleList().put(scheduleID, scheduleRecord); addEventsToMap(scheduleID, vEvent, event.getNode()); eventsList = eventsMap.get(scheduleID); for (CalendarCustomEvent addEvent : eventsList) { if (!dataSource.containsEvent(addEvent)) { dataSource.addEvent(addEvent); } } UI.getCurrent().removeWindow(deleteSchedulePopup); UI.getCurrent().removeWindow(scheduleEventPopup); } }); Button deleteSelected = new Button("Delete Only This Event", new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent dummy) { String scheduleID = (String) event.getData(); ScheduleRecord scheduleRecord = schedule.getScheduleList().get(scheduleID); VEvent vEvent = iCalSupport.readVEvent(scheduleRecord.getICal()); ManagerUI.log("before Exclude\n" + vEvent); iCalSupport.addExcludedDate(vEvent, event.getStart()); ManagerUI.log("after Exclude\n" + vEvent); scheduleRecord.setICal(vEvent.toString()); Schedule.update(scheduleID, vEvent.toString()); ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID); for (CalendarCustomEvent removeEvent : eventsList) { if (dataSource.containsEvent(removeEvent)) { dataSource.removeEvent(removeEvent); } } schedule.getScheduleList().put(scheduleID, scheduleRecord); addEventsToMap(scheduleID, vEvent, event.getNode()); eventsList = eventsMap.get(scheduleID); for (CalendarCustomEvent addEvent : eventsList) { if (!dataSource.containsEvent(addEvent)) { dataSource.addEvent(addEvent); } } UI.getCurrent().removeWindow(deleteSchedulePopup); UI.getCurrent().removeWindow(scheduleEventPopup); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(cancel); buttons.addComponent(deleteAll); buttons.addComponent(deleteFuture); buttons.addComponent(deleteSelected); deleteSelected.focus(); layout.addComponent(buttons); layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT); if (!UI.getCurrent().getWindows().contains(deleteSchedulePopup)) { UI.getCurrent().addWindow(deleteSchedulePopup); } }
From source file:com.skysql.manager.ui.ChartsDialog.java
License:Open Source License
/** * Instantiates a new charts dialog.//from www . ja va2 s . com * * @param chartsLayout the charts layout * @param chartButton the chart button */ public ChartsDialog(final ChartsLayout chartsLayout, final ChartButton chartButton) { this.chartButton = chartButton; this.chartsLayout = chartsLayout; dialogWindow = new ModalWindow("Monitors to Chart mapping", "775px"); HorizontalLayout wrapper = new HorizontalLayout(); //wrapper.setWidth("100%"); wrapper.setMargin(true); UI.getCurrent().addWindow(dialogWindow); newUserChart = (chartButton != null) ? new UserChart((UserChart) chartButton.getData()) : newUserChart(); ArrayList<String> monitorIDs = newUserChart.getMonitorIDs(); MonitorsLayout monitorsLayout = new MonitorsLayout(monitorIDs); wrapper.addComponent(monitorsLayout); VerticalLayout separator = new VerticalLayout(); separator.setSizeFull(); Embedded rightArrow = new Embedded(null, new ThemeResource("img/right_arrow.png")); separator.addComponent(rightArrow); separator.setComponentAlignment(rightArrow, Alignment.MIDDLE_CENTER); wrapper.addComponent(separator); ChartPreviewLayout chartPreviewLayout = new ChartPreviewLayout(newUserChart, chartsLayout.getTime(), chartsLayout.getInterval()); wrapper.addComponent(chartPreviewLayout); monitorsLayout.addChartPreview(chartPreviewLayout); 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) { dialogWindow.close(); } }); Button okButton = new Button(chartButton != null ? "Save Changes" : "Add Chart"); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { try { ChartButton newChartButton = new ChartButton(newUserChart); newChartButton.setChartsLayout(chartsLayout); newChartButton.setEditable(true); if (chartButton != null) { chartsLayout.replaceComponent(chartButton, newChartButton); } else { chartsLayout.addComponent(newChartButton); } } catch (Exception e) { ManagerUI.error(e.getMessage()); } dialogWindow.close(); } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.addComponent(buttonsBar); }
From source file:com.skysql.manager.ui.components.ScriptingProgressLayout.java
License:Open Source License
/** * Builds the progress./*from ww w . j a v a2 s . c o m*/ * * @param taskRecord the task record * @param command the command * @param steps the steps */ public void buildProgress(TaskRecord taskRecord, String command, String steps) { VaadinSession session = getSession(); if (session == null) { session = VaadinSession.getCurrent(); } if (observerMode) { // String userName = Users.getUserNames().get(taskRecord.getUser()); String userID = taskRecord.getUserID(); UserInfo userInfo = (UserInfo) session.getAttribute(UserInfo.class); DateConversion dateConversion = session.getAttribute(DateConversion.class); setTitle(command + " was started on " + dateConversion.adjust(taskRecord.getStart()) + " by " + userID); } else { setTitle(command); } String[] stepIDs; try { stepIDs = steps.split(","); } catch (NullPointerException npe) { stepIDs = new String[] {}; } totalSteps = stepIDs.length; primitives = new String[totalSteps]; taskImages = new Embedded[totalSteps]; // add steps icons progressIconsLayout.removeAllComponents(); for (int index = 0; index < totalSteps; index++) { String stepID = stepIDs[index].trim(); String description = Steps.getDescription(stepID); VerticalLayout stepLayout = new VerticalLayout(); progressIconsLayout.addComponent(stepLayout); stepLayout.addStyleName("stepIcons"); Label name = new Label(stepID); stepLayout.addComponent(name); stepLayout.setComponentAlignment(name, Alignment.MIDDLE_CENTER); Embedded image = new Embedded(null, new ThemeResource("img/scripting/pending.png")); image.setImmediate(true); image.setDescription(description); stepLayout.addComponent(image); primitives[index] = stepID; taskImages[index] = image; } setProgress(""); }
From source file:com.skysql.manager.ui.ErrorDialog.java
License:Open Source License
/** * Instantiates a new error dialog./*from w w w . j a va 2 s .com*/ * * @param e the exception * @param humanizedError the humanized error */ public ErrorDialog(Exception e, String humanizedError) { if (e != null) { ManagerUI.error(e.getMessage()); } dialogWindow = new ModalWindow("An Error has occurred", "775px"); dialogWindow.setHeight("340px"); dialogWindow.addCloseListener(this); UI current = UI.getCurrent(); if (current.getContent() == null) { current.setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null)); } current.addWindow(dialogWindow); HorizontalLayout wrapper = new HorizontalLayout(); wrapper.setSizeFull(); wrapper.setMargin(true); VerticalLayout iconLayout = new VerticalLayout(); iconLayout.setWidth("100px"); wrapper.addComponent(iconLayout); Embedded image = new Embedded(null, new ThemeResource("img/error.png")); iconLayout.addComponent(image); VerticalLayout textLayout = new VerticalLayout(); textLayout.setHeight("100%"); textLayout.setSpacing(true); wrapper.addComponent(textLayout); wrapper.setExpandRatio(textLayout, 1.0f); if (humanizedError != null || e != null) { String error = (humanizedError != null) ? humanizedError : e.toString(); ManagerUI.error(error); Label label = new Label(error, ContentMode.HTML); label.addStyleName("warning"); textLayout.addComponent(label); textLayout.setComponentAlignment(label, Alignment.TOP_CENTER); } if (e != null) { TextArea stackTrace = new TextArea("Error Log"); stackTrace.setSizeFull(); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); stackTrace.setValue(sw.toString()); textLayout.addComponent(stackTrace); textLayout.setComponentAlignment(stackTrace, Alignment.TOP_LEFT); textLayout.setExpandRatio(stackTrace, 1.0f); } 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("Close"); 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) { dialogWindow.close(); //UI.getCurrent().close(); } }); Button okButton = new Button("Send Error"); okButton.setEnabled(false); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { dialogWindow.close(); } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent(); windowLayout.setHeight("100%"); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(wrapper); windowLayout.setExpandRatio(wrapper, 1.0f); windowLayout.addComponent(buttonsBar); }
From source file:com.skysql.manager.ui.LoginView.java
License:Open Source License
/** * Instantiates a new login view.//w ww. ja v a 2s. c o m * * @param aboutRecord the about record */ public LoginView() { setSizeFull(); setMargin(true); setSpacing(true); addStyleName("loginView"); VerticalLayout logoLayout = new VerticalLayout(); addComponent(logoLayout); setComponentAlignment(logoLayout, Alignment.BOTTOM_CENTER); setExpandRatio(logoLayout, 1.0f); Embedded logo = new Embedded(null, new ThemeResource("img/loginlogo.png")); logoLayout.addComponent(logo); logoLayout.setComponentAlignment(logo, Alignment.BOTTOM_CENTER); Label releaseInfo = new Label("Version " + ManagerUI.GUI_RELEASE); releaseInfo.setSizeUndefined(); releaseInfo.addStyleName("releaseInfo"); logoLayout.addComponent(releaseInfo); logoLayout.setComponentAlignment(releaseInfo, Alignment.TOP_CENTER); VerticalLayout spacer = new VerticalLayout(); spacer.setHeight("20px"); logoLayout.addComponent(spacer); VerticalLayout loginBox = new VerticalLayout(); loginBox.addStyleName("loginBox"); loginBox.setSizeUndefined(); loginBox.setMargin(true); loginBox.setSpacing(true); addComponent(loginBox); setComponentAlignment(loginBox, Alignment.MIDDLE_CENTER); VerticalLayout loginFormLayout = new VerticalLayout(); loginFormLayout.addStyleName("loginForm"); loginFormLayout.setMargin(true); loginFormLayout.setSpacing(true); loginBox.addComponent(loginFormLayout); // userName.focus(); userName.setStyleName("loginControl"); userName.setInputPrompt("Username"); userName.setImmediate(true); userName.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { password.focus(); login.setClickShortcut(KeyCode.ENTER); } }); loginFormLayout.addComponent(userName); loginFormLayout.setComponentAlignment(userName, Alignment.MIDDLE_CENTER); // spacer loginFormLayout.addComponent(new Label("")); password.setStyleName("loginControl"); password.setInputPrompt("Password"); password.setImmediate(true); password.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { login.focus(); } }); loginFormLayout.addComponent(password); loginFormLayout.setComponentAlignment(password, Alignment.MIDDLE_CENTER); // spacer loginFormLayout.addComponent(new Label(" ")); login.setStyleName("loginControl"); login.setEnabled(false); loginFormLayout.addComponent(login); loginFormLayout.setComponentAlignment(login, Alignment.BOTTOM_CENTER); VerticalLayout filler = new VerticalLayout(); addComponent(filler); setExpandRatio(filler, 1.0f); preload(); }
From source file:com.skysql.manager.ui.PanelTools.java
License:Open Source License
/** * Instantiates a new panel tools./*from w w w . j a v a 2s . c o m*/ */ PanelTools() { // thisTab.setSizeFull(); // thisTab.setWidth(Sizeable.SIZE_UNDEFINED, 0); // Default setHeight("200px"); setSpacing(true); // External Tools Vertical Module SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class); LinkedHashMap<String, String> properties = systemInfo.getCurrentSystem().getProperties(); if (properties != null) { VerticalLayout externalsLayout = new VerticalLayout(); externalsLayout.setWidth("150px"); externalsLayout.addStyleName("externalsLayout"); externalsLayout.setSpacing(true); String EIP = properties.get(SystemInfo.PROPERTY_EIP); String MONyog = properties.get(SystemInfo.PROPERTY_MONYOG); if (EIP != null && MONyog != null) { String url = "http://" + EIP + MONyog; monyogLink = new Link("MONyog", new ExternalResource(url)); monyogLink.setTargetName("_blank"); monyogLink.setDescription("Open MONyog for the whole system"); monyogLink.setIcon(new ThemeResource("img/externalLink.png")); monyogLink.addStyleName("icon-after-caption"); externalsLayout.addComponent(monyogLink); externalsLayout.setComponentAlignment(monyogLink, Alignment.BOTTOM_CENTER); } phpUrl = properties.get(SystemInfo.PROPERTY_PHPMYADMIN); if (phpUrl != null) { phpLink = new Link("phpMyAdmin", null); phpLink.setTargetName("_blank"); phpLink.setDescription("Open phpMyAdmin for the selected node"); phpLink.setIcon(new ThemeResource("img/externalLink.png")); phpLink.addStyleName("icon-after-caption"); externalsLayout.addComponent(phpLink); externalsLayout.setComponentAlignment(phpLink, Alignment.BOTTOM_CENTER); } addComponent(externalsLayout); setComponentAlignment(externalsLayout, Alignment.MIDDLE_CENTER); } { Label spacer = new Label(); spacer.setWidth("40px"); addComponent(spacer); } // Scripting layout placeholder VerticalLayout placeholderLayout = new VerticalLayout(); placeholderLayout.addStyleName("placeholderLayout"); placeholderLayout.setSizeUndefined(); Label placeholderLabel = new Label("Links to external tools"); placeholderLabel.addStyleName("instructions"); placeholderLayout.addComponent(placeholderLabel); addComponent(placeholderLayout); setComponentAlignment(placeholderLayout, Alignment.MIDDLE_CENTER); }
From source file:com.skysql.manager.ui.WarningWindow.java
License:Open Source License
/** * Instantiates a new warning window./*from ww w .j a v a 2 s. 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 w w .ja va 2s .c o m*/ 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 ww w . j a v a 2 s . c om 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 www. j a v a2 s .c o 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); }