List of usage examples for com.vaadin.ui PopupView PopupView
public PopupView(PopupView.Content content)
From source file:com.cavisson.gui.dashboard.components.controls.PopupViews.java
License:Apache License
public PopupViews() { setMargin(true);//w w w. j a v a 2 s.co m Label h1 = new Label("Popup Views"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); PopupView pv = new PopupView(new Content() { @Override public Component getPopupComponent() { return new VerticalLayout() { { setMargin(true); setWidth("300px"); addComponent(new Label( "Fictum, deserunt mollit anim laborum astutumque! Magna pars studiorum, prodita quaerimus.")); } }; } @Override public String getMinimizedValueAsHTML() { return "Click to view"; } }); row.addComponent(pv); pv.setHideOnMouseOut(true); pv.setCaption("Hide on mouse-out"); pv = new PopupView(new Content() { int count = 0; @Override public Component getPopupComponent() { try { Thread.sleep(1000); } catch (InterruptedException e) { } return new VerticalLayout() { { setMargin(true); addComponent(new Label("<h3>Thanks for waiting!</h3><p>You've opened this popup <b>" + ++count + " time" + (count > 1 ? "s" : " only") + "</b>.</p>", ContentMode.HTML)); } }; } @Override public String getMinimizedValueAsHTML() { return "Show slow loading content"; } }); row.addComponent(pv); pv.setHideOnMouseOut(false); pv.setCaption("Hide on click-outside"); }
From source file:com.esofthead.mycollab.community.vaadin.web.ui.field.PopupFieldBuilder.java
License:Open Source License
public PopupView build() { view = new PopupView(new PopupView.Content() { @Override/* ww w .j a va 2 s.c o m*/ public String getMinimizedValueAsHTML() { return captionHtml; } @Override public Component getPopupComponent() { MVerticalLayout layout = new MVerticalLayout(); layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); Label infoLbl = new Label( AppContext.getMessage(GenericI18Enum.NOTIFICATION_FEATURE_NOT_AVAILABLE_IN_VERSION)); Button requestFeatureBtn = new Button("Buy the premium edition", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().addWindow(new AdWindow()); view.setPopupVisible(false); } }); requestFeatureBtn.addStyleName(UIConstants.BUTTON_ACTION); layout.with(infoLbl, requestFeatureBtn); return layout; } }); view.setDescription(description); view.setStyleName("block-popupedit"); return view; }
From source file:com.example.mmowgli_2_0.RootCards.java
/** * Depending on the type of root card created, this function creates the appropriate type of card creator *///from w w w. ja va2 s. c om private void initPopupView() { PopupView pop1; RootCardCreator creator1 = new RootCardCreator(); creator1.getTabSheet().removeTab(creator1.getTabSheet().getTab(creator1.getVerticalLayout_Root2())); pop1 = new PopupView(new PopupView.Content() { @Override public String getMinimizedValueAsHTML() { // TODO Auto-generated method stub return null; } @Override public Component getPopupComponent() { // TODO Auto-generated method stub return creator1; } }); mainLayout.addComponent(pop1); setAddCardButtonListener(pop1, root_button1); //set submit card listener setSubmitNewRootCardButtonListener(creator1, "-1"); //second popview PopupView pop2; RootCardCreator creator2 = new RootCardCreator(); creator2.getTabSheet().removeTab(creator2.getTabSheet().getTab(creator2.getVerticalLayout_Root1())); creator2.getTabSheet().getTab(creator2.getVerticalLayout_Root2()).setStyleName("Root2Main"); pop2 = new PopupView(new PopupView.Content() { @Override public String getMinimizedValueAsHTML() { // TODO Auto-generated method stub return null; } @Override public Component getPopupComponent() { // TODO Auto-generated method stub return creator2; } }); mainLayout.addComponent(pop2); setAddCardButtonListener(pop2, root_button2); setSubmitNewRootCardButtonListener(creator2, "-2"); }
From source file:com.foc.vaadin.gui.components.FVGearWrapper.java
License:Apache License
public void setComponent(C component, boolean addPopup) { dispose_Component();//from ww w . j a v a 2 s . com this.component = component; addComponentAsFirst((Component) component); if (addPopup && isEnabled()) { // In this sample we update the minimized view value with the content of // the TextField inside the popup. popup = new PopupView(new PopupTextField()); popup.addStyleName("gear"); // popup.addStyleName("v-popupview-gear"); // popup.setStyleName("v-popupview-gear"); popup.setDescription("More..."); popup.setHideOnMouseOut(true); addComponent(popup); setComponentAlignment(popup, Alignment.BOTTOM_LEFT); } }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultCompoundSearchView.java
License:Apache License
@Override public void initialize(TableColumns fields) { this.fields = fields; searchBox = new SearchBox(this); searchBox.setWidth("100%"); searchBox.setOptionHandler(new SearchOptionsHandler(fields)); searchBox.focus();//w ww . j av a2 s.com searchBox.setInputPrompt(getMessage("portlet.crud.compoundsearch.inputPrompt")); Button resetButton = new Button(getMessage("portlet.crud.compoundsearch.reset")); resetButton.setStyleName(LiferayTheme.BUTTON_LINK); resetButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { presenter.reset(); } }); PopupView infoButton = new PopupView(new Content() { @Override public String getMinimizedValueAsHTML() { return "?"; } @Override public Component getPopupComponent() { return createSearchInfo(); } }); infoButton.setHideOnMouseOut(false); searchBar = new HorizontalLayout(searchBox, resetButton, infoButton); searchBar.setWidth("100%"); searchBar.addStyleName("compsearchbar"); searchBar.setExpandRatio(searchBox, 1); searchBar.setSpacing(true); searchBar.setComponentAlignment(resetButton, Alignment.MIDDLE_CENTER); searchBar.setComponentAlignment(infoButton, Alignment.MIDDLE_CENTER); addComponent(searchBar); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.DatasetComponent.java
License:Open Source License
/** * Precondition: {DatasetView#table} has to be initialized. e.g. with * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the * Layout of this view.// w ww .ja va 2 s. c o m */ private void buildLayout() { this.vert.removeAllComponents(); this.vert.setSizeFull(); vert.setResponsive(true); // Table (containing datasets) section VerticalLayout tableSection = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); tableSection.setResponsive(true); tableSectionContent.setResponsive(true); // tableSectionContent.setCaption("Datasets"); // tableSectionContent.setIcon(FontAwesome.FLASK); // tableSection.addComponent(new Label(String.format("This project contains %s dataset(s).", // numberOfDatasets))); tableSectionContent.setMargin(new MarginInfo(true, false, true, false)); tableSection.addComponent(headerLabel); tableSectionContent.addComponent(this.table); vert.setMargin(new MarginInfo(false, true, false, false)); tableSection.setMargin(new MarginInfo(true, false, false, true)); // tableSectionContent.setMargin(true); // tableSection.setMargin(true); tableSection.addComponent(tableSectionContent); this.vert.addComponent(tableSection); table.setSizeFull(); tableSection.setSizeFull(); tableSectionContent.setSizeFull(); // this.table.setSizeFull(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, true, true)); buttonLayout.setHeight(null); // buttonLayout.setWidth("100%"); buttonLayout.setSpacing(true); buttonLayout.setResponsive(true); // final Button visualize = new Button(VISUALIZE_BUTTON_CAPTION); Button checkAll = new Button("Select all datasets"); checkAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : table.getItemIds()) { ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(true); } } }); Button uncheckAll = new Button("Unselect all datasets"); uncheckAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : table.getItemIds()) { ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(false); } } }); String content = "<p> In case of multiple file selections, Project Browser will create a tar archive.</p>" + "<hr>" + "<p> If you need help on extracting a tar archive file, follow the tips below: </p>" + "<p>" + FontAwesome.WINDOWS.getHtml() + " Windows </p>" + "<p> To open/extract TAR file on Windows, you can use 7-Zip, Easy 7-Zip, PeaZip.</p>" + "<hr>" + "<p>" + FontAwesome.APPLE.getHtml() + " MacOS </p>" + "<p> To open/extract TAR file on Mac, you can use Mac OS built-in utility Archive Utility,<br> or third-party freeware. </p>" + "<hr>" + "<p>" + FontAwesome.LINUX.getHtml() + " Linux </p>" + "<p> You need to use command tar. The tar is the GNU version of tar archiving utility. <br> " + "To extract/unpack a tar file, type: $ tar -xvf file.tar</p>"; export.setIcon(FontAwesome.DOWNLOAD); PopupView tooltip = new PopupView(new helpers.ToolTip(content)); tooltip.setHeight("44px"); HorizontalLayout help = new HorizontalLayout(); help.setSizeFull(); HorizontalLayout helpContent = new HorizontalLayout(); // helpContent.setSizeFull(); help.setMargin(new MarginInfo(false, false, false, true)); Label helpText = new Label("Attention: Click here before Download!"); helpContent.addComponent(new Label(FontAwesome.QUESTION_CIRCLE.getHtml(), ContentMode.HTML)); helpContent.addComponent(helpText); helpContent.addComponent(tooltip); helpContent.setSpacing(true); help.addComponent(helpContent); help.setComponentAlignment(helpContent, Alignment.TOP_CENTER); buttonLayout.addComponent(export); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); // buttonLayout.addComponent(visualize); buttonLayout.addComponent(this.download); /** * prepare download. */ download.setEnabled(false); download.setResource(new ExternalResource("javascript:")); // visualize.setEnabled(false); for (final Object itemId : this.table.getItemIds()) { setCheckedBox(itemId, (String) this.table.getItem(itemId).getItemProperty("CODE").getValue()); } this.table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (!event.isDoubleClick() & !((boolean) table.getItem(event.getItemId()).getItemProperty("isDirectory").getValue())) { String datasetCode = (String) table.getItem(event.getItemId()).getItemProperty("CODE") .getValue(); String datasetFileName = (String) table.getItem(event.getItemId()).getItemProperty("File Name") .getValue(); URL url; try { Resource res = null; Object parent = table.getParent(event.getItemId()); if (parent != null) { String parentDatasetFileName = (String) table.getItem(parent) .getItemProperty("File Name").getValue(); url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, parentDatasetFileName + "/" + datasetFileName); } else { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, datasetFileName); } Window subWindow = new Window(); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.setSizeFull(); subWindow.setContent(subContent); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); Boolean visualize = false; if (datasetFileName.endsWith(".pdf")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("application/pdf"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".png")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); // streamres.setMIMEType("application/png"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".qcML")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/xml"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".alleles")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".tsv")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".GSvar")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".log")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".html")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/html"); res = streamres; visualize = true; } if (visualize) { // LOGGER.debug("Is resource null?: " + String.valueOf(res == null)); BrowserFrame frame = new BrowserFrame("", res); subContent.addComponent(frame); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setSizeUndefined(); subWindow.setHeight("75%"); subWindow.setWidth("75%"); subWindow.setResizable(false); frame.setSizeFull(); frame.setHeight("100%"); // frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.9), Unit.PIXELS); // Open it in the UI ui.addWindow(subWindow); } } catch (MalformedURLException e) { LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s", datasetCode)); Notification.show( "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data", Notification.Type.ERROR_MESSAGE); } } } }); this.vert.addComponent(buttonLayout); this.vert.addComponent(help); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.LevelComponent.java
License:Open Source License
/** * Precondition: {DatasetView#table} has to be initialized. e.g. with * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the * Layout of this view./* www. j av a2 s. c o m*/ */ private void buildLayout() { this.vert.removeAllComponents(); this.vert.setWidth("100%"); // Table (containing datasets) section VerticalLayout tableSectionDatasets = new VerticalLayout(); VerticalLayout tableSectionSamples = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); HorizontalLayout sampletableSectionContent = new HorizontalLayout(); tableSectionContent.setMargin(new MarginInfo(false, false, false, false)); sampletableSectionContent.setMargin(new MarginInfo(false, false, false, false)); // tableSectionContent.setCaption("Datasets"); // tableSectionContent.setIcon(FontAwesome.FLASK); descriptionLabel.setWidth("100%"); tableSectionDatasets.addComponent(descriptionLabel); sampletableSectionContent.addComponent(sampleGrid); tableSectionContent.addComponent(this.datasetTable); tableSectionDatasets.setMargin(new MarginInfo(true, false, false, true)); tableSectionDatasets.setSpacing(true); tableSectionSamples.setMargin(new MarginInfo(true, false, true, true)); tableSectionSamples.setSpacing(true); tableSectionDatasets.addComponent(tableSectionContent); tableSectionSamples.addComponent(sampletableSectionContent); tableSectionSamples.addComponent(exportSamples); this.vert.addComponent(tableSectionDatasets); sampleGrid.setWidth("100%"); datasetTable.setWidth("100%"); tableSectionDatasets.setWidth("100%"); tableSectionSamples.setWidth("100%"); sampletableSectionContent.setWidth("100%"); tableSectionContent.setWidth("100%"); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, false, true)); buttonLayout.setHeight(null); buttonLayout.setSpacing(true); this.download.setEnabled(false); buttonLayout.setSpacing(true); Button checkAll = new Button("Select all datasets"); checkAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : datasetTable.getItemIds()) { ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(true); } } }); Button uncheckAll = new Button("Unselect all datasets"); uncheckAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : datasetTable.getItemIds()) { ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(false); } } }); buttonLayout.addComponent(exportData); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); // buttonLayout.addComponent(visualize); buttonLayout.addComponent(this.download); String content = "<p> In case of multiple file selections, Project Browser will create a tar archive.</p>" + "<hr>" + "<p> If you need help on extracting a tar archive file, follow the tips below: </p>" + "<p>" + FontAwesome.WINDOWS.getHtml() + " Windows </p>" + "<p> To open/extract TAR file on Windows, you can use 7-Zip, Easy 7-Zip, PeaZip.</p>" + "<hr>" + "<p>" + FontAwesome.APPLE.getHtml() + " MacOS </p>" + "<p> To open/extract TAR file on Mac, you can use Mac OS built-in utility Archive Utility,<br> or third-part freeware. </p>" + "<hr>" + "<p>" + FontAwesome.LINUX.getHtml() + " Linux </p>" + "<p> You need to use command tar. The tar is the GNU version of tar archiving utility. <br> " + "To extract/unpack a tar file, type: $ tar -xvf file.tar</p>"; PopupView tooltip = new PopupView(new helpers.ToolTip(content)); tooltip.setHeight("44px"); HorizontalLayout help = new HorizontalLayout(); help.setSizeFull(); HorizontalLayout helpContent = new HorizontalLayout(); // helpContent.setSizeFull(); help.setMargin(new MarginInfo(false, false, false, true)); Label helpText = new Label("Attention: Click here before Download!"); helpContent.addComponent(new Label(FontAwesome.QUESTION_CIRCLE.getHtml(), ContentMode.HTML)); helpContent.addComponent(helpText); helpContent.addComponent(tooltip); helpContent.setSpacing(true); help.addComponent(helpContent); help.setComponentAlignment(helpContent, Alignment.TOP_CENTER); /** * prepare download. */ download.setResource(new ExternalResource("javascript:")); download.setEnabled(false); for (final Object itemId : this.datasetTable.getItemIds()) { setCheckedBox(itemId, (String) this.datasetTable.getItem(itemId).getItemProperty("CODE").getValue()); } this.datasetTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (!event.isDoubleClick() & !((boolean) datasetTable.getItem(event.getItemId()) .getItemProperty("isDirectory").getValue())) { String datasetCode = (String) datasetTable.getItem(event.getItemId()).getItemProperty("CODE") .getValue(); String datasetFileName = (String) datasetTable.getItem(event.getItemId()) .getItemProperty("File Name").getValue(); URL url = null; try { Resource res = null; Object parent = datasetTable.getParent(event.getItemId()); if (parent != null) { String parentDatasetFileName = (String) datasetTable.getItem(parent) .getItemProperty("File Name").getValue(); try { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, parentDatasetFileName + "/" + URLEncoder.encode(datasetFileName, "UTF-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { try { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, URLEncoder.encode(datasetFileName, "UTF-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Window subWindow = new Window(); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.setSizeFull(); subWindow.setContent(subContent); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); Boolean visualize = false; if (datasetFileName.endsWith(".pdf")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("application/pdf"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".png")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("application/png"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".qcML")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/xml"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".alleles")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".tsv")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".log")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".html")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/html"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".GSvar")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (visualize) { BrowserFrame frame = new BrowserFrame("", res); frame.setSizeFull(); subContent.addComponent(frame); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setSizeUndefined(); subWindow.setHeight("75%"); subWindow.setWidth("75%"); subWindow.setResizable(false); frame.setSizeFull(); frame.setHeight("100%"); // frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.9), Unit.PIXELS); // Open it in the UI ui.addWindow(subWindow); } } catch (MalformedURLException e) { LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s", datasetCode)); helpers.Utils.Notification("No file attached.", "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data", "error"); // Notification // .show( // "Given dataset has no file attached to it!! Please Contact your project manager. Or // check whether it already has some data", // Notification.Type.ERROR_MESSAGE); } } } }); this.vert.addComponent(help); this.vert.addComponent(buttonLayout); this.vert.addComponent(tableSectionSamples); }
From source file:edu.vcu.csbc.vahmpexplorer.main.VaHMPExplorer.java
public Component createToolBar(boolean loggedIn) { HorizontalLayout h = new HorizontalLayout(); h.setMargin(true);// www . j a v a 2s . c o m h.setWidth("100%"); Embedded headerImg = new Embedded(null, new ThemeResource("../vahmpexplorer/img/header.png")); headerImg.setWidth(311, Embedded.UNITS_PIXELS); headerImg.setHeight(45, Embedded.UNITS_PIXELS); headerImg.setType(Embedded.TYPE_IMAGE); headerImg.setStyleName(BaseTheme.BUTTON_LINK); headerImg.setDescription("Version " + HelpMessages.VERSION); h.addComponent(headerImg); if (loggedIn) { Panel panel = new Panel(); Label loggedInUser = new Label( "Welcome: " + user.getFirstName() + " " + user.getLastName() + " (" + user.getLogin() + ")"); changePassword = new Button("Change Password"); changePassword.setStyleName(BaseTheme.BUTTON_LINK); changePassword.addListener((Button.ClickListener) this); logout = new Button("Logout"); logout.setStyleName(BaseTheme.BUTTON_LINK); logout.addListener((Button.ClickListener) this); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(changePassword); hl.addComponent(logout); panel.addComponent(loggedInUser); panel.addComponent(hl); h.addComponent(panel); h.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT); } PopupView help = new PopupView(new MainHelpPopup()); h.addComponent(help); h.setComponentAlignment(help, Alignment.MIDDLE_RIGHT); h.setComponentAlignment(headerImg, Alignment.MIDDLE_LEFT); return h; }
From source file:fr.univlorraine.mondossierweb.uicomponents.AutoComplete.java
License:Apache License
public void showChoices(List<ResultatDeRecherche> text, Layout layout, Button btnRecherche, boolean touchkitMobileDisplay) { //Si du texte est saisi if (text.size() > 0) { //Si la popup est dj instancie, on la masque if (choicesPopup != null) { choicesPopup.setPopupVisible(false); }//from w w w .j a v a 2s .com //Si c'est la premire fois que l'on affiche la popup if (choices == null) { //On cr la table contenant les propositions choices = new Table(); //Ajout du libell dans la table choices.addContainerProperty("lib", String.class, ""); //Si on est en affichage bureau, on ajoute le type if (!touchkitMobileDisplay) { choices.addContainerProperty("type", String.class, ""); } //On cache les headers des colonnes choices.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN); //la table fait la mme largeur que le composant textfield de saisie choices.setWidth(getWidth(), getWidthUnits()); //Ajout du style css googletable choices.setStyleName("googletable"); //Si on est en affichage bureau, on dtermine la main la taille des colonnes if (!touchkitMobileDisplay) { choices.setColumnWidth("lib", 596); choices.setColumnWidth("type", 100); } choices.setImmediate(true); //Gestion du clic sur une ligne de la table -> on met la valeut de la ligne dans le textField de saisie choices.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { Item i = event.getItem(); setValue(i.getItemProperty("lib").getValue().toString()); btnRecherche.click(); } }); } else { //On vide simplement la table de son contenu prcdent choices.removeAllItems(); } //On parcourt les rsultats pour les ajouter la table int i = 1; for (ResultatDeRecherche r : text) { Item item = choices.addItem(i); item.getItemProperty("lib").setValue(r.getLib()); //Si on est en affichage bureau, on ajoute le type if (!touchkitMobileDisplay) { item.getItemProperty("type").setValue(transcodeType(r.getType())); } i++; } selectedItem = 0; //On fixe la hauteur de la table en fonction du nombre de rsultats affichs choices.setHeight(38 * text.size() + 1, Unit.PIXELS); //la table fait la mme largeur que le composant textfield de saisie choices.setWidth(getWidth(), getWidthUnits()); // Si on n'a encore jamais affich la popup if (choicesPopup == null) { //on cr la popup choicesPopup = new PopupView(new PopupTextFieldContent()); //On lui ajoute le style css googlepopupview choicesPopup.setStyleName("googlepopupview"); //On ajoute la popup au layout layout.addComponent(choicesPopup); //la popup fait la mme largeur que le composant textfield de saisie choicesPopup.setWidth(getWidth(), getWidthUnits()); choices.setSelectable(true); choices.setImmediate(true); choicesPopup.addPopupVisibilityListener(new PopupVisibilityListener() { @Override public void popupVisibilityChange(PopupVisibilityEvent event) { if (!event.isPopupVisible()) { //On masque la popup quand on perd le focus sur le champ texte choicesPopup.setVisible(false); } } }); } //On affiche la popup choicesPopup.setVisible(true); choicesPopup.setPopupVisible(true); //La popup fait la mme hauteur que la table qu'elle contient choicesPopup.setHeight(choices.getHeight(), choices.getHeightUnits()); } else { //Aucun texte n'ai saisi if (choicesPopup != null) { //On masque la popup si elle est dj instancie choicesPopup.setVisible(false); choicesPopup.setPopupVisible(false); } } }
From source file:helpers.Utils.java
License:Open Source License
public static HorizontalLayout questionize(Component c, final String info, final String header) { final HorizontalLayout res = new HorizontalLayout(); res.setSpacing(true);/* w ww .j a v a 2s. c om*/ if (c instanceof CustomVisibilityComponent) { CustomVisibilityComponent custom = (CustomVisibilityComponent) c; c = custom.getInnerComponent(); custom.addListener(new VisibilityChangeListener() { @Override public void setVisible(boolean b) { res.setVisible(b); } }); } res.setVisible(c.isVisible()); res.setCaption(c.getCaption()); c.setCaption(null); res.addComponent(c); PopupView pv = new PopupView(new Content() { @Override public Component getPopupComponent() { Label l = new Label(info, ContentMode.HTML); l.setCaption(header); l.setIcon(FontAwesome.INFO); l.setWidth("250px"); l.addStyleName("info"); return new VerticalLayout(l); } @Override public String getMinimizedValueAsHTML() { return "[?]"; } }); pv.setHideOnMouseOut(false); res.addComponent(pv); return res; }