List of usage examples for com.vaadin.ui Window Window
public Window(String caption, Component content)
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void editTags(final Main main, String title, final Base container) { final Database database = main.getDatabase(); final Window subwindow = new Window(title, new VerticalLayout()); subwindow.setModal(true);/*from www .j a va 2s .c o m*/ subwindow.setWidth("400px"); subwindow.setHeight("360px"); subwindow.setResizable(true); VerticalLayout winLayout = (VerticalLayout) subwindow.getContent(); winLayout.setMargin(true); winLayout.setSpacing(true); // Add some content; a label and a close-button final List<String> tags = new ArrayList<String>(); for (Tag t : container.getRelatedTags(database)) tags.add(t.getId(database)); final CssLayout vl = new CssLayout(); vl.setCaption("Kytss olevat aihetunnisteet:"); fillTagEditor(database, vl, tags, Account.canWrite(main, container)); winLayout.addComponent(vl); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); hl.setSpacing(true); final TagCombo combo = new TagCombo(); final CustomLazyContainer comboContainer = new CustomLazyContainer(database, combo, Tag.enumerate(database)); combo.setWidth("100%"); combo.setCaption("Uusi aihetunniste:"); combo.setInputPrompt("valitse listasta tai kirjoita"); combo.setFilteringMode(FilteringMode.STARTSWITH); combo.setTextInputAllowed(true); combo.setImmediate(true); combo.setNullSelectionAllowed(false); combo.setInvalidAllowed(true); combo.setInvalidCommitted(true); combo.setItemCaptionMode(ItemCaptionMode.PROPERTY); combo.setItemCaptionPropertyId("id"); //should set combo.setContainerDataSource(comboContainer); hl.addComponent(combo); hl.setExpandRatio(combo, 1.0f); Button add = new Button("Lis", new Button.ClickListener() { private static final long serialVersionUID = -2848576385076605664L; public void buttonClick(ClickEvent event) { String filter = (String) combo.getValue(); if (filter != null && filter.length() > 0) { Tag t = database.getOrCreateTag(filter); if (tags.contains(t.getId(database))) return; tags.add(t.getId(database)); fillTagEditor(database, vl, tags, main.account != null); combo.clear(); } } }); hl.addComponent(add); hl.setComponentAlignment(add, Alignment.BOTTOM_LEFT); hl.setExpandRatio(add, 0.0f); winLayout.addComponent(hl); Button close = new Button("Tallenna", new Button.ClickListener() { private static final long serialVersionUID = -451523776456589591L; public void buttonClick(ClickEvent event) { main.removeWindow(subwindow); List<Tag> newTags = new ArrayList<Tag>(); for (String s : tags) newTags.add(database.getOrCreateTag(s)); container.setRelatedTags(database, newTags); Updates.update(main, true); } }); Button discard = new Button("Peru muutokset", new Button.ClickListener() { private static final long serialVersionUID = -2387057110951581993L; public void buttonClick(ClickEvent event) { main.removeWindow(subwindow); } }); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.addComponent(close); hl2.addComponent(discard); winLayout.addComponent(hl2); winLayout.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER); main.addWindow(subwindow); }
From source file:org.aksw.autosparql.tbsl.gui.vaadin.TBSLApplication.java
License:Apache License
private void onShowLearnedQuery() { String learnedSPARQLQuery = UserSession.getManager().getLearnedSPARQLQuery(); VerticalLayout layout = new VerticalLayout(); final Window w = new Window("Learned SPARQL Query", layout); w.setWidth("300px"); w.setSizeUndefined();// w w w .j a v a 2 s . c o m w.setPositionX(200); w.setPositionY(100); getMainWindow().addWindow(w); w.addListener(new Window.CloseListener() { @Override public void windowClose(CloseEvent e) { getMainWindow().removeWindow(w); } }); Label queryLabel = new Label(learnedSPARQLQuery, Label.CONTENT_PREFORMATTED); queryLabel.setWidth(null); layout.addComponent(queryLabel); Label nlLabel = new Label(UserSession.getManager().getNLRepresentation(learnedSPARQLQuery)); layout.addComponent(nlLabel); }
From source file:org.escidoc.browser.ui.dnd.FilesDropBox.java
License:Open Source License
private void showComponent(final Component component, final String name) { final VerticalLayout layout = new VerticalLayout(); layout.setSizeUndefined();// www . j a va 2 s .c o m layout.setMargin(true); final Window window = new Window(name, layout); window.setSizeUndefined(); component.setSizeUndefined(); window.addComponent(component); getWindow().addWindow(window); }
From source file:org.vaadin.addon.ewopener.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { EnhancedBrowserWindowOpener opener1 = new EnhancedBrowserWindowOpener().popupBlockerWorkaround(true); Button button1 = new Button("Click me"); button1.addClickListener(e -> {/*from ww w. ja v a 2s. c o m*/ opener1.open(generateResource()); }); opener1.extend(button1); EnhancedBrowserWindowOpener opener4 = new EnhancedBrowserWindowOpener().popupBlockerWorkaround(true); Button button4 = new Button("Nothing to open here"); button4.addClickListener(e -> { opener4.open((Resource) null); }); opener4.extend(button4); Button button2 = new Button("Click me"); button2.addClickListener(e -> { EnhancedBrowserWindowOpener.extendOnce(button2).open(generateResource()); }); Button button3 = new Button("Click me"); EnhancedBrowserWindowOpener opener3 = new EnhancedBrowserWindowOpener().popupBlockerWorkaround(true) .withGeneratedContent("myFileName.txt", this::generateContent).doExtend(button3); button3.addClickListener(opener3::open); Link link = new Link("Click me", null); new EnhancedBrowserWindowOpener().clientSide(true) .withGeneratedContent("myFileName.txt", this::generateContent).doExtend(link); Link link2 = new Link("Click me", null); new EnhancedBrowserWindowOpener().clientSide(true) .withGeneratedContent("myFileName.txt", this::generateContent, resource -> { resource.setCacheTime(0); resource.setFilename("runtimeFileName-" + Instant.now().getEpochSecond() + ".txt"); }).doExtend(link2); EnhancedBrowserWindowOpener opener5 = new EnhancedBrowserWindowOpener( new ClassResource(DemoUI.class, "static.txt")); CssLayout hiddenComponent = new MCssLayout().withWidth("0").withHeight("0"); opener5.extend(hiddenComponent); CompletableFuture.runAsync(this::doSomeLongProcessing).thenRun(() -> getUI().access(opener5::open)); table = new Table("Select items to download", new BeanItemContainer<>(DummyService.Person.class, DummyService.data())); table.setImmediate(true); table.setVisibleColumns("name", "age"); table.setColumnHeaders("Name", "Age"); table.setWidth("100%"); table.setPageLength(20); table.setMultiSelectMode(MultiSelectMode.DEFAULT); table.setMultiSelect(true); table.setSelectable(true); final MyPopupContent popupContent = new MyPopupContent(); Button popupButton = new Button("Open modal", event -> { Window window = new Window("Test", popupContent); window.setWidth(40, Sizeable.Unit.PERCENTAGE); window.setHeight(200, Sizeable.Unit.PIXELS); window.setModal(true); window.setDraggable(false); window.setResizable(false); window.center(); getUI().addWindow(window); }); MenuBar.Command cmd = selectedItem -> Notification.show("Item clicked", "Item is " + selectedItem.getDescription(), Notification.Type.TRAY_NOTIFICATION); MenuBar menuBar = new MenuBar(); menuBar.setSizeFull(); EnhancedBrowserWindowOpener opener6 = new EnhancedBrowserWindowOpener() .withGeneratedContent("menu-item-serverside.txt", this::generateContent) .popupBlockerWorkaround(true); EnhancedBrowserWindowOpener opener7 = new EnhancedBrowserWindowOpener() .withGeneratedContent("menu-item-clientside-1.txt", this::generateContent).clientSide(true); EnhancedBrowserWindowOpener opener8 = new EnhancedBrowserWindowOpener() .withGeneratedContent("menu-item-clientside-2.txt", this::generateContent).clientSide(true); MenuBar.MenuItem menuItem = menuBar.addItem("Download from Menu (Client side)", selectedItem -> { System.out.println("OK, Invoked"); }); MenuBar.MenuItem subMenu = menuBar.addItem("Sub menu", null); subMenu.addItem("Item 1", cmd); subMenu.addItem("Item 2", cmd); MenuBar.MenuItem subItem = subMenu.addItem("Download (client side)", cmd); MenuBar.MenuItem subItem2 = subMenu.addItem("Download (server side)", selectedItem -> opener6.open()); opener7.doExtend(menuBar, menuItem); opener6.doExtend(menuBar, subItem2); opener8.doExtend(menuBar, subItem); // Show it in the middle of the screen final Layout layout = new MVerticalLayout( new MLabel("Enhanced Window Opener Demo").withStyleName(ValoTheme.LABEL_COLORED, ValoTheme.LABEL_H1), new MHorizontalLayout().add(table, 1) .add(new MCssLayout(menuBar, readMarkdown("code_menu.md").withFullWidth(), new MVerticalLayout(readMarkdown("code1.md"), button1) .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false), new MVerticalLayout(readMarkdown("code2.md"), button2) .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false), new MVerticalLayout(readMarkdown("code7.md"), button3) .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false), new MVerticalLayout(readMarkdown("code5.md"), link) .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false), new MVerticalLayout(readMarkdown("code6.md"), link2) .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false), new MVerticalLayout(readMarkdown("code3.md"), button4) .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false), new MVerticalLayout(readMarkdown("code8.md"), popupButton) .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false), new MVerticalLayout(readMarkdown("code4.md"), hiddenComponent) .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false)) .withFullWidth().withStyleName("demo-samples"), 5) .withFullWidth()).withFullWidth().withMargin(true); setContent(layout); }
From source file:org.vaadin.training.fundamentals.happening.ui.viewimpl.LoginViewImpl.java
License:Creative Commons License
@SuppressWarnings("serial") private void showLoginWindow() { if (loginWindow != null && loginWindow.getParent() != null) { return;/* w ww. j a v a2 s. c o m*/ } loginLayout = new CssLayout(); loginLayout.setSizeFull(); loginLayout.addStyleName("login"); loginWindow = new Window(tr.getString("LoginWindow.Caption"), loginLayout); loginWindow.setWidth("60%"); loginWindow.setHeight("60%"); loginWindow.setClosable(false); loginWindow.setModal(true); loginWindow.center(); LoginForm loginForm = new LoginForm(); loginForm.setSizeUndefined(); loginForm.addListener(new LoginListener() { @Override public void onLogin(LoginEvent event) { String accountId = event.getLoginParameter("username"); String password = event.getLoginParameter("password"); LoginViewImpl.this.getWindow().removeWindow(event.getComponent().getWindow()); LoginViewImpl.this.fireEvent(new LoginAttemptEvent(LoginViewImpl.this, accountId, password)); } }); loginLayout.addComponent(loginForm); // Label photoAttribution = new Label( // "Photo by Curtis Fry. Licensed under Creative Commons"); // photoAttribution.setSizeUndefined(); // photoAttribution.addStyleName("photoAttribution"); // loginLayout.addComponent(photoAttribution); // TextField username = new // TextField(tr.getString("LoginView.Username")); // loginLayout.addComponent(username, "username"); // PasswordField password = new PasswordField( // tr.getString("LoginView.Password")); // loginLayout.addComponent(password, "password"); // // Button registerButton = new Button(tr.getString("Button.Register")); // registerButton.addListener(new Button.ClickListener() { // @Override // public void buttonClick(ClickEvent event) { // } // }); // loginLayout.addComponent(registerButton, "registerButton"); getWindow().addWindow(loginWindow); }
From source file:org.ws13.vaadin.osgi.dm.app.ModuleDemoApp.java
License:Apache License
@Override public void init() { tabs = new TabSheet(); tabs.setSizeFull();//w w w . j a v a 2 s . c o m for (Module module : moduleService.getModules()) { tabs.addTab(module.createComponent(), module.getName(), null); } setMainWindow(new Window("Module Demo Application", tabs)); System.out.println("ModuleDemoApp: Application initializing, adding module service listener"); moduleService.addListener(this); }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
@Override public void init() { setUser(Flash.login());// ww w . ja v a 2 s.co m setTheme("custom"); TabSheet t = new TabSheet(); t.addStyleName(Reindeer.TABSHEET_MINIMAL); t.setSizeFull(); t.setCloseHandler(new DelegateCloseHandler()); UserInfoPanel.addClosableToTabSheet(t, getUser().toString()); TreeTableOrganization treeTableOrganization = new TreeTableOrganization(); CrudNews showNews = new CrudNews(); table = treeTableOrganization.getTreeTable(); Tab orgsTab = t.addTab(treeTableOrganization, ""); t.setSelectedTab(orgsTab); t.addTab(new GroupTab(), ""); GwsSystemTab systemTab = new GwsSystemTab(); t.addTab(systemTab, " ??"); t.addListener(systemTab); GwsLazyTab gwsLazyTab = new GwsLazyTab(); t.addTab(gwsLazyTab, "? ??"); t.addListener(gwsLazyTab); t.addTab(createEmployeeWidget(), ""); RefreshableTab settings = createSettings(); t.addTab(settings, "??"); t.addListener(settings); Component businessCalendar = createBusinessCalendar(); t.addTab(businessCalendar, "? "); LogTab logTab = new LogTab(); t.addListener(logTab); t.addTab(logTab, ""); t.addTab(showNews, "??"); t.addTab(registryTab(), "?"); setMainWindow(new Window( getUser() + " | | -" + Activator.getContext().getBundle().getVersion(), t)); AdminServiceProvider.get().createLog(Flash.getActor(), "Admin application", (String) getUser(), "login", null, true); }
From source file:ru.codeinside.gses.webui.ActivitiApp.java
License:Mozilla Public License
@Override public void init() { try {/* w w w .ja va2 s . c om*/ String userLogin = Flash.login(); Actor userActor = Flash.getActor(); ImmutableSet<Role> userRoles = Flash.flash().getRoles(); boolean productionMode = RunProfile.isProduction(); setUser(userLogin); setTheme("custom"); setMainWindow(new Window(" :: " + userLogin, createUi(userLogin, userRoles, productionMode))); AdminServiceProvider.get().createLog(userActor, "application", userLogin, "userLogin", null, true); } catch (Table.CacheUpdateException e) { for (Throwable cause : e.getCauses()) { Logger.getAnonymousLogger().log(Level.WARNING, "on table" + e.getTable(), cause); } } }
From source file:ui.button.AddCertificateButton.java
License:Apache License
public AddCertificateButton(final Integer userId, final String language, final Achievement a) { super(Translator.getTranslation("Add Certificate", language), FontAwesome.CERTIFICATE); setDescription(Translator.getTranslation("Add Certificate", language)); addClickListener(new Button.ClickListener() { @Override/* w w w. j av a2s. c o m*/ public void buttonClick(Button.ClickEvent event) { UploadReceiver receiver = new CertificateUploadReceiver(userId, language, a); Upload upload = new Upload(Translator.getTranslation("Add Certificate", language), receiver); upload.addSucceededListener((Upload.SucceededListener) receiver); String wcaption = Translator.getTranslation("Upload", language); final Window window = new Window(wcaption, upload); window.center(); //window.setModal(true); window.setStyleName("window"); receiver.setWindow(window); window.addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { window.close(); } }); getUI().addWindow(window); } }); }
From source file:ui.button.AddPhotoButton.java
License:Apache License
public AddPhotoButton(final Integer userId, final String language) { super(Translator.getTranslation("Add professional photo", language), FontAwesome.CAMERA_RETRO); setDescription(Translator.getTranslation("Add professional photo", language)); addClickListener(new Button.ClickListener() { @Override//w w w . j a v a2s . co m public void buttonClick(Button.ClickEvent event) { UploadReceiver receiver = new PhotoUploadReceiver(userId, language); Upload upload = new Upload(Translator.getTranslation("Choose your best photo", language), receiver); upload.addSucceededListener((Upload.SucceededListener) receiver); String wcaption = Translator.getTranslation("Upload a photo", language); final Window window = new Window(wcaption, upload); window.center(); //window.setModal(true); window.setStyleName("window"); receiver.setWindow(window); window.addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { window.close(); } }); getUI().addWindow(window); } }); }