List of usage examples for com.vaadin.ui Window setContent
@Override public void setContent(Component content)
From source file:com.etest.view.tq.TQCoverageUI.java
Window getMaxItemsWindow(Item item, double previousValue) { Window sub = new Window("Field Value: "); sub.setWidth("150px"); sub.setModal(true);/* w ww . j ava 2 s .c o m*/ sub.center(); sub.setResizable(false); VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true); v.setSpacing(true); TextField field = new CommonTextField("Enter Value..", "Enter a Value: "); v.addComponent(field); Button button = new Button("CLOSE"); button.setWidth("100%"); button.setIcon(FontAwesome.TASKS); button.addStyleName(ValoTheme.BUTTON_PRIMARY); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener((Button.ClickEvent event) -> { boolean isNumeric = CommonUtilities.isNumeric(field.getValue().trim()); if (!isNumeric) { return; } item.getItemProperty("Max Items").setValue(CommonUtilities.convertStringToDouble(field.getValue())); if (tq.calculateTotalMaxItems(grid) == CommonUtilities .convertStringToDouble(totalItems.getValue().trim())) { footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid))); } else { item.getItemProperty("Max Items").setValue(previousValue); footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid))); ShowErrorNotification.warning("Total Max Items should be equal to Total Test Items"); return; } sub.close(); }); v.addComponent(button); v.setComponentAlignment(button, Alignment.BOTTOM_CENTER); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.etest.view.tq.TQCoverageWindow.java
Window confirmDeleteWindow() { Window sub = new Window("TQ Coverage"); sub.setWidth("250px"); sub.setResizable(false);//from ww w . j a v a 2 s .co m sub.setModal(true); sub.center(); VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true); Button delete = new Button("DELETE TQ?"); delete.setWidth("100%"); delete.setIcon(FontAwesome.TRASH_O); delete.addStyleName(ValoTheme.BUTTON_PRIMARY); delete.addStyleName(ValoTheme.BUTTON_SMALL); delete.addClickListener((Button.ClickEvent event) -> { boolean result = tq.deleteTQCoverage(getTQCoverageId()); if (result) { sub.close(); close(); } }); v.addComponent(delete); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.expressui.core.MainApplication.java
License:Open Source License
@Override public void init() { currentInstance.set(this); setTheme(getCustomTheme());/*w w w . j a v a 2 s . c om*/ customizeConfirmDialogStyle(); Window mainWindow = new Window(); setMainWindow(mainWindow); mainWindow.addStyleName("e-main-window"); mainWindow.setCaption(getTypeCaption()); VerticalLayout mainLayout = new VerticalLayout(); String id = StringUtil.generateDebugId("e", this, mainLayout, "mainLayout"); mainLayout.setDebugId(id); mainWindow.setSizeFull(); mainLayout.setSizeFull(); mainWindow.setContent(mainLayout); setLogoutURL(getApplicationProperties().getRestartApplicationUrl()); configureLeftMenuBar(mainMenuBar.getLeftMenuBarRoot()); configureRightMenuBar(mainMenuBar.getRightMenuBarRoot()); mainLayout.addComponent(mainMenuBar); pageLayoutTabSheet = new TabSheet(); id = StringUtil.generateDebugId("e", this, pageLayoutTabSheet, "pageLayoutTabSheet"); pageLayoutTabSheet.setDebugId(id); pageLayoutTabSheet.addStyleName("e-main-page-layout"); pageLayoutTabSheet.setSizeFull(); mainLayout.addComponent(pageLayoutTabSheet); mainLayout.setExpandRatio(pageLayoutTabSheet, 1.0f); Link expressUILink = new Link(uiMessageSource.getMessage("mainApplication.footerMessage"), new ExternalResource(uiMessageSource.getMessage("mainApplication.footerLink"))); expressUILink.setTargetName("_blank"); expressUILink.setIcon(new ThemeResource("../expressui/favicon.png")); expressUILink.setSizeUndefined(); mainLayout.addComponent(expressUILink); mainLayout.setComponentAlignment(expressUILink, Alignment.TOP_CENTER); configureSessionTimeout(mainWindow); postWire(); onDisplay(); }
From source file:com.foc.vaadin.FocWebApplication.java
License:Apache License
@Override public void addWindow(Window window) throws IllegalArgumentException, NullPointerException { boolean executedWithoutPopup = false; if (isMobile()) { Object content = window.getContent(); if (content instanceof ICentralPanel) { if (getContent() != null && getContent() instanceof FocCentralPanel) { window.setContent(null); FocCentralPanel centralComponent = (FocCentralPanel) getContent(); centralComponent.changeCentralPanelContent((ICentralPanel) content, true); executedWithoutPopup = true; }// ww w . ja v a 2 s .c o m } } if (!executedWithoutPopup) { window.setModal(true); super.addWindow(window); } }
From source file:com.foc.vaadin.gui.xmlForm.FocXMLLayout.java
License:Apache License
public void printThisLayout() { XMLView xmlView = getXMLView();/*from w w w . j a va2 s .c o m*/ Window window = new Window(); // window.setScrollable(false);//HEREHERE FocXMLLayout printingForm = new FocXMLLayout(); printingForm.init((FocCentralPanel) getMainWindow(), xmlView, getFocData()); printingForm.parseXMLAndBuildGui(); window.setContent(printingForm); FocWebApplication.getInstanceForThread().addWindow(window); // mWindow.open(new ExternalResource(window.getURL()), "_blank", 595, 842, // Window.BORDER_NONE); JavaScript.getCurrent().execute("print();"); JavaScript.getCurrent().execute("self.close();"); }
From source file:com.garyclayburg.vconsole.TargetWindows.java
License:Open Source License
void populateTarget(User selectedUser, String entitledTarget) { Window window = targetWindows.get(entitledTarget); if (window != null) { UI ui = window.getUI();// w ww . j a v a 2 s . co m if (ui != null) { VaadinSession session = ui.getSession(); if (session != null) { session.getLockInstance().lock(); try { VerticalLayout windowContent = populateTargetWindowData(selectedUser, entitledTarget); window.setContent(windowContent); } finally { session.getLockInstance().unlock(); } } } } }
From source file:com.garyclayburg.vconsole.VConsole.java
License:Open Source License
private Table createUserTable(BeanContainer<String, User> userBeanContainer) { final Collection[] selectedRows = new Collection[1]; final Table userTable = new Table(); userTable.setSizeFull();/* www . ja va 2 s . co m*/ userTable.setSelectable(true); userTable.setMultiSelect(false); userTable.setImmediate(true); userTable.setContainerDataSource(userBeanContainer); userTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { Collection<?> itemPropertyIds = event.getItem().getItemPropertyIds(); log.info("properties clicked: " + itemPropertyIds); log.info("multiple select? " + selectedRows[0]); } }); userTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { // selectedRows[0] = (Collection) userTable.getValue(); log.info("selected: " + userTable.getValue()); } }); userTable.addActionHandler(new Action.Handler() { @Override public Action[] getActions(Object target, Object sender) { Table selectedUserTable = (Table) sender; Item item = selectedUserTable.getItem(selectedUserTable.getValue()); Action[] actions = new Action[0]; if (item instanceof BeanItem) { log.debug("create right-click menu items"); // if (target == null){ //create actions for item user clicked on Item targetItem = selectedUserTable.getItem(target); if (targetItem != null) { User targetUser = (User) ((BeanItem) targetItem).getBean(); if (targetUser != null) { Set<String> allEntitledTargets = attributeService.getEntitledTargets(targetUser); Set<Action> entitledTargetActions = new HashSet<>(); for (String targetName : allEntitledTargets) { final Action action = new Action(targetName); entitledTargetActions.add(action); } actions = entitledTargetActions.toArray(new Action[entitledTargetActions.size()]); log.debug("right-click actions for user {}: {}", target, entitledTargetActions); } } } else { log.debug("Cannot create right-click menu items"); } return actions; } @Override public void handleAction(Action action, Object sender, Object target) { if (action != null) { Table selectedUserTable = (Table) sender; selectedUserTable.getValue(); Item item = selectedUserTable.getItem(selectedUserTable.getValue()); if (item instanceof BeanItem) { log.debug("create target window"); User user = (User) ((BeanItem) item).getBean(); targetWindows.showTargetWindow(user, action.getCaption()); } else { log.debug("Cannot create window"); } } else { Window multiWindow = new Window("multi-user myAD attributes"); UI.getCurrent().addWindow(multiWindow); Label stuff = new Label("2 users here " + selectedRows[0] + " "); multiWindow.setContent(stuff); } } }); userTable.setVisibleColumns("firstname", "lastname"); return userTable; }
From source file:com.github.mjvesa.herd.wordset.VaadinWordSet.java
License:Apache License
@Override public Word[] getWords() { return new Word[] { new BaseWord("new-button", "", Word.POSTPONED) { private static final long serialVersionUID = -2492817908731559368L; @Override/* www .java 2 s . c om*/ public void execute(final Interpreter interpreter) { Button b = new Button("", new Button.ClickListener() { private static final long serialVersionUID = -4622489800920283752L; @Override public void buttonClick(ClickEvent event) { Button b = event.getButton(); Word command = (Word) b.getData(); if (command != null) { interpreter.execute(command); } } }); interpreter.pushData(b); } }, new BaseWord("set-click-listener", "", Word.POSTPONED) { private static final long serialVersionUID = 5749856686458297558L; @Override public void execute(Interpreter interpreter) { Object o = interpreter.popData(); Button b = (Button) interpreter.popData(); b.setData(o); interpreter.pushData(b); } }, new BaseWord("new-hl", "", Word.POSTPONED) { private static final long serialVersionUID = 8813556668649386248L; @Override public void execute(Interpreter interpreter) { HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); interpreter.pushData(hl); } }, new BaseWord("new-vl", "", Word.POSTPONED) { private static final long serialVersionUID = -1848213448504804229L; @Override public void execute(Interpreter interpreter) { VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); interpreter.pushData(vl); } }, new BaseWord("new-gl", "( x y - gl )", Word.POSTPONED) { private static final long serialVersionUID = 4079634885691605257L; @Override public void execute(Interpreter interpreter) { Integer height = (Integer) interpreter.popData(); Integer width = (Integer) interpreter.popData(); interpreter.pushData(new GridLayout(width, height)); } }, new BaseWord("gl-new-line", "", Word.POSTPONED) { private static final long serialVersionUID = 975877390052961807L; @Override public void execute(Interpreter interpreter) { ((GridLayout) interpreter.peekData()).newLine(); } }, new BaseWord("new-window", "", Word.POSTPONED) { private static final long serialVersionUID = -6887364362728545090L; @Override public void execute(Interpreter interpreter) { Window w = new Window(); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); w.setContent(vl); interpreter.pushData(w); interpreter.pushData(vl); } }, new BaseWord("main-panel", "", Word.POSTPONED) { private static final long serialVersionUID = -8622281600566696475L; @Override public void execute(Interpreter interpreter) { interpreter.pushData(interpreter.getMainPanel()); } }, new BaseWord("add-window", "", Word.POSTPONED) { private static final long serialVersionUID = 7106029415576813922L; @Override public void execute(Interpreter interpreter) { Window w = (Window) interpreter.popData(); interpreter.getView().getUI().addWindow(w); } }, new BaseWord("add-component", "", Word.POSTPONED) { private static final long serialVersionUID = 5640824046985354091L; @Override public void execute(Interpreter interpreter) { Component comp = (Component) interpreter.popData(); ComponentContainer cc = (ComponentContainer) interpreter.popData(); cc.addComponent(comp); interpreter.pushData(cc); } }, new BaseWord("set-caption", "", Word.POSTPONED) { private static final long serialVersionUID = 5497598050469462487L; @Override public void execute(Interpreter interpreter) { String s = (String) interpreter.popData(); Component c = (Component) interpreter.popData(); c.setCaption(s); interpreter.pushData(c); } }, new BaseWord("set-value", "", Word.POSTPONED) { private static final long serialVersionUID = -1769743552659215058L; @Override public void execute(Interpreter interpreter) { Object o = interpreter.popData(); Property p = (Property) interpreter.popData(); p.setValue(o); interpreter.pushData(p); } }, new BaseWord("get-value", "", Word.POSTPONED) { private static final long serialVersionUID = 8445550546521886374L; @Override public void execute(Interpreter interpreter) { Field f = (Field) interpreter.popData(); interpreter.pushData(f); interpreter.pushData(f.getValue()); } }, new BaseWord("set-size-full", "", Word.POSTPONED) { private static final long serialVersionUID = -1206491811133054467L; @Override public void execute(Interpreter interpreter) { Component comp = (Component) interpreter.popData(); comp.setSizeFull(); interpreter.pushData(comp); } }, new BaseWord("set-size-undefined", "", Word.POSTPONED) { private static final long serialVersionUID = -3450618729379622987L; @Override public void execute(Interpreter interpreter) { Component comp = (Component) interpreter.popData(); comp.setSizeUndefined(); interpreter.pushData(comp); } }, new BaseWord("set-height", "", Word.POSTPONED) { private static final long serialVersionUID = -8426734568403715950L; @Override public void execute(Interpreter interpreter) { String str = (String) interpreter.popData(); Component comp = (Component) interpreter.popData(); comp.setHeight(str); interpreter.pushData(comp); } }, new BaseWord("set-width", "", Word.POSTPONED) { private static final long serialVersionUID = -4558264143049463814L; @Override public void execute(Interpreter interpreter) { String str = (String) interpreter.popData(); Component comp = (Component) interpreter.popData(); comp.setWidth(str); interpreter.pushData(comp); } }, new BaseWord("clear-container", "", Word.POSTPONED) { private static final long serialVersionUID = 1070175466682034329L; @Override public void execute(Interpreter interpreter) { ComponentContainer cc = (ComponentContainer) interpreter.popData(); cc.removeAllComponents(); } }, new BaseWord("new-check-box", "", Word.POSTPONED) { private static final long serialVersionUID = 4018632924389912599L; @Override public void execute(Interpreter interpreter) { interpreter.pushData(new CheckBox()); } }, new BaseWord("new-date-field", "", Word.POSTPONED) { private static final long serialVersionUID = 6313296566085274642L; @Override public void execute(final Interpreter interpreter) { interpreter.pushData(new DateField()); final String dfCommand = (String) interpreter.popData(); DateField df = new DateField(); df.setImmediate(true); df.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = 1472139878970514093L; public void valueChange(ValueChangeEvent event) { interpreter.pushData(event.getProperty().getValue()); interpreter.interpret(dfCommand); } }); interpreter.pushData(df); } }, new BaseWord("new-label", "", Word.POSTPONED) { private static final long serialVersionUID = -2825285195439247251L; @Override public void execute(Interpreter interpreter) { interpreter.pushData(new Label()); } }, new BaseWord("new-text-field", "", Word.POSTPONED) { private static final long serialVersionUID = -1064489458253275380L; @Override public void execute(final Interpreter interpreter) { final String tfCommand = interpreter.getNextNonNopWord(); TextField tf = new TextField(); tf.setCaption((String) interpreter.popData()); tf.setValue(""); tf.setImmediate(true); tf.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 4325104922208051065L; public void valueChange(ValueChangeEvent event) { interpreter.pushData(event.getProperty().getValue()); interpreter.interpret(tfCommand); } }); interpreter.pushData(tf); } }, new BaseWord("new-table", "", Word.POSTPONED) { private static final long serialVersionUID = -5052653341575232035L; @Override public void execute(final Interpreter interpreter) { final String tableCommand = interpreter.getParser().getNextWord(); Table table = new Table(); table.setCaption((String) interpreter.popData()); table.setImmediate(true); table.setSelectable(true); table.addItemClickListener(new ItemClickListener() { /** * */ private static final long serialVersionUID = 3585546076571010729L; public void itemClick(ItemClickEvent event) { interpreter.pushData(event.getItem()); interpreter.execute(interpreter.getDictionary().get(tableCommand)); } }); interpreter.pushData(table); } }, new BaseWord("new-combo-box", "", Word.POSTPONED) { private static final long serialVersionUID = 3881577354424928897L; @Override public void execute(final Interpreter interpreter) { final String newItemCommand = interpreter.getParser().getNextWord(); final String itemSelectedCommand = interpreter.getParser().getNextWord(); final ComboBox cb = new ComboBox(); String str = (String) interpreter.popData(); cb.setNullSelectionAllowed(false); cb.setCaption(str); cb.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM); cb.setNewItemsAllowed(true); cb.setNewItemHandler(new NewItemHandler() { /** * */ private static final long serialVersionUID = 3340658590351611289L; public void addNewItem(String newItemCaption) { cb.setImmediate(false); interpreter.pushData(newItemCaption); interpreter.interpret(newItemCommand); cb.setImmediate(true); } }); cb.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = 2706579869793251379L; public void valueChange(ValueChangeEvent event) { interpreter.pushData( cb.getContainerDataSource().getItem(event.getProperty().getValue())); interpreter.interpret(itemSelectedCommand); } }); cb.setImmediate(true); interpreter.pushData(cb); } }, new BaseWord("new-select", "", Word.POSTPONED) { private static final long serialVersionUID = -6142351970812196488L; @Override public void execute(final Interpreter interpreter) { final String selCommand = interpreter.getParser().getNextWord(); final ComboBox sel = new ComboBox(); sel.setCaption((String) interpreter.popData()); sel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM); sel.setNullSelectionAllowed(false); sel.setImmediate(true); sel.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = -7705548618092166199L; public void valueChange(ValueChangeEvent event) { Item item = sel.getContainerDataSource().getItem(event.getProperty().getValue()); interpreter.pushData(item); interpreter.interpret(selCommand); } }); interpreter.pushData(sel); } }, new BaseWord("new-list-select", "", Word.POSTPONED) { private static final long serialVersionUID = 8686093227035249035L; @Override public void execute(final Interpreter interpreter) { final String lselCommand = interpreter.getParser().getNextWord(); final ListSelect lsel = new ListSelect(); lsel.setCaption((String) interpreter.popData()); lsel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM); lsel.setNullSelectionAllowed(false); lsel.setImmediate(true); lsel.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = -5523488417834167806L; public void valueChange(ValueChangeEvent event) { Item item = lsel.getContainerDataSource().getItem(event.getProperty().getValue()); interpreter.pushData(item); interpreter.interpret(lselCommand); } }); interpreter.pushData(lsel); } }, new BaseWord("set-container-data-source", "", Word.POSTPONED) { private static final long serialVersionUID = 8644721936358613031L; @Override public void execute(Interpreter interpreter) { Container cont = (Container) interpreter.popData(); AbstractSelect as = (AbstractSelect) interpreter.popData(); as.setContainerDataSource(cont); interpreter.pushData(as); } }, new BaseWord("set-column-headers", "", Word.POSTPONED) { private static final long serialVersionUID = -7296881714369214846L; @Override public void execute(Interpreter interpreter) { Table table = (Table) interpreter.popData(); table.setColumnHeaders((String[]) getArrayFromList(interpreter, new String[0])); } }, new BaseWord("set-visible-columns", "", Word.POSTPONED) { private static final long serialVersionUID = 5674765074478598320L; @Override public void execute(Interpreter interpreter) { Table table = (Table) interpreter.popData(); table.setVisibleColumns((String[]) getArrayFromList(interpreter, new String[0])); } } }; }
From source file:com.hack23.cia.web.impl.ui.application.views.pageclicklistener.SetGoogleAuthenticatorCredentialClickListener.java
License:Apache License
@Override public void buttonClick(final ClickEvent event) { final SetGoogleAuthenticatorCredentialResponse response = (SetGoogleAuthenticatorCredentialResponse) applicationManager .service(googleAuthRequest); if (ServiceResult.SUCCESS == response.getResult()) { try {/*from w w w . j a v a 2s. c o m*/ final URI keyUri = new URI(response.getOtpAuthTotpURL()); final QRCode qrCode = new QRCode(QR_CODE, keyUri.toASCIIString()); qrCode.setHeight(QR_CODE_IMAGE_SIZE); qrCode.setWidth(QR_CODE_IMAGE_SIZE); final Window mywindow = new Window(GOOGLE_AUTHENTICATOR_QR_CODE); mywindow.setHeight(MODAL_WINDOW_SIZE); mywindow.setWidth(MODAL_WINDOW_SIZE); mywindow.setPositionX(WINDOW_POSITION); mywindow.setPositionY(WINDOW_POSITION); final VerticalLayout panelContent = new VerticalLayout(); mywindow.setContent(panelContent); panelContent.addComponent(qrCode); mywindow.setModal(true); UI.getCurrent().addWindow(mywindow); } catch (final URISyntaxException e) { LOGGER.warn(PROBLEM_DISPLAYING_QR_CODE, e); Notification.show(PROBLEM_DISPLAYING_QR_CODE, ERROR_MESSAGE, Notification.Type.WARNING_MESSAGE); } } else { Notification.show(PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR, ERROR_MESSAGE, Notification.Type.WARNING_MESSAGE); LOGGER.info(PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR_SESSIONID, googleAuthRequest.getSessionId()); } }
From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java
License:Apache License
protected void showNoUserSessionDialog(App app) { Messages messages = AppBeans.get(Messages.NAME); Window dialog = new NoUserSessionExceptionDialog(); dialog.setStyleName("c-nousersession-dialog"); dialog.setCaption(messages.getMainMessage("dialogs.Information", locale)); dialog.setClosable(false);//w w w .j a v a 2s . c o m dialog.setResizable(false); dialog.setModal(true); AppUI ui = app.getAppUI(); if (ui.isTestMode()) { dialog.setCubaId("optionDialog"); dialog.setId(ui.getTestIdManager().getTestId("optionDialog")); } Label messageLab = new CubaLabel(); messageLab.setWidthUndefined(); messageLab.setValue(messages.getMainMessage("noUserSession.message", locale)); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setWidthUndefined(); layout.setStyleName("c-nousersession-dialog-layout"); layout.setSpacing(true); dialog.setContent(layout); Button reloginBtn = new Button(); if (ui.isTestMode()) { reloginBtn.setCubaId("reloginBtn"); reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn")); } reloginBtn.addStyleName(WebButton.ICON_STYLE); reloginBtn.addStyleName("c-primary-action"); reloginBtn.addClickListener(event -> relogin()); reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey())); String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey()); reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName)); ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class); setClickShortcut(reloginBtn, clientConfig.getCommitShortcut()); reloginBtn.focus(); layout.addComponent(messageLab); layout.addComponent(reloginBtn); layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT); ui.addWindow(dialog); dialog.center(); }