List of usage examples for com.vaadin.ui Window setContent
@Override public void setContent(Component content)
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
void handleShowActiveUsersActionTL(MenuBar menubar) { Session session = HSess.get();//from ww w. j ava 2 s .c om Criteria criteria = session.createCriteria(User.class); criteria.setProjection(Projections.rowCount()); criteria.add(Restrictions.eq("accountDisabled", false)); int totcount = ((Long) criteria.list().get(0)).intValue(); // new and improved int count = Mmowgli2UI.getGlobals().getSessionCount(); Window countWin = new Window("Display Active User 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 users* (including yourself)<br/>currently playing:")); 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); layout.addComponent(new Label("* Count incremented on login, decremented on timeout or logout.")); hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(lab = new HtmlLabel("Total registered users:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label totalLab = new HtmlLabel(); totalLab.setWidth("50px"); totalLab.setValue(" " + totcount); totalLab.addStyleName("m-greyborder"); hl.addComponent(totalLab); hl.setComponentAlignment(totalLab, Alignment.MIDDLE_LEFT); layout.addComponent(hl); countWin.setWidth("325px"); UI.getCurrent().addWindow(countWin); countWin.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
private void _postGameEvent(String title, final GameEvent.EventType typ, String buttName, boolean doWarning, MenuBar mbar) {//from ww w . j ava 2s . c o m // Create the window... final Window bcastWindow = new Window(title); bcastWindow.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); bcastWindow.setContent(layout); layout.addComponent(new Label("Compose message (255 char limit):")); final TextArea ta = new TextArea(); ta.setRows(5); ta.setWidth("99%"); layout.addComponent(ta); HorizontalLayout buttHl = new HorizontalLayout(); final Button bcancelButt = new Button("Cancel"); buttHl.addComponent(bcancelButt); Button bokButt = new Button(buttName); bokButt.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttHl.addComponent(bokButt); layout.addComponent(buttHl); layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT); if (doWarning) layout.addComponent(new Label("Use with great deliberation!")); bcastWindow.setWidth("320px"); UI.getCurrent().addWindow(bcastWindow); bcastWindow.setPositionX(0); bcastWindow.setPositionY(0); ta.focus(); @SuppressWarnings("serial") ClickListener lis = new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { if (event.getButton() == bcancelButt) ; // nothin else { // This check is now done in GameEvent.java, but should ideally prompt the user. String msg = ta.getValue().toString().trim(); if (msg.length() > 0) { HSess.init(); if (msg.length() > 255) // clamp to 255 to avoid db exception msg = msg.substring(0, 254); User u = Mmowgli2UI.getGlobals().getUserTL(); if (typ == GameEvent.EventType.GAMEMASTERNOTE) GameEventLogger.logGameMasterCommentTL(msg, u); else GameEventLogger.logGameMasterBroadcastTL(typ, msg, u); HSess.close(); } } bcastWindow.close(); } }; bcancelButt.addClickListener(lis); bokButt.addClickListener(lis); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleShowNumberCardsActionTL(MenuBar mbar) { Session session = HSess.get();/*w ww . ja v a 2s . com*/ 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);/* ww w . j a v a2 s . c o m*/ 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 v a 2 s . co 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 av a 2s. c om 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.components.MmowgliDialogContent.java
License:Open Source License
public static void throwUpDialog2() { Window w = new Window(); w.setClosable(false);/*w w w. j a v a2s. 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;// w w w. j a va2s . c o 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.export.BaseExporter.java
License:Open Source License
protected void getMetaStringOrCancel(final MetaListener lis, String title, final Map<String, String> params) { final Window dialog = new Window(title); final TextField[] parameterFields; dialog.setModal(true);//w w w .j ava 2 s.c o m VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); dialog.setContent(layout); final TextArea ta = new TextArea(); ta.setWidth("100%"); ta.setInputPrompt("Type a description of this data, or the game which generated this data (optional)"); ta.setImmediate(true); layout.addComponent(ta); Set<String> keySet = params.keySet(); parameterFields = new TextField[keySet.size()]; int i = 0; GridLayout pGL = new GridLayout(); pGL.addStyleName("m-greyborder"); pGL.setColumns(2); Label hdr = new HtmlLabel("<b>Parameters</b>"); hdr.addStyleName("m-textaligncenter"); pGL.addComponent(hdr, 0, 0, 1, 0); // top row pGL.setComponentAlignment(hdr, Alignment.MIDDLE_CENTER); pGL.setSpacing(false); for (String key : keySet) { pGL.addComponent(new HtmlLabel(" " + key + " ")); pGL.addComponent(parameterFields[i] = new TextField()); parameterFields[i++].setValue(params.get(key)); } if (i > 0) { layout.addComponent(pGL); layout.setComponentAlignment(pGL, Alignment.TOP_CENTER); } HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); @SuppressWarnings("serial") Button cancelButt = new Button("Cancel", new Button.ClickListener() { public void buttonClick(ClickEvent event) { dialog.close(); lis.continueOrCancel(null); } }); @SuppressWarnings("serial") Button exportButt = new Button("Export", new Button.ClickListener() { public void buttonClick(ClickEvent event) { dialog.close(); Set<String> keySet = params.keySet(); int i = 0; for (String key : keySet) params.put(key, parameterFields[i++].getValue().toString()); lis.continueOrCancel(ta.getValue().toString()); } }); hl.addComponent(cancelButt); hl.addComponent(exportButt); hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT); hl.setExpandRatio(cancelButt, 1.0f); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.addComponent(hl); dialog.setWidth("385px"); dialog.setHeight("310px"); hl.setWidth("100%"); ta.setWidth("100%"); ta.setHeight("100%"); layout.setExpandRatio(ta, 1.0f); UI.getCurrent().addWindow(dialog); }
From source file:edu.nps.moves.mmowgli.MmowgliMessageBroadcaster.java
License:Open Source License
private static void _postGameEvent(String title, final GameEvent.EventType typ, String buttName, boolean doWarning) { // Create the window... final Window bcastWindow = new Window(title); bcastWindow.setModal(true);/* w ww. j ava 2s . c o m*/ VerticalLayout layout = new VerticalLayout(); bcastWindow.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); layout.addComponent(new Label("Compose message (255 char limit):")); final TextArea ta = new TextArea(); ta.setRows(5); ta.setWidth("99%"); layout.addComponent(ta); HorizontalLayout buttHl = new HorizontalLayout(); final Button bcancelButt = new Button("Cancel"); buttHl.addComponent(bcancelButt); Button bokButt = new Button(buttName); buttHl.addComponent(bokButt); layout.addComponent(buttHl); layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT); if (doWarning) layout.addComponent(new Label("Use with great deliberation!")); bcastWindow.setWidth("320px"); UI.getCurrent().addWindow(bcastWindow); bcastWindow.setPositionX(0); bcastWindow.setPositionY(0); ta.focus(); @SuppressWarnings("serial") ClickListener lis = new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed @HibernateUserRead public void buttonClick(ClickEvent event) { if (event.getButton() == bcancelButt) ; // nothin else { // This check is now done in GameEvent.java, but should ideally prompt the user. HSess.init(); String msg = ta.getValue().toString().trim(); if (msg.length() > 0) { if (msg.length() > 255) // clamp to 255 to avoid db exception msg = msg.substring(0, 254); Serializable uid = Mmowgli2UI.getGlobals().getUserID(); User u = User.getTL(uid); if (typ == GameEvent.EventType.GAMEMASTERNOTE) GameEventLogger.logGameMasterCommentTL(msg, u); else GameEventLogger.logGameMasterBroadcastTL(typ, msg, u); // GameEvent.save(new GameEvent(typ,msg)); HSess.close(); } } bcastWindow.close(); } }; bcancelButt.addClickListener(lis); bokButt.addClickListener(lis); }