List of usage examples for com.vaadin.ui Window center
public void center()
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleShowNumberCardsActionTL(MenuBar mbar) { Session session = HSess.get();/*from w w w. j a v a2 s . c om*/ Criteria criteria = session.createCriteria(Card.class); criteria.setProjection(Projections.rowCount()); int count = ((Long) criteria.list().get(0)).intValue(); // Create the window... Window countWin = new Window("Display Card Count"); countWin.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); countWin.setContent(layout); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Label lab; hl.addComponent(lab = new HtmlLabel("Number of cards played:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label countTf = new HtmlLabel(); countTf.setWidth("50px"); countTf.setValue(" " + count); countTf.addStyleName("m-greyborder"); hl.addComponent(countTf); hl.setComponentAlignment(countTf, Alignment.MIDDLE_LEFT); layout.addComponent(hl); countWin.setWidth("255px"); UI.getCurrent().addWindow(countWin); countWin.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleShowTotalRegisteredTL(MenuBar mbar) { Criteria criteria = HSess.get().createCriteria(User.class); criteria.setProjection(Projections.rowCount()); criteria.add(Restrictions.eq("accountDisabled", false)); int count = ((Long) criteria.list().get(0)).intValue(); criteria.add(Restrictions.eq("gameMaster", true)); int gmCount = ((Long) criteria.list().get(0)).intValue(); Criteria adminCrit = HSess.get().createCriteria(User.class); adminCrit.setProjection(Projections.rowCount()); adminCrit.add(Restrictions.eq("accountDisabled", false)); adminCrit.add(Restrictions.eq("administrator", true)); int adminCount = ((Long) adminCrit.list().get(0)).intValue(); // Create the window... Window countWin = new Window("Display Registered User Counts"); countWin.setModal(true);//from ww w. j a v a2 s .c om VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); countWin.setContent(layout); layout.addComponent(makeHL("Number of registered players:", count)); layout.addComponent(makeHL("Number of registered game masters:", gmCount)); layout.addComponent(makeHL("Number of registered game administrators:", adminCount)); layout.addComponent(makeHL("Total, excluding disabled accounts:", count + gmCount + adminCount)); countWin.setWidth("415px"); UI.getCurrent().addWindow(countWin); countWin.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleLoginLimitActionTL() { // Create the window... final Window loginWin = new Window("Change Session Login Limit"); loginWin.setModal(true);//from w w w .j a va 2 s . c o m VerticalLayout layout = new VerticalLayout(); loginWin.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(new Label("Max users to be logged in")); final TextField utf = new TextField(); utf.setColumns(10); final int oldVal = Game.getTL().getMaxUsersOnline(); utf.setValue("" + oldVal); hl.addComponent(utf); layout.addComponent(hl); HorizontalLayout buttHl = new HorizontalLayout(); // LLListener llis = new LLListener(loginWin); final Button cancelButt = new Button("Cancel"); buttHl.addComponent(cancelButt); final Button okButt = new Button("Save"); buttHl.addComponent(okButt); layout.addComponent(buttHl); layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT); layout.addComponent(new Label("Use with great deliberation!")); loginWin.setWidth("320px"); UI.getCurrent().addWindow(loginWin); loginWin.center(); @SuppressWarnings("serial") ClickListener llis = new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (event.getButton() == cancelButt) { } else if (event.getButton() == okButt) { HSess.init(); try { int i = Integer.parseInt(utf.getValue().toString()); Game g = Game.getTL(); g.setMaxUsersOnline(i); Game.updateTL(); GameEventLogger.logLoginLimitChangeTL(oldVal, i); } catch (Throwable t) { Notification.show("Error", "Invalid integer", Notification.Type.ERROR_MESSAGE); HSess.close(); return; } HSess.close(); } loginWin.close(); } }; cancelButt.addClickListener(llis); okButt.addClickListener(llis); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleDumpEmailsTL() { final TextField tf; final Window dialog = new Window("Filter Player Email Dump"); dialog.setModal(true);/*from ww w .j a v a 2 s.c o m*/ VerticalLayout layout = new VerticalLayout(); dialog.setContent(layout); layout.setMargin(true); layout.setSpacing(true); final OptionGroup radios = new OptionGroup(null, Arrays.asList(opts)); layout.addComponent(radios); layout.addComponent(tf = new MTextField().withWidth("50%")); tf.setCaption("value"); Label lab; layout.addComponent(lab = new Label()); lab.setHeight("10px"); radios.setNullSelectionAllowed(false); // user can not 'unselect' radios.select(allp); // select this by default radios.setImmediate(false); // don't send the change to the server at once radios.setMultiSelect(false); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); @SuppressWarnings("serial") Button cancelButt = new Button("Cancel", new Button.ClickListener() { public void buttonClick(ClickEvent event) { dialog.close(); } }); @SuppressWarnings("serial") Button addButt = new Button("Dump", new Button.ClickListener() { public void buttonClick(ClickEvent event) { Float val = null; String valS = ""; boolean parseError = false; try { val = Float.parseFloat(tf.getValue()); valS = formatter.valueToString(val); } catch (Exception ex) { parseError = true; } HSess.init(); Object sel = radios.getValue(); Criteria crit = null; String windowTitle = ""; boolean isExpl = true; if (sel == allp) { crit = HSess.get().createCriteria(User.class); windowTitle = new String("All users"); isExpl = true; if (parseError) { Notification.show("Value ignored", Notification.Type.WARNING_MESSAGE); System.out.println("Tried to show a Notification"); } } else if (sel == grex) { crit = getExplorationGreaterThanTL(val); windowTitle = "Users with exploration points greater than " + valS; isExpl = true; } else if (sel == lsex) { crit = getExplorationLessThanTL(val); windowTitle = "Users with exploration points less than " + valS; isExpl = true; } else if (sel == grim) { crit = getImplementationGreaterThanTL(val); windowTitle = "Users with implementation points greater than " + valS; isExpl = false; } else if (sel == lsim) { crit = getImplementationLessThanTL(val); windowTitle = "Users with implementation points less than " + valS; isExpl = false; } if (crit != null) { @SuppressWarnings("unchecked") List<User> lis = (List<User>) crit.list(); StringBuilder sb = new StringBuilder(); handleEmailListNoHeader(lis, sb, isExpl); String title = windowTitle + " - " + UUID.randomUUID(); BrowserWindowOpener.openWithInnerHTML(sb.toString(), title, "_blank"); } else { Notification.show("Invalid value", Notification.Type.ERROR_MESSAGE); HSess.close(); return; } dialog.close(); HSess.close(); } }); hl.addComponent(cancelButt); hl.addComponent(addButt); hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT); hl.setExpandRatio(cancelButt, 1.0f); layout.addComponent(hl); hl.setWidth("100%"); layout.addComponent(lab = new Label()); layout.setExpandRatio(lab, 1.0f); UI.getCurrent().addWindow(dialog); dialog.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleCreateActionPlanTL() { Object cardRootId = null;/*from w w w . j av a 2 s. c o m*/ Component c = Mmowgli2UI.getAppUI().getFrameContent(); if (c != null && c instanceof CardChainPage) cardRootId = ((CardChainPage) c).getCardId(); Window subWin = new CreateActionPlanWindow(null, cardRootId); UI.getCurrent().addWindow(subWin); subWin.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleCreateActionPlan(Button button, Object cardRootId) { Window subWin = new CreateActionPlanWindow(null, cardRootId); UI.getCurrent().addWindow(subWin);//ww w . j ava 2 s.co m subWin.center(); }
From source file:edu.nps.moves.mmowgli.components.MmowgliDialogContent.java
License:Open Source License
public static void throwUpDialog2() { Window w = new Window(); w.setClosable(false);/*from ww w . j a v a 2 s . c o m*/ w.setResizable(true); w.setStyleName("m-mmowglidialog2"); w.addStyleName("m-transparent"); // don't know why I need this, .mmowglidialog sets it too w.setWidth("600px"); w.setHeight("400px"); MmowgliDialogContent con = new MmowgliDialogContent(); w.setContent(con); con.setSizeFull(); con.initGui(); con.setTitleString("Yippee ki awol!"); UI.getCurrent().addWindow(w); w.center(); }
From source file:edu.nps.moves.mmowgli.components.SignupsTable.java
License:Open Source License
@SuppressWarnings("serial") public static void showDialog(String title) { final Button bulkMailButt = new Button("Initiate bulk mail job sending to filtered list"); final Button emailButt = new Button("Compose email"); emailButt.setDescription("Opens editing dialog to compose an email message to the selected individuals"); final Button displayButt = new Button("Display as plain text"); Button closeButt;/*from ww w .j a va2s. co m*/ final SignupsTable tab = new SignupsTable(null, null, new ValueChangeListener() // selected { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { emailButt.setEnabled(true); } }); final Window dialog = new Window(title); dialog.setWidth("950px"); dialog.setHeight("650px"); VerticalLayout vl = new VerticalLayout(); dialog.setContent(vl); vl.setSizeFull(); vl.setMargin(true); vl.setSpacing(true); addFilterCheckBoxes(vl); vl.addComponent(new Label("Individuals who have established game accounts are shown faintly")); tab.setSizeFull(); vl.addComponent(tab); vl.setExpandRatio(tab, 1.0f); HorizontalLayout buttHL = new HorizontalLayout(); buttHL.setSpacing(true); buttHL.addComponent(bulkMailButt); bulkMailButt.setImmediate(true); ; Label lab = new Label(""); buttHL.addComponent(lab); buttHL.setExpandRatio(lab, 1.0f); buttHL.addComponent(emailButt); emailButt.setImmediate(true); buttHL.addComponent(displayButt); displayButt.setImmediate(true); buttHL.addComponent(closeButt = new Button("Close")); closeButt.setImmediate(true); emailButt.setEnabled(false); closeButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { dialog.close(); } }); emailButt.addClickListener(new ClickListener() { @SuppressWarnings("rawtypes") @Override public void buttonClick(ClickEvent event) { HSess.init(); Set set = (Set) tab.getValue(); ArrayList<String> emails = new ArrayList<String>(set.size()); Iterator itr = set.iterator(); while (itr.hasNext()) { QueryWrapper wrap = (QueryWrapper) itr.next(); emails.add(wrap.getEmail()); } new SendMessageWindow(emails); HSess.close(); } }); displayButt.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { HSess.init(); dumpSignupsTL(); HSess.close(); } }); bulkMailButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { BulkMailHandler.showDialog((QueryContainer) tab.getContainerDataSource()); } }); vl.addComponent(buttHL); vl.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT); UI.getCurrent().addWindow(dialog); dialog.center(); }
From source file:edu.nps.moves.mmowgli.modules.administration.ScoringHelpWindow.java
License:Open Source License
public static void showTL(Game game) { Window win = new ScoringHelpWindow(game); UI.getCurrent().addWindow(win);/*from www. j a v a 2 s. c om*/ win.center(); }
From source file:edu.nps.moves.mmowgli.modules.administration.SessionReportWindow.java
License:Open Source License
public static void showSessionReport() { Window me = new SessionReportWindow("Active Players"); UI.getCurrent().addWindow(me);/*from w w w . j a v a 2s . c o m*/ me.center(); }