List of usage examples for com.vaadin.ui Window close
public void close()
From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java
License:Open Source License
public static Window showConfirmationPopup(String caption, Component content, String confirmCaption, String cancelCaption, Integer width, Consumer<Boolean> resultConsumer) { Window popupWindow = VaadinUiUtil.createPopupWindow(); if (width != null) { popupWindow.setWidth(width, Unit.PIXELS); } else {/*w w w. j av a 2 s . c om*/ popupWindow.setWidthUndefined(); } popupWindow.setCaption(caption); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); content.setWidth(100, Unit.PERCENTAGE); layout.addComponent(content); ConfirmationComponent confirmationComponent = new ConfirmationComponent(false) { private static final long serialVersionUID = 1L; @Override protected void onConfirm() { popupWindow.close(); resultConsumer.accept(true); } @Override protected void onCancel() { popupWindow.close(); resultConsumer.accept(false); } }; confirmationComponent.getConfirmButton().setCaption(confirmCaption); confirmationComponent.getCancelButton().setCaption(cancelCaption); popupWindow.addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; @Override public void windowClose(CloseEvent e) { confirmationComponent.getCancelButton().click(); } }); layout.addComponent(confirmationComponent); layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT); layout.setWidth(100, Unit.PERCENTAGE); layout.setSpacing(true); popupWindow.setContent(layout); UI.getCurrent().addWindow(popupWindow); return popupWindow; }
From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java
License:Open Source License
public static Window showDeleteConfirmationWindow(String content, Runnable callback) { Window popupWindow = VaadinUiUtil.createPopupWindow(); VerticalLayout deleteLayout = new VerticalLayout(); deleteLayout.setMargin(true);/*w ww .j a v a 2s .c om*/ deleteLayout.setSizeUndefined(); deleteLayout.setSpacing(true); Label description = new Label(content); description.setWidth(100, Unit.PERCENTAGE); deleteLayout.addComponent(description); ConfirmationComponent deleteConfirmationComponent = new ConfirmationComponent(false) { private static final long serialVersionUID = 1L; @Override protected void onConfirm() { popupWindow.close(); onDone(); callback.run(); } @Override protected void onCancel() { popupWindow.close(); } }; deleteConfirmationComponent.getConfirmButton().setCaption(I18nProperties.getString(Strings.yes)); deleteConfirmationComponent.getCancelButton().setCaption(I18nProperties.getString(Strings.no)); deleteLayout.addComponent(deleteConfirmationComponent); deleteLayout.setComponentAlignment(deleteConfirmationComponent, Alignment.BOTTOM_RIGHT); popupWindow.setCaption(I18nProperties.getString(Strings.headingConfirmDeletion)); popupWindow.setContent(deleteLayout); UI.getCurrent().addWindow(popupWindow); return popupWindow; }
From source file:dhbw.clippinggorilla.userinterface.windows.ActivateWindow.java
public static Window get() { Window window = new Window(); window.setModal(true);// ww w. j a va2 s. com window.setResizable(false); window.setDraggable(false); window.setCaption(Language.get(Word.ACTIVATION_CODE)); window.addCloseShortcut(ShortcutAction.KeyCode.ENTER, null); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setMargin(false); windowLayout.setSizeUndefined(); FormLayout forms = new FormLayout(); forms.setMargin(true); forms.setSizeUndefined(); Button save = new Button(Language.get(Word.ACTIVATE)); TextField activationCode = new TextField(Language.get(Word.ACTIVATION_CODE)); activationCode.setMaxLength(6); activationCode.focus(); activationCode.addValueChangeListener(e -> { if (activationCode.getValue().length() > 5) { save.setEnabled(true); activationCode.setComponentError(null); } else { save.setEnabled(false); activationCode.setComponentError(new UserError(Language.get(Word.ACTIVATION_CODE_SIX_CHARS), AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_CODE_SIX_CHARS)); } }); forms.addComponent(activationCode); Button resendMail = new Button(Language.get(Word.RESEND_ACTIVATION_CODE)); resendMail.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); resendMail.addClickListener(ce -> { try { UserUtils.resendActivationMail(UserUtils.getCurrent()); VaadinUtils.infoNotification(Language.get(Word.RESEND_ACTIVATION_CODE_SUCCESSFUL)); } catch (EmailException ex) { VaadinUtils.errorNotification(Language.get(Word.RESEND_ACTIVATION_CODE_FAILED)); } }); forms.addComponent(resendMail); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE); Label placeholder = new Label(); Button cancel = new Button(Language.get(Word.CANCEL)); cancel.setIcon(VaadinIcons.CLOSE); cancel.addClickListener(ce -> { window.close(); }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); save.setEnabled(false); save.setIcon(VaadinIcons.CHECK); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addClickListener(ce -> { try { String code = activationCode.getValue(); User user = UserUtils.getCurrent(); if (UserUtils.activateUser(user, code)) { VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_SUCCESSFUL)); window.close(); } else { activationCode.setValue(""); VaadinUtils.errorNotification(Language.get(Word.ACTIVATION_FAILED)); } } catch (NumberFormatException e) { } }); save.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); footer.setSizeUndefined(); footer.setWidth("100%"); footer.addComponents(placeholder, cancel, save); footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER); windowLayout.addComponent(forms); windowLayout.addComponent(footer); window.setContent(windowLayout); return window; }
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) {/* ww w. j ava 2s . c om*/ // 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 handleLoginLimitActionTL() { // Create the window... final Window loginWin = new Window("Change Session Login Limit"); loginWin.setModal(true);/*from w ww . j a v a 2 s . c om*/ 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 w w 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.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 www.jav a 2 s . 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);/*from w w w .j a v a 2 s. c om*/ 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);//from w w w .j a v a 2s . co 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); }
From source file:edu.nps.moves.mmowgli.modules.gamemaster.AddAuthorEventHandler.java
License:Open Source License
@SuppressWarnings("serial") public static void inviteAuthorsToActionPlan() { final Window win = new Window("Choose Action Plan"); win.setWidth("600px"); win.setHeight("500px"); VerticalLayout layout = new VerticalLayout(); win.setContent(layout);/* w ww . j av a2s.c o m*/ layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); final ActionPlanTable apt = new ActionPlanTable() { @Override public ItemClickListener getItemClickListener() { return new ItemClickListener() { public void itemClick(ItemClickEvent event) { } }; // null listener } }; apt.setMultiSelect(false); apt.setPageLength(10); apt.setSizeFull(); layout.addComponent(apt); layout.setExpandRatio(apt, 1.0f); HorizontalLayout buttHL = new HorizontalLayout(); layout.addComponent(buttHL); buttHL.setWidth("100%"); buttHL.setSpacing(true); Label sp; buttHL.addComponent(sp = new Label()); sp.setWidth("1px"); buttHL.setExpandRatio(sp, 1.0f); Button selectButton = new Button("Select"); buttHL.addComponent(selectButton); Button cancelButton = new Button("Cancel"); buttHL.addComponent(cancelButton); UI.getCurrent().addWindow(win); win.center(); selectButton.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { win.close(); Object o = apt.getValue(); if (o != null) { HSess.init(); inviteAuthorsToActionPlanTL(o); HSess.close(); } } }); cancelButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { win.close(); } }); }