List of usage examples for com.vaadin.ui Window Window
public Window(String caption)
From source file:br.gov.sp.saovicente.MyVaadinApplication.java
License:Apache License
@Override public void init() { final Window mainWindow = new Window("Sampleinvientchart2 Application"); mainWindow.setSizeFull();//from ww w . ja v a 2 s. c o m setMainWindow(mainWindow); mgberr = new MessageBox(getMainWindow(), "My message ERRO...", MessageBox.Icon.ERROR, "Hello World!", new MessageBox.ButtonConfig(ButtonType.OK, "Ok")); mgbinf = new MessageBox(getMainWindow(), "My message INFO...", MessageBox.Icon.INFO, "Hello World!", new MessageBox.ButtonConfig(ButtonType.OK, "Ok")); mgbquest = new MessageBox(getMainWindow(), "My message QUESTION...", MessageBox.Icon.QUESTION, "Hello World!", new MessageBox.ButtonConfig(ButtonType.YES, "YES"), new MessageBox.ButtonConfig(ButtonType.NO, "NO")); mgbnone = new MessageBox(getMainWindow(), "My message NONE...", MessageBox.Icon.QUESTION, "Hello World!", new MessageBox.ButtonConfig(ButtonType.OK, "Ok")); mgbwarn = new MessageBox(getMainWindow(), "My message WARN...", MessageBox.Icon.WARN, "Hello World!", new MessageBox.ButtonConfig(ButtonType.OK, "Ok")); infomacao = new Button("Informao"); infomacao.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgbinf.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { } }); } }); erro = new Button("Erro"); erro.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgberr.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { System.out.println("Este boto foi pressionado: " + buttonType); } }); } }); none = new Button("None"); none.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgbnone.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { System.out.println("Este boto foi pressionado: " + buttonType); } }); } }); question = new Button("Question"); question.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgbquest.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { if (buttonType.toString().equals("YES")) { mainWindow.open(new ExternalResource("http://10.171.0.9:8080/bic/")); System.out.println("Este boto foi pressionado: " + buttonType); } else if (buttonType.toString().equals("NO")) { mainWindow.open(new ExternalResource("http://localhost:8080/modelo/")); } } }); } }); warn = new Button("Warn"); warn.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mgbwarn.show(new MessageBox.EventListener() { public void buttonClicked(ButtonType buttonType) { System.out.println("Este boto foi pressionado: " + buttonType); } }); } }); HorizontalLayout botao = new HorizontalLayout(); botao.setSpacing(true); botao.addComponent(erro); botao.addComponent(warn); botao.addComponent(none); botao.addComponent(infomacao); botao.addComponent(question); // CustomDateField df = new CustomDateField(); //df.setbTwelveHourClock(false); // df.setbTwelveHourClock(true); // mainWindow.addComponent(df); //mainWindow.addComponent(new WidgetSetTest()); mainWindow.addComponent(botao); }
From source file:by.vitsoft.material.vaadin.MyVaadinApplication.java
License:Apache License
@Override public void init() { window = new Window("My Vaadin Application"); setMainWindow(window);//from w w w . ja v a 2 s . com //window.addComponent(new Button("Click Me")); // Create a table. It is by default not editable. final Table table = new Table(); // Define the names and data types of columns. //table.addContainerProperty("Date", Date.class, null); //table.addContainerProperty("Work", Boolean.class, null); table.addContainerProperty("Id", Long.class, null); table.addContainerProperty("UnitId", Long.class, null); table.setColumnHeader("UnitId", ""); table.addContainerProperty("UnitName", String.class, null); table.setColumnHeader("UnitName", "?"); // Add a few items in the table. BaseResponse<Unit> units = guideService.getGuides("unit", null); for (Unit unit : units.getData()) { table.addItem(new Object[] { unit.getId(), unit.getUnitId(), unit.getUnitName() }, unit.getId()); // Item identifier } table.setPageLength(10); window.addComponent(table); final CheckBox switchEditable = new CheckBox("Editable"); switchEditable.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { table.setEditable(((Boolean) event.getProperty().getValue()).booleanValue()); } }); switchEditable.setImmediate(true); window.addComponent(switchEditable); }
From source file:cib.ladnyik.MyVaadinApplication.java
License:Apache License
@Override public void init() { Workbook wb = new XSSFWorkbook(); window = new Window("My Vaadin Application"); setMainWindow(window);/*from ww w . ja va 2 s. com*/ Button button = new Button("Click Me Two Times Three Times XXX"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { window.addComponent(new Label("Thank you for clicking")); System.out.println("Thank you for clicking"); } }); window.addComponent(button); }
From source file:com.acme.oms.ui.RunnerVaadinApplication.java
License:Apache License
@Override public void init() { @SuppressWarnings("resource") ConfigurableApplicationContext appCtx = new ClassPathXmlApplicationContext( "META-INF/spring/application-context.xml"); appCtx.registerShutdownHook();/*from w w w . j a v a2 s . co m*/ queryRepository = appCtx.getBean(JpaOrderQueryRepository.class); commandBus = appCtx.getBean(CommandBus.class); window = new Window("Order Management System"); orderForm = new OrderForm(commandBus); orderList = new OrderList(new OrderContainer(queryRepository)); orderListView = new OrderListView(orderList, orderForm); window.addComponent(orderListView); window.getContent().setSizeFull(); setMainWindow(window); }
From source file:com.assemblade.ui.CatApplication.java
License:Apache License
@Override public void init() { setTheme("cat-chameleon"); mainWindow = new Window("CAT"); setMainWindow(mainWindow);// w w w . ja va2s.co m viewManager = new ViewManager(mainWindow); viewManager.switchScreen(LoginScreen.class.getName(), new LoginScreen()); }
From source file:com.bsb.common.vaadin.embed.component.ComponentWrapper.java
License:Apache License
/** * Wraps a {@link Layout} into a Vaadin application. * * @param layout the layout to wrap/*w w w . ja va 2 s .co m*/ * @return an application displaying that layout */ public Application wrapLayout(Layout layout) { // TODO: add a header to switch the style, etc // TODO: add bookmark to set the style final Window mainWindow = new Window("Dev"); if (server.getConfig().isDevelopmentHeader()) { final VerticalSplitPanel mainLayout = new VerticalSplitPanel(); mainLayout.setSizeFull(); mainLayout.setSplitPosition(SPLIT_POSITION, Sizeable.UNITS_PIXELS); mainLayout.setLocked(true); final DevApplicationHeader header = new DevApplicationHeader(server); header.setSpacing(true); mainLayout.setFirstComponent(header); mainLayout.setSecondComponent(layout); mainWindow.setContent(mainLayout); } else { mainWindow.setContent(layout); } return new DevApplication(server, mainWindow); }
From source file:com.bsb.samples.vaadin.wizard.core.WizardSampleApplication.java
License:Apache License
@Override public void init() { final VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeFull();/*from w w w . j a v a 2s . co m*/ mainLayout.setMargin(true); final Wizard wizard = new Wizard(); wizard.addStep(new FirstStep(), "First"); wizard.addStep(new FinalStep(), "Final"); wizard.setWidth(800, Sizeable.UNITS_PIXELS); wizard.setHeight(600, Sizeable.UNITS_PIXELS); mainLayout.addComponent(wizard); mainLayout.setComponentAlignment(wizard, Alignment.MIDDLE_CENTER); final Window mainWindow = new Window("Wizard Sample"); mainWindow.setContent(mainLayout); setMainWindow(mainWindow); }
From source file:com.cavisson.gui.dashboard.components.calender.BeanItemContainerTestUI.java
License:Apache License
/** * Opens up a modal dialog window where an event can be modified * /* ww w. j a v a 2 s . c o m*/ * @param event * The event to modify */ private void editEvent(final BasicEvent event) { Window modal = new Window("Add event"); modal.setModal(true); modal.setResizable(false); modal.setDraggable(false); modal.setWidth("300px"); final FieldGroup fieldGroup = new FieldGroup(); FormLayout formLayout = new FormLayout(); TextField captionField = new TextField("Caption"); captionField.setImmediate(true); TextField descriptionField = new TextField("Description"); descriptionField.setImmediate(true); DateField startField = new DateField("Start"); startField.setResolution(Resolution.MINUTE); startField.setImmediate(true); DateField endField = new DateField("End"); endField.setImmediate(true); endField.setResolution(Resolution.MINUTE); formLayout.addComponent(captionField); formLayout.addComponent(descriptionField); formLayout.addComponent(startField); formLayout.addComponent(endField); fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY); fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY); fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY); fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY); fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event, Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY, ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY))); modal.setContent(formLayout); modal.addCloseListener(new Window.CloseListener() { @Override public void windowClose(CloseEvent e) { // Commit changes to bean try { fieldGroup.commit(); } catch (CommitException e1) { e1.printStackTrace(); } if (events.containsId(event)) { /* * BeanItemContainer does not notify container listeners * when the bean changes so we need to trigger a * ItemSetChange event */ BasicEvent dummy = new BasicEvent(); events.addBean(dummy); events.removeItem(dummy); } else { events.addBean(event); } } }); getUI().addWindow(modal); }
From source file:com.cavisson.gui.dashboard.components.charts.Impl.ResizeInsideVaadinComponent.java
@Override protected Component getChart() { VerticalSplitPanel verticalSplitPanel = new VerticalSplitPanel(); HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel(); horizontalSplitPanel.setSecondComponent(verticalSplitPanel); verticalSplitPanel.setFirstComponent(createChart()); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true);//from ww w . j a v a 2s . com verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Relatively sized components resize themselves automatically when in Vaadin component.")); Button button = new Button("Open in a window"); button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { Window window = new Window("Chart windodw"); window.setContent(createChart()); window.setWidth("50%"); window.setHeight("50%"); getUI().addWindow(window); } }); verticalLayout.addComponent(button); horizontalSplitPanel.setFirstComponent(verticalLayout); return horizontalSplitPanel; }
From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java
License:Apache License
Panel windows() { Panel p = new Panel("Dialogs"); VerticalLayout content = new VerticalLayout() { final Window win = new Window("Window Caption"); String prevHeight = "300px"; boolean footerVisible = true; boolean autoHeight = false; boolean tabsVisible = false; boolean toolbarVisible = false; boolean footerToolbar = false; boolean toolbarLayout = false; String toolbarStyle = null; VerticalLayout windowContent() { VerticalLayout root = new VerticalLayout(); if (toolbarVisible) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setSizeUndefined(); menuBar.setStyleName(toolbarStyle); Component toolbar = menuBar; if (toolbarLayout) { menuBar.setWidth(null); HorizontalLayout toolbarLayout = new HorizontalLayout(); toolbarLayout.setWidth("100%"); toolbarLayout.setSpacing(true); Label label = new Label("Tools"); label.setSizeUndefined(); toolbarLayout.addComponents(label, menuBar); toolbarLayout.setExpandRatio(menuBar, 1); toolbarLayout.setComponentAlignment(menuBar, Alignment.TOP_RIGHT); toolbar = toolbarLayout; }// ww w .j a v a2s .co m toolbar.addStyleName("v-window-top-toolbar"); root.addComponent(toolbar); } Component content = null; if (tabsVisible) { TabSheet tabs = new TabSheet(); tabs.setSizeFull(); VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); tabs.addTab(l, "Selected"); tabs.addTab(new Label(" ", ContentMode.HTML), "Another"); tabs.addTab(new Label(" ", ContentMode.HTML), "One more"); tabs.addStyleName("padded-tabbar"); tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(final SelectedTabChangeEvent event) { try { Thread.sleep(600); } catch (InterruptedException e) { e.printStackTrace(); } } }); content = tabs; } else if (!autoHeight) { Panel p = new Panel(); p.setSizeFull(); p.addStyleName("borderless"); if (!toolbarVisible || !toolbarLayout) { p.addStyleName("scroll-divider"); } VerticalLayout l = new VerticalLayout(); l.addComponent(new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML)); l.setMargin(true); p.setContent(l); content = p; } else { content = new Label( "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>", ContentMode.HTML); root.setMargin(true); } root.addComponent(content); if (footerVisible) { HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName("v-window-bottom-toolbar"); Label footerText = new Label("Footer text"); footerText.setSizeUndefined(); Button ok = new Button("OK"); ok.addStyleName("primary"); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok, cancel); footer.setExpandRatio(footerText, 1); if (footerToolbar) { MenuBar menuBar = MenuBars.getToolBar(); menuBar.setStyleName(toolbarStyle); menuBar.setWidth(null); footer.removeAllComponents(); footer.addComponent(menuBar); } root.addComponent(footer); } if (!autoHeight) { root.setSizeFull(); root.setExpandRatio(content, 1); } return root; } { setSpacing(true); setMargin(true); win.setWidth("380px"); win.setHeight(prevHeight); win.setClosable(false); win.setResizable(false); win.setContent(windowContent()); win.setCloseShortcut(KeyCode.ESCAPE, null); Command optionsCommand = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Footer")) { footerVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Auto Height")) { autoHeight = selectedItem.isChecked(); if (!autoHeight) { win.setHeight(prevHeight); } else { prevHeight = win.getHeight() + win.getHeightUnits().toString(); win.setHeight(null); } } if (selectedItem.getText().equals("Tabs")) { tabsVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top")) { toolbarVisible = selectedItem.isChecked(); } if (selectedItem.getText().equals("Footer")) { footerToolbar = selectedItem.isChecked(); } if (selectedItem.getText().equals("Top layout")) { toolbarLayout = selectedItem.isChecked(); } if (selectedItem.getText().equals("Borderless")) { toolbarStyle = selectedItem.isChecked() ? "borderless" : null; } win.setContent(windowContent()); } }; MenuBar options = new MenuBar(); options.setCaption("Content"); options.addItem("Auto Height", optionsCommand).setCheckable(true); options.addItem("Tabs", optionsCommand).setCheckable(true); MenuItem option = options.addItem("Footer", optionsCommand); option.setCheckable(true); option.setChecked(true); options.addStyleName("small"); addComponent(options); options = new MenuBar(); options.setCaption("Toolbars"); options.addItem("Footer", optionsCommand).setCheckable(true); options.addItem("Top", optionsCommand).setCheckable(true); options.addItem("Top layout", optionsCommand).setCheckable(true); options.addItem("Borderless", optionsCommand).setCheckable(true); options.addStyleName("small"); addComponent(options); Command optionsCommand2 = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Caption")) { win.setCaption(selectedItem.isChecked() ? "Window Caption" : null); } else if (selectedItem.getText().equals("Closable")) { win.setClosable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Resizable")) { win.setResizable(selectedItem.isChecked()); } else if (selectedItem.getText().equals("Modal")) { win.setModal(selectedItem.isChecked()); } } }; options = new MenuBar(); options.setCaption("Options"); MenuItem caption = options.addItem("Caption", optionsCommand2); caption.setCheckable(true); caption.setChecked(true); options.addItem("Closable", optionsCommand2).setCheckable(true); options.addItem("Resizable", optionsCommand2).setCheckable(true); options.addItem("Modal", optionsCommand2).setCheckable(true); options.addStyleName("small"); addComponent(options); final Button show = new Button("Open Window", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { getUI().addWindow(win); win.center(); win.focus(); event.getButton().setEnabled(false); } }); show.addStyleName("primary"); addComponent(show); final CheckBox hidden = new CheckBox("Hidden"); hidden.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { win.setVisible(!hidden.getValue()); } }); addComponent(hidden); win.addCloseListener(new CloseListener() { @Override public void windowClose(final CloseEvent e) { show.setEnabled(true); } }); } }; p.setContent(content); return p; }