List of usage examples for com.vaadin.ui VerticalLayout setExpandRatio
public void setExpandRatio(Component component, float ratio)
This method is used to control how excess space in layout is distributed among components.
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildSupportTab(User user) { VerticalLayout root = new VerticalLayout(); root.setCaption(Language.get(Word.SUPPORT)); root.setIcon(VaadinIcons.HEADSET);/*from w w w . j a v a 2 s . co m*/ root.setWidth("100%"); root.setHeight("100%"); root.setSpacing(true); root.setMargin(true); TextArea textAreaMessage = new TextArea(Language.get(Word.MESSAGE)); textAreaMessage.setWidth("100%"); textAreaMessage.setHeight("100%"); Button buttonSend = new Button(Language.get(Word.SEND), VaadinIcons.ENVELOPE); buttonSend.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSend.addClickListener(ce -> { try { if (emailsSend.containsKey(user)) { Map<LocalDate, Integer> times = emailsSend.get(user); if (times.containsKey(LocalDate.now())) { if (times.get(LocalDate.now()) > 3) { if (times.get(LocalDate.now()) > 15) { UserUtils.banUser(user); VaadinUtils.errorNotification("BANNED DUE TO TOO MUCH EMAILS"); } else { VaadinUtils.errorNotification("TOO MUCH EMAILS"); } return; } else { times.put(LocalDate.now(), times.get(LocalDate.now()) + 1); } } else { times.put(LocalDate.now(), 1); } } else { HashMap<LocalDate, Integer> times = new HashMap<>(); times.put(LocalDate.now(), 1); emailsSend.put(user, times); } Mail.send(Props.get("supportmail"), "SUPPORT", user.toString() + "\n" + textAreaMessage.getValue()); VaadinUtils.middleInfoNotification(Language.get(Word.SUCCESSFULLY_SEND)); textAreaMessage.clear(); } catch (EmailException ex) { VaadinUtils.errorNotification(Language.get(Word.SEND_FAILED)); Log.error("Could not send Supportmail: ", ex); } }); root.addComponents(textAreaMessage, buttonSend); root.setExpandRatio(textAreaMessage, 5); root.setComponentAlignment(buttonSend, Alignment.MIDDLE_LEFT); return root; }
From source file:ed.cracken.pos.ui.purchases.PurchaserView.java
public PurchaserView() { summary = SellSummaryTo.builder().count(BigDecimal.ZERO).total(BigDecimal.ZERO).build(); setSizeFull();// w w w . j av a 2s .c om addStyleName("crud-view"); viewLogic = new PurchaserLogic(this); paymentView = new PurchaserPaymentView(); grid = new PurchaserGrid(); grid.addSelectionListener((SelectionEvent event) -> { viewLogic.editItem(grid.getSelectedRow()); }); VerticalLayout mainContent = new VerticalLayout(); HorizontalLayout foot; mainContent.addComponent(createTopBar()); mainContent.addComponent(grid); mainContent.addComponent(foot = createFooter()); mainContent.setMargin(true); mainContent.setSpacing(true); mainContent.setSizeFull(); mainContent.setExpandRatio(grid, 1); mainContent.setStyleName("crud-main-layout"); mainContent.setComponentAlignment(foot, Alignment.TOP_CENTER); addComponent(mainContent); addComponent(purchaseItemForm = new PurchaseItemForm(viewLogic)); }
From source file:ed.cracken.pos.ui.seller.SellerView.java
public SellerView() { summary = SellSummaryTo.builder().count(BigDecimal.ZERO).total(BigDecimal.ZERO).build(); setSizeFull();//from ww w .j a v a 2 s . co m addStyleName("crud-view"); viewLogic = new SellerLogic(this); paymentView = new SellerPaymentView(); grid = new SellerGrid(); grid.addSelectionListener((SelectionEvent event) -> { viewLogic.editItem(grid.getSelectedRow()); }); VerticalLayout barAndGridLayout = new VerticalLayout(); HorizontalLayout foot; barAndGridLayout.addComponent(createTopBar()); barAndGridLayout.addComponent(grid); barAndGridLayout.addComponent(foot = createFooter()); barAndGridLayout.setMargin(true); barAndGridLayout.setSpacing(true); barAndGridLayout.setSizeFull(); barAndGridLayout.setExpandRatio(grid, 1); barAndGridLayout.setStyleName("crud-main-layout"); barAndGridLayout.setComponentAlignment(foot, Alignment.TOP_CENTER); addComponent(barAndGridLayout); addComponent(sellItemForm = new SellItemForm(viewLogic)); }
From source file:edu.cornell.qatarmed.planrnaseq.AnnotateRNAseqSQL.java
private void initLayout() { /* Root of the user interface component tree is set */ HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); setContent(splitPanel);/*from w w w.ja v a 2 s.c om*/ /* Build the component tree */ VerticalLayout leftLayout = new VerticalLayout(); VerticalSplitPanel rightSplitPanel = new VerticalSplitPanel(); // VerticalSplitPanel leftSplitPanel = new VerticalSplitPanel(); splitPanel.addComponent(leftLayout); splitPanel.addComponent(rightSplitPanel); VerticalLayout rightTopLayout = new VerticalLayout(); // rightTopLayout.addComponent(rightTopForm); rightTopTabsheet.setSizeFull(); rightTopLayout.addComponent(rightTopTabsheet); rightTopTabsheet.addTab(rightTopForm, "Study Details"); rightTopTabsheet.addTab(rightTopAnnotationForm, "Annotate"); rightTopLayout.setSizeFull(); rightSplitPanel.addComponent(rightTopLayout); HorizontalSplitPanel rightBottomLayout = new HorizontalSplitPanel(); // HorizontalLayout rightBottomLayout = new HorizontalLayout(); VerticalLayout rightBottomLeftLayout = new VerticalLayout(); VerticalLayout rightBottomRightLayout = new VerticalLayout(); rightBottomLayout.addComponent(rightBottomLeftLayout); rightBottomLayout.addComponent(rightBottomRightLayout); // rightBottomLayout.setExpandRatio(rightBottomLeftLayout, 1); // rightBottomLayout.setExpandRatio(rightBottomRightLayout, 3); rightBottomLayout.setSplitPosition(30f, Unit.PERCENTAGE); rightBottomLayout.setSizeFull(); rightBottomTabsheet.setSizeFull(); rightSplitPanel.addComponent(rightBottomLayout); splitPanel.setSplitPosition(50f, Unit.PERCENTAGE); // rightSplitPanel.setWidth("20%"); /* //make form asking parameters and add it to leftLaayout VerticalLayout formLayout = new VerticalLayout(); // TextField studyName = new TextField("RNAseq Study Name"); formLayout.addComponent(studyName); List replist = new ArrayList(); ComboBox numReplicates = new ComboBox("Replicates", replist); formLayout.addComponent(numReplicates); leftLayout.addComponent(formLayout); */ HorizontalLayout leftTopLayout = new HorizontalLayout(); leftLayout.addComponent(leftTopLayout); leftTopLayout.addComponent(searchField); leftTopLayout.addComponent(searchButton); leftTopLayout.setWidth("100%"); searchField.setWidth("100%"); leftTopLayout.setExpandRatio(searchField, 1); leftLayout.addComponent(bioprojectSummaryTable); // leftLayout.setExpandRatio(searchField, 0); leftLayout.setExpandRatio(bioprojectSummaryTable, 1); bioprojectSummaryTable.setSizeFull(); /* Set the contents in the left of the split panel to use all the space */ leftLayout.setSizeFull(); /* VerticalLayout resultLayout = new VerticalLayout(); rightLayout.addComponent(resultLayout); VerticalLayout chartLayout = new VerticalLayout(); rightLayout.addComponent(chartLayout); chartLayout.setVisible(false); */ rightBottomLeftLayout.addComponent(tree); rightBottomRightLayout.addComponent(rightBottomTabsheet); rightBottomTabsheet.addTab(myform, "Selected Biosample"); myform.setSizeFull(); VerticalLayout rbTabBiosampleSummaryLayout = new VerticalLayout(); // Right bottom Biosample Summary rightBottomTabsheet.addTab(rbTabBiosampleSummaryLayout, "All Biosamples"); rbTabBiosampleSummaryLayout.addComponent(biosampleSummaryTable); rbTabBiosampleSummaryLayout.setSizeFull(); initDataAndSubcomponent(); rightTopLayout.setSizeFull(); rightBottomRightLayout.setSizeFull(); }
From source file:edu.cornell.qatarmed.planrnaseq.AnnotateView.java
public void initLayout() { /* Root of the user interface component tree is set */ HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); addComponent(splitPanel);/*from w ww. ja v a 2s. c o m*/ // panel = new Panel(); // panel.setContent(splitPanel); splitPanel.setSizeFull(); //setCompositionRoot(splitPanel); // panel.setContent(splitPanel); /* Build the component tree */ VerticalLayout leftLayout = new VerticalLayout(); VerticalSplitPanel rightSplitPanel = new VerticalSplitPanel(); // VerticalSplitPanel leftSplitPanel = new VerticalSplitPanel(); splitPanel.addComponent(leftLayout); splitPanel.addComponent(rightSplitPanel); VerticalLayout rightTopLayout = new VerticalLayout(); // rightTopLayout.addComponent(rightTopForm); rightTopTabsheet.setSizeFull(); rightTopLayout.addComponent(rightTopTabsheet); rightTopTabsheet.addTab(rightTopForm, "Study Details"); rightTopTabsheet.addTab(rightTopAnnotationForm, "Annotate"); rightTopLayout.setSizeFull(); rightSplitPanel.addComponent(rightTopLayout); HorizontalSplitPanel rightBottomLayout = new HorizontalSplitPanel(); // HorizontalLayout rightBottomLayout = new HorizontalLayout(); VerticalLayout rightBottomLeftLayout = new VerticalLayout(); VerticalLayout rightBottomRightLayout = new VerticalLayout(); rightBottomLayout.addComponent(rightBottomLeftLayout); rightBottomLayout.addComponent(rightBottomRightLayout); // rightBottomLayout.setExpandRatio(rightBottomLeftLayout, 1); // rightBottomLayout.setExpandRatio(rightBottomRightLayout, 3); rightBottomLayout.setSplitPosition(30f, Unit.PERCENTAGE); rightBottomLayout.setSizeFull(); rightBottomTabsheet.setSizeFull(); rightSplitPanel.addComponent(rightBottomLayout); splitPanel.setSplitPosition(50f, Unit.PERCENTAGE); // rightSplitPanel.setWidth("20%"); /* //make form asking parameters and add it to leftLaayout VerticalLayout formLayout = new VerticalLayout(); // TextField studyName = new TextField("RNAseq Study Name"); formLayout.addComponent(studyName); List replist = new ArrayList(); ComboBox numReplicates = new ComboBox("Replicates", replist); formLayout.addComponent(numReplicates); leftLayout.addComponent(formLayout); */ HorizontalLayout leftTopLayout = new HorizontalLayout(); leftLayout.addComponent(leftTopLayout); leftTopLayout.addComponent(searchField); leftTopLayout.addComponent(searchButton); leftTopLayout.setWidth("100%"); searchField.setWidth("100%"); leftTopLayout.setExpandRatio(searchField, 1); leftLayout.addComponent(bioprojectSummaryTable); // leftLayout.setExpandRatio(searchField, 0); leftLayout.setExpandRatio(bioprojectSummaryTable, 1); bioprojectSummaryTable.setSizeFull(); /* Set the contents in the left of the split panel to use all the space */ leftLayout.setSizeFull(); /* VerticalLayout resultLayout = new VerticalLayout(); rightLayout.addComponent(resultLayout); VerticalLayout chartLayout = new VerticalLayout(); rightLayout.addComponent(chartLayout); chartLayout.setVisible(false); */ rightBottomLeftLayout.addComponent(tree); rightBottomRightLayout.addComponent(rightBottomTabsheet); rightBottomTabsheet.addTab(myform, "Selected Biosample"); myform.setSizeFull(); VerticalLayout rbTabBiosampleSummaryLayout = new VerticalLayout(); // Right bottom Biosample Summary rightBottomTabsheet.addTab(rbTabBiosampleSummaryLayout, "All Biosamples"); rbTabBiosampleSummaryLayout.addComponent(biosampleSummaryTable); rbTabBiosampleSummaryLayout.setSizeFull(); initDataAndSubcomponent(); rightTopLayout.setSizeFull(); rightBottomRightLayout.setSizeFull(); }
From source file:edu.cornell.qatarmed.planrnaseq.BrowseAndAnnotate.java
public void initLayout() { /* Root of the user interface component tree is set */ VerticalLayout mainLayout = new VerticalLayout(); Label titleLabel = new Label("<span style=\"color:rgb(255,255,255)\">MetaRNA-Seq: An interactive " + "tool to browse and annotate RNA-Seq meta-data</span>", ContentMode.HTML); titleLabel.addStyleName("maintitle"); HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); mainLayout.addComponent(titleLabel); mainLayout.addComponent(splitPanel); setContent(mainLayout);/* w w w . j a va2 s . com*/ splitPanel.setSizeFull(); mainLayout.setSizeFull(); mainLayout.setExpandRatio(splitPanel, 1); /* Build the component tree */ // VerticalLayout leftLayout = new VerticalLayout(); // moved this to class level as it is been accessed by other function VerticalSplitPanel rightSplitPanel = new VerticalSplitPanel(); // VerticalSplitPanel leftSplitPanel = new VerticalSplitPanel(); splitPanel.addComponent(leftLayout); splitPanel.addComponent(rightSplitPanel); VerticalLayout rightTopLayout = new VerticalLayout(); // rightTopLayout.addComponent(rightTopForm); rightTopTabsheet.setSizeFull(); rightTopLayout.addComponent(rightTopTabsheet); rightTopTabsheet.addTab(startHelpLayout, "Start Help"); StartHelp sh = new StartHelp(); startHelpLayout.addComponent(sh); rightTopTabsheet.addTab(rightTopForm, "Study Details"); rightTopTabsheet.addTab(rightTopAnnotationForm, "Annotate"); rightTopLayout.setSizeFull(); rightSplitPanel.addComponent(rightTopLayout); HorizontalSplitPanel rightBottomLayout = new HorizontalSplitPanel(); // HorizontalLayout rightBottomLayout = new HorizontalLayout(); VerticalLayout rightBottomLeftLayout = new VerticalLayout(); VerticalLayout rightBottomRightLayout = new VerticalLayout(); rightBottomLayout.addComponent(rightBottomLeftLayout); rightBottomLayout.addComponent(rightBottomRightLayout); // rightBottomLayout.setExpandRatio(rightBottomLeftLayout, 1); // rightBottomLayout.setExpandRatio(rightBottomRightLayout, 3); rightBottomLayout.setSplitPosition(30f, Unit.PERCENTAGE); rightBottomLayout.setSizeFull(); rightBottomTabsheet.setSizeFull(); rightSplitPanel.addComponent(rightBottomLayout); splitPanel.setSplitPosition(50f, Unit.PERCENTAGE); //HorizontalLayout leftTopLayout = new HorizontalLayout(); // moved this to class level as it is been accessed by other function leftLayout.addComponent(leftTopLayout); leftTopLayout.addComponent(searchField); leftTopLayout.addComponent(searchButton); leftTopLayout.addComponent(slowSearchButton); leftTopLayout.addComponent(guidedSearchButton); leftTopLayout.setWidth("100%"); searchField.setWidth("100%"); leftTopLayout.setExpandRatio(searchField, 1); leftLayout.addComponent(bioprojectSummaryTable); // leftLayout.setExpandRatio(searchField, 0); leftLayout.setExpandRatio(bioprojectSummaryTable, 1); bioprojectSummaryTable.setSizeFull(); /* Set the contents in the left of the split panel to use all the space */ leftLayout.setSizeFull(); rightBottomLeftLayout.addComponent(tree); rightBottomRightLayout.addComponent(rightBottomTabsheet); rightBottomTabsheet.addTab(myform, "Details of selected Item"); myform.setSizeFull(); VerticalLayout rbTabBiosampleSummaryLayout = new VerticalLayout(); // Right bottom Biosample Summary // rightBottomTabsheet.addTab(rbTabBiosampleSummaryLayout, "All Biosamples"); rbTabBiosampleSummaryLayout.addComponent(biosampleSummaryTable); rbTabBiosampleSummaryLayout.setSizeFull(); initDataAndSubcomponent(); rightTopLayout.setSizeFull(); rightBottomRightLayout.setSizeFull(); }
From source file:edu.kit.dama.ui.admin.administration.usergroup.GroupMembershipEditorWindow.java
License:Apache License
private GridLayout getMainLayout() throws AuthorizationException, UnsupportedEnumException { if (mainPanel == null) { String id = "mainPanel"; LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ..."); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(2, 2); //add table and exclude button builder.addComponent(getMembersTable(), 0, 0).addComponent(getExcludeMembersButton(), Alignment.BOTTOM_LEFT, 0, 1, 1, 1); Label l = new Label( "To add members select them in the list below and click <i>'Add Member(s)'</i>. To exclude members select them in the table and click <i>'Exclude Member(s)'</i>", ContentMode.HTML); Button closeButton = new Button("Close"); closeButton.addClickListener((event) -> { close();/*from w w w . j av a2 s . c o m*/ }); VerticalLayout actionLayout = new VerticalLayout(l, getUserSelector(), getAddMembersButton()); actionLayout.setComponentAlignment(l, Alignment.TOP_CENTER); actionLayout.setComponentAlignment(getUserSelector(), Alignment.TOP_RIGHT); actionLayout.setComponentAlignment(getAddMembersButton(), Alignment.TOP_RIGHT); actionLayout.setExpandRatio(getUserSelector(), 1.0f); actionLayout.setSpacing(true); actionLayout.setSizeFull(); builder.addComponent(actionLayout, 1, 0, 1, 1).addComponent(closeButton, Alignment.BOTTOM_RIGHT, 1, 1, 1, 1); mainPanel = builder.getLayout(); mainPanel.setId(DEBUG_ID_PREFIX + id); mainPanel.setSizeFull(); mainPanel.setColumnExpandRatio(0, .7f); mainPanel.setColumnExpandRatio(1, .3f); mainPanel.setRowExpandRatio(0, .99f); mainPanel.setRowExpandRatio(1, .01f); mainPanel.setSpacing(true); mainPanel.setMargin(true); updateMainPanel(); } return mainPanel; }
From source file:edu.kit.dama.ui.admin.wizard.FirstStartWizard.java
License:Apache License
private void buildMainLayout() { stepLayout = new VerticalLayout(); back.setEnabled(false);//from w w w .j av a 2 s. c om stepLayout.addComponent(stepList[currentStep]); stepLayout.setComponentAlignment(stepList[currentStep], Alignment.TOP_RIGHT); stepLayout.setSpacing(false); stepLayout.setMargin(false); stepLayout.setWidth("100%"); stepLayout.setHeight("500px"); final VerticalLayout stepLabels = new VerticalLayout(); for (WizardStep step : stepList) { Label stepLabel = new Label(step.getStepName()); stepLabel.setWidth("250px"); stepLabels.addComponent(stepLabel); stepLabels.setComponentAlignment(stepLabel, Alignment.TOP_LEFT); } //make introduction label bold stepLabels.getComponent(0).addStyleName("myboldcaption"); Label spacer = new Label(); stepLabels.addComponent(spacer); stepLabels.setExpandRatio(spacer, 1.0f); stepLabels.setWidth("275px"); stepLabels.setHeight("550px"); stepLabels.setSpacing(true); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(2, 2); HorizontalLayout buttonLayout = new HorizontalLayout(back, next); buttonLayout.setSizeFull(); buttonLayout.setComponentAlignment(back, Alignment.BOTTOM_RIGHT); buttonLayout.setComponentAlignment(next, Alignment.BOTTOM_RIGHT); buttonLayout.setExpandRatio(back, 1.0f); next.addClickListener((event) -> { if ("Go To Login".equals(next.getCaption())) { Page.getCurrent().reload(); } else if ("Finish".equals(next.getCaption())) { //do finish WizardPersistHelper helper = new WizardPersistHelper(); if (helper.persist(properties)) { UIUtils7.showInformation("Success", "All information have been successfully stored into the database. For details, please refer to the log output above.\n" + "You may now dismiss this message and click 'Go To Login' in order to access the login page.\n" + "From there you can to login using your administrator account or create a personalized user account.", 3000); back.setVisible(false); next.setCaption("Go To Login"); } else { UIUtils7.showError("Failed to store collected information in database.\n" + "Please refer to the log output above."); } ((WizardSummary) stepList[currentStep]).setSummary(helper.getMessages()); } else { if (currentStep + 1 <= stepList.length - 1) { if (stepList[currentStep].validate()) { stepList[currentStep].collectProperties(properties); currentStep++; stepLayout.replaceComponent(stepList[currentStep - 1], stepList[currentStep]); Label currentLabel = (Label) stepLabels.getComponent(currentStep); Label prevLabel = (Label) stepLabels.getComponent(currentStep - 1); currentLabel.addStyleName("myboldcaption"); prevLabel.removeStyleName("myboldcaption"); if (stepList[currentStep] instanceof WizardSummary) { StringBuilder summary = new StringBuilder(); for (WizardStep step : stepList) { summary.append(step.getSummary()).append("\n"); } ((WizardSummary) stepList[currentStep]).setSummary(summary.toString()); } } } if (currentStep == stepList.length - 1) { //finish next.setCaption("Finish"); } else { next.setCaption("Next"); } back.setEnabled(true); } }); back.addClickListener((event) -> { if (currentStep - 1 >= 0) { stepList[currentStep].collectProperties(properties); currentStep--; stepLayout.replaceComponent(stepList[currentStep + 1], stepList[currentStep]); Label currentLabel = (Label) stepLabels.getComponent(currentStep); Label prevLabel = (Label) stepLabels.getComponent(currentStep + 1); currentLabel.addStyleName("myboldcaption"); prevLabel.removeStyleName("myboldcaption"); } next.setEnabled(true); back.setEnabled(currentStep > 0); next.setCaption("Next"); }); builder.addComponent(stepLabels, Alignment.TOP_LEFT, 0, 0, 1, 2); builder.addComponent(stepLayout, Alignment.TOP_LEFT, 1, 0, 1, 1); builder.addComponent(buttonLayout, Alignment.BOTTOM_LEFT, 1, 1, 1, 1); mainLayout = builder.getLayout(); mainLayout.setMargin(true); mainLayout.setSizeFull(); // mainLayout.setColumnExpandRatio(0, .3f); mainLayout.setColumnExpandRatio(1, 1f); mainLayout.setRowExpandRatio(0, .95f); mainLayout.setRowExpandRatio(1, .05f); }
From source file:edu.kit.dama.ui.commons.util.PaginationLayout.java
License:Apache License
/** * Fill the pagination listing based on a specific query to obtain valid * objects.//from w w w. ja v a2 s . c o m */ private void renderPage() { //obtain the objects of this page (5 entries per page are shown) int start = currentPage * entriesPerPage; //initialize page panel and layout page = new Panel(); page.setCaption(caption); page.setImmediate(true); page.setIcon(icon); VerticalLayout pageLayout = new VerticalLayout(); pageLayout.setMargin(true); pageLayout.setImmediate(true); pageLayout.setSizeUndefined(); page.setSizeFull(); List<C> entries; if (overallEntries > 0) { AbstractComponent header = callback.renderHeader(); if (header != null) { pageLayout.addComponent(header); pageLayout.setComponentAlignment(header, Alignment.TOP_LEFT); } entries = callback.getEntries(this, start); //add all objects of this page int objectIdx = 1; for (C entry : entries) { AbstractComponent renderedEntry = callback.renderEntry(entry, start + objectIdx); pageLayout.addComponent(renderedEntry); pageLayout.setComponentAlignment(renderedEntry, Alignment.TOP_CENTER); Label spacer = new Label("<hr/>", Label.CONTENT_XHTML); spacer.setHeight("3px"); spacer.setWidth("100%"); pageLayout.addComponent(spacer); pageLayout.setComponentAlignment(spacer, Alignment.TOP_CENTER); objectIdx++; } //if there are less than 'entriesPerPage' entries, add a 'filler' to keep the actual items on top of the layout if (objectIdx < entriesPerPage) { Label filler = new Label(); pageLayout.addComponent(filler); pageLayout.setExpandRatio(filler, 1.0f); } } else { //nothing visible Label filler = new Label("No entries available"); pageLayout.addComponent(filler); pageLayout.setExpandRatio(filler, 1.0f); } page.setContent(pageLayout); }
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 . java 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(); }