List of usage examples for com.vaadin.ui Alignment BOTTOM_CENTER
Alignment BOTTOM_CENTER
To view the source code for com.vaadin.ui Alignment BOTTOM_CENTER.
Click Source Link
From source file:fr.amapj.view.views.login.LoginPart.java
License:Open Source License
public void buildLoginView(ValoMenuLayout root, AmapUI ui, String loginFromUrl, String passwordFromUrl, String sudo) {//from w w w. jav a2 s. co m this.ui = ui; CssLayout loginAera = root.prepareForLoginPage(); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSizeFull(); loginAera.setStyleName("login-backgroundimage"); loginAera.addComponent(loginLayout); // Recuperation des parametres String nomAmap = new ParametresService().getParametres().nomAmap; ui.getPage().setTitle(nomAmap); // Zone de saisie login/password MyLoginForm myLoginForm = new MyLoginForm(loginFromUrl, passwordFromUrl, sudo, nomAmap); myLoginForm.addStyleName("login-layout"); loginLayout.addComponent(myLoginForm); loginLayout.setComponentAlignment(myLoginForm, Alignment.MIDDLE_CENTER); loginLayout.setExpandRatio(myLoginForm, 10); Label l1 = new Label("Application fonctionnant avec AmapJ - "); Link link = new Link("Plus d'infos", new ExternalResource("http://amapj.fr")); link.setTargetName("_blank"); HorizontalLayout hL = new HorizontalLayout(); hL.addComponent(l1); hL.setComponentAlignment(l1, Alignment.MIDDLE_CENTER); hL.addComponent(link); hL.setComponentAlignment(link, Alignment.MIDDLE_CENTER); hL.setMargin(true); loginLayout.addComponent(hL); loginLayout.setComponentAlignment(hL, Alignment.BOTTOM_CENTER); loginLayout.setExpandRatio(hL, 1); // Si les deux champs ont t remplis on tente une validation automatique if ((passwordFromUrl != null) && (loginFromUrl != null)) { myLoginForm.login(loginFromUrl, passwordFromUrl); } }
From source file:gq.vaccum121.ui.LoginScreen.java
License:Apache License
private void initLayout() { FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined();/*from w ww . ja v a 2 s. c o m*/ userName = new TextField("Username"); passwordField = new PasswordField("Password"); login = new Button("Login"); loginForm.addComponent(userName); loginForm.addComponent(passwordField); loginForm.addComponent(login); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { login(); } }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSizeUndefined(); loginFailedLabel = new Label(); loginLayout.addComponent(loginFailedLabel); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loggedOutLabel = new Label("Good bye!"); loginLayout.addComponent(loggedOutLabel); loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER); loggedOutLabel.setSizeUndefined(); loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS); loggedOutLabel.setVisible(false); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(rootLayout); setSizeFull(); }
From source file:jp.primecloud.auto.ui.DialogConfirm.java
License:Open Source License
public DialogConfirm(String caption, String message, Buttons buttons, Layout optionLayout) { super(caption); setModal(true);//from w w w.j a v a 2 s. c o m setResizable(false); setClosable(false); setWidth("380px"); addStyleName("dialog-confirm"); setIcon(Icons.DLGWARNING.resource()); VerticalLayout layout = (VerticalLayout) getContent(); layout.setWidth("100%"); layout.setMargin(false, true, false, true); layout.setSpacing(false); if (message != null && message.length() > 0) { // ?"\n"?"\t"???????"PREFORMATTED"?? Label lbl; if (message.indexOf("\n") != -1 || message.indexOf("\t") != -1) { lbl = new Label(message, Label.CONTENT_PREFORMATTED); } else { lbl = new Label(message, Label.CONTENT_TEXT); } lbl.addStyleName("dialog-message"); layout.addComponent(lbl); } // ???? if (optionLayout != null) { optionLayout.addStyleName("dialog-confirm-option"); addComponent(optionLayout); layout.setComponentAlignment(optionLayout, Alignment.MIDDLE_CENTER); } HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); // okButton = new Button(ViewProperties.getCaption("button.ok"), this, "buttonClick"); okButton.setDescription(ViewProperties.getCaption("description.ok")); okButton.setData(Result.OK); // [Enter]?okButton okButton.setClickShortcut(KeyCode.ENTER); okButton.focus(); cancelButton = new Button(ViewProperties.getCaption("button.cancel"), this, "buttonClick"); cancelButton.setDescription(ViewProperties.getCaption("description.cancel")); cancelButton.setData(Result.Cancel); switch (buttons) { case OK: hl.addComponent(okButton); break; case OKCancel: hl.addComponent(okButton); hl.addComponent(cancelButton); break; case OKCancelConfirm: hl.addComponent(okButton); hl.addComponent(cancelButton); okButton.setEnabled(false); confirm = new ComboBox(); confirm.setWidth("200px"); confirm.setImmediate(true); confirm.addStyleName("dialog-confirm"); confirm.setInputPrompt(ViewProperties.getCaption("description.dialogConfirmComboBox")); confirm.addItem(ViewProperties.getCaption("field.dialogConfirmComboBox")); confirm.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (confirm.getValue() != null) { okButton.setEnabled(true); } else { okButton.setEnabled(false); } } }); layout.addComponent(confirm); layout.setComponentAlignment(confirm, Alignment.MIDDLE_CENTER); break; default: break; } layout.addComponent(hl); layout.setComponentAlignment(hl, Alignment.BOTTOM_CENTER); }
From source file:kn.uni.gis.ui.AdminWindow.java
License:Apache License
private Component loginComponent() { final VerticalLayout layout = new VerticalLayout(); final PasswordField passwordField = new PasswordField("Old Hunters Age"); passwordField.setWidth("-1px"); passwordField.setHeight("-1px"); passwordField.focus();/*from w w w .j av a 2 s .c om*/ Button button_2 = new Button(); button_2.setCaption("Login"); button_2.setImmediate(false); button_2.setWidth("-1px"); button_2.setHeight("-1px"); button_2.addListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (password.equals(passwordField.getValue())) { AdminWindow.this.removeComponent(layout); AdminWindow.this.addComponent(createTable()); } else { AdminWindow.this.showNotification("Wrong age!"); } } }); layout.addComponent(passwordField); layout.addComponent(button_2); layout.setComponentAlignment(passwordField, Alignment.TOP_CENTER); layout.setComponentAlignment(button_2, Alignment.BOTTOM_CENTER); return layout; }
From source file:life.qbic.components.OfferManagerTab.java
License:Open Source License
/** * creates the tab for displaying and modifying the offers in a vaadin grid * @return vaadin component/*from ww w. j a va2 s.co m*/ * @throws SQLException: */ static Component createOfferManagerTab() throws SQLException { Database db = qOfferManager.getDb(); VerticalLayout offerManLayout = new VerticalLayout(); HorizontalLayout editSettingsLayout = new HorizontalLayout(); detailsLayout = new VerticalLayout(); editSettingsLayout.setSpacing(true); detailsLayout.setSizeFull(); ComboBox updateStatus = new ComboBox("Select Status"); updateStatus.addItem("In Progress"); updateStatus.addItem("Sent"); updateStatus.addItem("Accepted"); updateStatus.addItem("Rejected"); Button updateButton = new Button("Update"); updateButton.setIcon(FontAwesome.SPINNER); updateButton.setDescription("Click here to update the currently selected offer."); Button deleteOfferButton = new Button("Delete"); deleteOfferButton.setIcon(FontAwesome.TRASH_O); deleteOfferButton.setDescription("Click here to delete the currently selected offer."); packageGroupComboBox = new ComboBox("Select package group"); packageGroupComboBox.addItems("All", "Bioinformatics Analysis", "Mass spectrometry", "Project Management", "Sequencing", "Other"); packageGroupComboBox.setValue("All"); packageGroupComboBox.setNullSelectionAllowed(false); packageGroupComboBox .setDescription("Click here to select the package group for the packages displayed below."); Button exportTableButton = new Button("Export as .csv"); exportTableButton.setIcon(FontAwesome.DOWNLOAD); exportTableButton.setDescription("Click here to export the table as .csv file."); editSettingsLayout.addComponent(updateStatus); editSettingsLayout.addComponent(updateButton); editSettingsLayout.addComponent(deleteOfferButton); editSettingsLayout.addComponent(packageGroupComboBox); editSettingsLayout.addComponent(exportTableButton); editSettingsLayout.setComponentAlignment(updateButton, Alignment.BOTTOM_CENTER); editSettingsLayout.setComponentAlignment(deleteOfferButton, Alignment.BOTTOM_CENTER); editSettingsLayout.setComponentAlignment(packageGroupComboBox, Alignment.BOTTOM_CENTER); editSettingsLayout.setComponentAlignment(exportTableButton, Alignment.BOTTOM_CENTER); Button generateOfferButton = new Button("Download offer"); generateOfferButton.setIcon(FontAwesome.DOWNLOAD); generateOfferButton .setDescription("Select an offer from the grid then click here to download it as .docx!"); generateOfferButton.setEnabled(false); offerManLayout.setMargin(true); offerManLayout.setSpacing(true); offerManLayout.setSizeFull(); TableQuery tq = new TableQuery("offers", DBManager.getDatabaseInstanceAlternative()); tq.setVersionColumn("OPTLOCK"); SQLContainer container = new SQLContainer(tq); container.setAutoCommit(true); offerManagerGrid = new RefreshableGrid(container); // add the filters to the grid GridCellFilter filter = new GridCellFilter(offerManagerGrid); filter.setTextFilter("offer_id", true, true); filter.setTextFilter("offer_number", true, false); filter.setTextFilter("offer_project_reference", true, false); filter.setTextFilter("offer_facility", true, false); filter.setTextFilter("offer_name", true, false); filter.setTextFilter("offer_description", true, false); filter.setDateFilter("offer_date"); filter.setDateFilter("last_edited"); filter.setComboBoxFilter("offer_status", Arrays.asList("In Progress", "Sent", "Accepted", "Rejected")); offerManagerGrid.setSelectionMode(Grid.SelectionMode.SINGLE); addListeners(db, updateStatus, updateButton, deleteOfferButton, generateOfferButton, container, exportTableButton); offerManagerGrid.getColumn("offer_id").setHeaderCaption("Id").setWidth(100).setEditable(false); offerManagerGrid.getColumn("offer_number").setHeaderCaption("Quotation Number").setWidth(200) .setEditable(false); offerManagerGrid.getColumn("offer_project_reference").setHeaderCaption("Project Reference") .setEditable(false); offerManagerGrid.getColumn("offer_name").setHeaderCaption("Offer Name").setWidth(200); offerManagerGrid.getColumn("offer_facility").setHeaderCaption("Prospect"); offerManagerGrid.getColumn("offer_description").setHeaderCaption("Description").setWidth(300); offerManagerGrid.getColumn("offer_total").setHeaderCaption("Price ()").setEditable(false); offerManagerGrid.getColumn("offer_status").setHeaderCaption("Status").setEditable(false); offerManagerGrid.getColumn("offer_date").setHeaderCaption("Date").setEditable(false); offerManagerGrid.getColumn("last_edited").setHeaderCaption("Last edited").setEditable(false); offerManagerGrid.getColumn("added_by").setHeaderCaption("Added by").setEditable(false); offerManagerGrid.setColumnOrder("offer_id", "offer_project_reference", "offer_number", "offer_name", "offer_description", "offer_total", "offer_facility", "offer_status", "offer_date", "last_edited", "added_by"); offerManagerGrid.removeColumn("discount"); offerManagerGrid.removeColumn("internal"); offerManagerGrid.removeColumn("offer_group"); offerManagerGrid.removeColumn("offer_extra_price"); offerManagerGrid.removeColumn("offer_price"); offerManagerGrid.sort("offer_date", SortDirection.DESCENDING); offerManagerGrid.setWidth("100%"); offerManagerGrid.setSelectionMode(Grid.SelectionMode.SINGLE); offerManagerGrid.setEditorEnabled(true); // add tooltips to the cells offerManagerGrid.setCellDescriptionGenerator((Grid.CellDescriptionGenerator) cell -> { if (cell.getValue() == null) return null; return cell.getValue().toString(); }); // add tooltips to the header row for (Grid.Column column : offerManagerGrid.getColumns()) { Grid.HeaderCell cell = offerManagerGrid.getDefaultHeaderRow().getCell(column.getPropertyId()); String htmlWithTooltip = String.format("<span title=\"%s\">%s</span>", cell.getText(), cell.getText()); cell.setHtml(htmlWithTooltip); } offerManLayout.addComponent(offerManagerGrid); offerManLayout.addComponent(editSettingsLayout); offerManLayout.addComponent(detailsLayout); offerManLayout.addComponent(generateOfferButton); return offerManLayout; }
From source file:life.qbic.components.OfferManagerTabPackageComponent.java
License:Open Source License
/** * creates the component showing the packages of the respective package type of the currently selected offer in a * grid and enables the user to add and remove packages from the offer * @param offerGridContainer: sql container of all the offers * @param selectedOfferID: id of the currently selected offer * @param packagesType: type of the packages: "All", "Bioinformatics Analysis", "Project Management", "Sequencing", * "Mass spectrometry", "Other"; what type of packages the grid should display * @return vaadin component/*from w w w.ja v a 2 s . c o m*/ * @throws SQLException : */ static Component createOfferManagerTabPackageComponent(SQLContainer offerGridContainer, String selectedOfferID, String packagesType) throws SQLException { Database db = qOfferManager.getDb(); VerticalLayout packQuantityLayout = new VerticalLayout(); packQuantityLayout.setMargin(true); packQuantityLayout.setSpacing(true); packQuantityLayout.setSizeFull(); HorizontalLayout packSettingsLayout = new HorizontalLayout(); ComboBox packageQuantityComboBox = new ComboBox("Select Quantity"); for (int i = 1; i <= 1000; i++) packageQuantityComboBox.addItem(i); Button updateQuantityButton = new Button("Update quantity"); updateQuantityButton.setIcon(FontAwesome.SPINNER); updateQuantityButton.setDescription("Updates the quantity of the current package."); Button removePackageButton = new Button("Remove"); removePackageButton.setIcon(FontAwesome.TRASH_O); removePackageButton.setDescription("Removes the selected package from the current offer."); // we are only displaying the packages for the current package group ComboBox packagesAvailableForOfferComboBox = new ComboBox("Select package to add"); packagesAvailableForOfferComboBox.setFilteringMode(FilteringMode.CONTAINS); String selectedPackageGroup = OfferManagerTab.getPackageGroupComboBoxValue(); if (selectedPackageGroup.equals("All")) { packagesAvailableForOfferComboBox.addItems(db.getPackageIdsAndNames()); } else { packagesAvailableForOfferComboBox.addItems(db.getPackageIdsAndNames(selectedPackageGroup)); } Button addPackageButton = new Button("Add"); addPackageButton.setIcon(FontAwesome.PLUS); addPackageButton.setDescription("Adds a package to the current offer."); ComboBox externalInternalPriceComboBox = new ComboBox("External/Internal Price"); externalInternalPriceComboBox .setDescription("Select here whether the internal, the external academical or the " + "external commercial price should be used for the current selected package."); externalInternalPriceComboBox.addItems("Internal", "External academic", "External commercial"); Button externalInternalButton = new Button("Update price type"); externalInternalButton.setIcon(FontAwesome.SPINNER); externalInternalButton.setDescription( "Updates the package price type (internal/external academic/external " + "commercial) to use."); packSettingsLayout.addComponent(packageQuantityComboBox); packSettingsLayout.addComponent(updateQuantityButton); packSettingsLayout.addComponent(removePackageButton); packSettingsLayout.addComponent(packagesAvailableForOfferComboBox); packSettingsLayout.addComponent(addPackageButton); packSettingsLayout.addComponent(externalInternalPriceComboBox); packSettingsLayout.addComponent(externalInternalButton); packSettingsLayout.setComponentAlignment(updateQuantityButton, Alignment.BOTTOM_CENTER); packSettingsLayout.setComponentAlignment(removePackageButton, Alignment.BOTTOM_CENTER); packSettingsLayout.setComponentAlignment(addPackageButton, Alignment.BOTTOM_CENTER); packSettingsLayout.setComponentAlignment(externalInternalPriceComboBox, Alignment.MIDDLE_CENTER); packSettingsLayout.setComponentAlignment(externalInternalButton, Alignment.BOTTOM_CENTER); packSettingsLayout.setSpacing(true); // we need different freeform queries if 'All' package groups are selected or e.g. only 'Bioinformatics' package groups String freeformQueryString = "SELECT * " + "FROM offers " + "INNER JOIN offers_packages ON offers.`offer_id` = offers_packages.`offer_id` " + "INNER JOIN packages ON packages.`package_id` = offers_packages.`package_id`" + "WHERE offers.offer_id = " + selectedOfferID + " AND packages.`package_group` = '" + packagesType + "'"; if (Objects.equals(packagesType, "All")) { freeformQueryString = "SELECT * " + "FROM offers " + "INNER JOIN offers_packages ON offers.`offer_id` = offers_packages.`offer_id` " + "INNER JOIN packages ON packages.`package_id` = offers_packages.`package_id`" + "WHERE offers.offer_id = " + selectedOfferID; } FreeformQuery query = new FreeformQuery(freeformQueryString, DBManager.getDatabaseInstanceAlternative()); SQLContainer packsContainer = new SQLContainer(query); packsContainer.setAutoCommit(true); selectedPacksInOfferGrid = new RefreshableGrid(packsContainer); // add tooltips to the cells selectedPacksInOfferGrid.setCellDescriptionGenerator((Grid.CellDescriptionGenerator) cell -> { if (cell.getValue() == null) return null; return cell.getValue().toString(); }); // update the array lists holding the information about the packages of the current offer updatePackageArrays(packsContainer); addListeners(offerGridContainer, selectedOfferID, db, packageQuantityComboBox, updateQuantityButton, removePackageButton, packagesAvailableForOfferComboBox, addPackageButton, packsContainer, externalInternalPriceComboBox, externalInternalButton); // remove unimportant columns from the grid selectedPacksInOfferGrid.removeColumn("offer_id"); selectedPacksInOfferGrid.removeColumn("offer_number"); selectedPacksInOfferGrid.removeColumn("offer_project_reference"); selectedPacksInOfferGrid.removeColumn("offer_facility"); selectedPacksInOfferGrid.removeColumn("offer_name"); selectedPacksInOfferGrid.removeColumn("offer_description"); selectedPacksInOfferGrid.removeColumn("offer_group"); selectedPacksInOfferGrid.removeColumn("offer_price"); selectedPacksInOfferGrid.removeColumn("offer_extra_price"); selectedPacksInOfferGrid.removeColumn("offer_total"); selectedPacksInOfferGrid.removeColumn("offer_date"); selectedPacksInOfferGrid.removeColumn("offer_status"); selectedPacksInOfferGrid.removeColumn("last_edited"); selectedPacksInOfferGrid.removeColumn("added_by"); selectedPacksInOfferGrid.removeColumn("package_date"); selectedPacksInOfferGrid.removeColumn("discount"); selectedPacksInOfferGrid.removeColumn("internal"); selectedPacksInOfferGrid.removeColumn("package_grp"); // rename the header caption selectedPacksInOfferGrid.getColumn("package_id").setHeaderCaption("Id"); selectedPacksInOfferGrid.getColumn("package_addon_price").setHeaderCaption("Package total price ()"); selectedPacksInOfferGrid.getColumn("package_count").setHeaderCaption("Quantity"); selectedPacksInOfferGrid.getColumn("package_discount").setHeaderCaption("Discount"); selectedPacksInOfferGrid.getColumn("package_name").setHeaderCaption("Package Name").setWidth(200); selectedPacksInOfferGrid.getColumn("package_facility").setHeaderCaption("Package Facility"); selectedPacksInOfferGrid.getColumn("package_description").setHeaderCaption("Description").setWidth(300); selectedPacksInOfferGrid.getColumn("package_group").setHeaderCaption("Group"); selectedPacksInOfferGrid.getColumn("package_price_internal").setHeaderCaption("Internal base price ()"); selectedPacksInOfferGrid.getColumn("package_price_external_academic") .setHeaderCaption("External academic base price ()"); selectedPacksInOfferGrid.getColumn("package_price_external_commercial") .setHeaderCaption("External commercial base price ()"); selectedPacksInOfferGrid.getColumn("package_unit_type").setHeaderCaption("Unit Type"); selectedPacksInOfferGrid.getColumn("package_price_type").setHeaderCaption("Package price type"); selectedPacksInOfferGrid.setColumnOrder("package_id", "package_name", "package_description", "package_addon_price", "package_count", "package_discount", "package_group", "package_facility", "package_price_internal", "package_price_external_academic", "package_price_external_commercial", "package_price_type", "package_unit_type"); // we don't want the packages to be be editable, because this would change the package in other offers as well selectedPacksInOfferGrid.setEditorEnabled(false); selectedPacksInOfferGrid.setSelectionMode(Grid.SelectionMode.SINGLE); selectedPacksInOfferGrid.setWidth("100%"); // label showing the packages group currently displayed (e.g. "All", "Project Management", etc.) Label packagesGroupLabel = new Label("<b><u>" + packagesType + ":</u></b>", ContentMode.HTML); packQuantityLayout.addComponent(packagesGroupLabel); packQuantityLayout.addComponent(selectedPacksInOfferGrid); packQuantityLayout.addComponent(packSettingsLayout); return packQuantityLayout; }
From source file:life.qbic.components.PackageManagerTab.java
License:Open Source License
/** * creates the tab for creating new packages * @return vaadin component/*from ww w . j a v a2s . c o m*/ * @throws SQLException: */ static Component createPackageManagerTab() throws SQLException { Database db = qOfferManager.getDb(); VerticalLayout packManVerticalLayout = new VerticalLayout(); packManVerticalLayout.setMargin(true); packManVerticalLayout.setSpacing(true); packManVerticalLayout.setSizeFull(); HorizontalLayout packManHorizontalLayout = new HorizontalLayout(); packManHorizontalLayout.setSpacing(true); Button addPackageButton = new Button("New Package"); addPackageButton.setIcon(FontAwesome.PLUS); addPackageButton.setDescription("Click here to add a new package but don't forget to update the details."); ComboBox updatePackageGroupComboBox = new ComboBox("Select package group"); updatePackageGroupComboBox.addItems("Sequencing", "Project Management", "Bioinformatics Analysis", "Mass spectrometry", "Other"); updatePackageGroupComboBox.setDescription( "Select a package group for the currently selected package and hit the " + "update button."); Button updateSelectedPackageButton = new Button("Update"); updateSelectedPackageButton.setIcon(FontAwesome.SPINNER); updateSelectedPackageButton.setDescription("Click here to update the currently selected package."); Button deleteSelectedPackageButton = new Button("Delete"); deleteSelectedPackageButton.setIcon(FontAwesome.TRASH_O); deleteSelectedPackageButton.setDescription("Click here to delete the currently selected package."); Button exportTableButton = new Button("Export as .csv"); exportTableButton.setIcon(FontAwesome.DOWNLOAD); exportTableButton.setDescription("Click here to export the table as .csv file."); CheckBox calculatePricesAutomaticallyCheckBox = new CheckBox("Auto-calculate external prices"); calculatePricesAutomaticallyCheckBox .setDescription("Click here to enable/disable the automatic calculation of the " + "external prices based on the internal prices."); calculatePricesAutomaticallyCheckBox.setValue(true); TableQuery tq = new TableQuery("packages", DBManager.getDatabaseInstanceAlternative()); tq.setVersionColumn("OPTLOCK"); SQLContainer container = new SQLContainer(tq); container.setAutoCommit(true); GeneratedPropertyContainer gpcontainer = new GeneratedPropertyContainer(container); // create the column holding the offer_ids where the package is being used in // TODO: offer_ids currently not in use; since it's extremely slow.. /* gpcontainer.addGeneratedProperty("offer_ids", new PropertyValueGenerator<String>() { @Override public String getValue(Item item, Object itemId, Object propertyId) { int package_id = (Integer) item.getItemProperty("package_id").getValue(); // query offers_packages for all offer_ids of the current package ArrayList<String> offerIds = db.getOfferIdsForPackage(package_id); return String.join(",", offerIds); } @Override public Class<String> getType() { return String.class; } }); */ RefreshableGrid packageGrid = new RefreshableGrid(gpcontainer); // add the filters to the grid GridCellFilter filter = new GridCellFilter(packageGrid); filter.setTextFilter("package_id", true, true); filter.setTextFilter("package_name", true, false); filter.setTextFilter("package_facility", true, false); filter.setTextFilter("package_description", true, false); filter.setTextFilter("package_group", true, false); filter.setTextFilter("package_unit_type", true, false); filter.setComboBoxFilter("package_group", Arrays.asList("Bioinformatics Analysis", "Mass spectrometry", "Project Management", "Sequencing", "Other")); packageGrid.getColumn("package_id").setHeaderCaption("Id").setWidth(100); packageGrid.getColumn("package_name").setHeaderCaption("Name"); packageGrid.getColumn("package_facility").setHeaderCaption("Facility"); packageGrid.getColumn("package_description").setHeaderCaption("Description").setWidth(300); packageGrid.getColumn("package_group").setHeaderCaption("Package Group").setEditable(false); packageGrid.getColumn("package_price_internal").setHeaderCaption("Internal Price ()"); packageGrid.getColumn("package_price_external_academic").setHeaderCaption("Ext. Academical Price ()"); packageGrid.getColumn("package_price_external_commercial").setHeaderCaption("Ext. Commercial Price ()"); // TODO: offer_ids currently not in use; since it's extremely slow.. //packageGrid.getColumn("offer_ids").setHeaderCaption("Offer Id's"); packageGrid.getColumn("package_unit_type").setHeaderCaption("Unit Type"); /* // TODO: offer_ids currently not in use; since it's extremely slow.. packageGrid.setColumnOrder("package_id", "package_name", "package_description", "package_group", "package_facility", "package_price_internal", "package_price_external_academic", "package_price_external_commercial", "package_unit_type", "offer_ids");*/ packageGrid.setColumnOrder("package_id", "package_name", "package_description", "package_group", "package_facility", "package_price_internal", "package_price_external_academic", "package_price_external_commercial", "package_unit_type"); packageGrid.removeColumn("added_by"); packageGrid.removeColumn("package_grp"); packageGrid.removeColumn("package_date"); packageGrid.removeColumn("last_edited"); packageGrid.sort("package_name", SortDirection.ASCENDING); packageGrid.setWidth("100%"); packageGrid.setSelectionMode(Grid.SelectionMode.SINGLE); packageGrid.setEditorEnabled(true); addAutomaticPriceCalculation(calculatePricesAutomaticallyCheckBox, container, packageGrid); // add tooltips to the cells packageGrid.setCellDescriptionGenerator((Grid.CellDescriptionGenerator) cell -> { if (cell.getValue() == null) return null; return cell.getValue().toString(); }); // add tooltips to the header row for (Grid.Column column : packageGrid.getColumns()) { Grid.HeaderCell cell = packageGrid.getDefaultHeaderRow().getCell(column.getPropertyId()); String htmlWithTooltip = String.format("<span title=\"%s\">%s</span>", cell.getText(), cell.getText()); cell.setHtml(htmlWithTooltip); } addListeners(db, addPackageButton, updatePackageGroupComboBox, updateSelectedPackageButton, deleteSelectedPackageButton, container, packageGrid, exportTableButton); packManHorizontalLayout.addComponent(addPackageButton); packManHorizontalLayout.addComponent(updatePackageGroupComboBox); packManHorizontalLayout.addComponent(updateSelectedPackageButton); packManHorizontalLayout.addComponent(deleteSelectedPackageButton); packManHorizontalLayout.addComponent(exportTableButton); packManHorizontalLayout.addComponent(calculatePricesAutomaticallyCheckBox); packManHorizontalLayout.setComponentAlignment(addPackageButton, Alignment.BOTTOM_CENTER); packManHorizontalLayout.setComponentAlignment(updatePackageGroupComboBox, Alignment.MIDDLE_CENTER); packManHorizontalLayout.setComponentAlignment(updateSelectedPackageButton, Alignment.BOTTOM_CENTER); packManHorizontalLayout.setComponentAlignment(deleteSelectedPackageButton, Alignment.BOTTOM_CENTER); packManHorizontalLayout.setComponentAlignment(calculatePricesAutomaticallyCheckBox, Alignment.MIDDLE_CENTER); packManHorizontalLayout.setComponentAlignment(exportTableButton, Alignment.BOTTOM_CENTER); packManVerticalLayout.addComponent(packageGrid); packManVerticalLayout.addComponent(packManHorizontalLayout); return packManVerticalLayout; }
From source file:me.uni.emuseo.view.common.paging.PagedTableLayout.java
License:Open Source License
protected void buildNavPanel() { navigationLayout = new HorizontalLayout(); HorizontalLayout extraLayout = new HorizontalLayout(); createItemsPeerPageComboBox();/*from w ww . j a v a 2 s .co m*/ itemsPerPageComboBox.setWidth(100, Unit.PIXELS); middleLayout = new HorizontalLayout(); middleLayout.setSpacing(true); buildNavButtons(); extraLayout.addComponent(firstPageButton); extraLayout.addComponent(prevPageButton); extraLayout.addComponents(middleLayout); extraLayout.addComponent(nextPageButton); extraLayout.addComponent(lastPageButton); extraLayout.setSpacing(true); navigationLayout.addComponent(itemsPerPageComboBox); navigationLayout.addComponent(extraLayout); navigationLayout.setExpandRatio(itemsPerPageComboBox, 0); navigationLayout.setExpandRatio(extraLayout, 1); navigationLayout.setComponentAlignment(itemsPerPageComboBox, Alignment.MIDDLE_LEFT); navigationLayout.setComponentAlignment(extraLayout, Alignment.BOTTOM_CENTER); navigationLayout.setWidth(100, Unit.PERCENTAGE); navigationLayout.setMargin(new MarginInfo(false, true, false, true)); }
From source file:me.uni.emuseo.view.login.LoginView.java
License:Open Source License
public LoginView() { this.setSizeFull(); Label titleLabel = new Label("<h1>e<strong>Museo</strong></h1>", ContentMode.HTML); loginLayout = new LoginLayout(); addComponent(titleLabel);// w w w .j a v a 2 s. c o m addComponent(loginLayout); titleLabel.setWidth(150, Unit.PIXELS); setExpandRatio(titleLabel, 0); setExpandRatio(loginLayout, 1); setComponentAlignment(titleLabel, Alignment.BOTTOM_CENTER); setComponentAlignment(loginLayout, Alignment.TOP_CENTER); }
From source file:me.uni.emuseo.view.menu.MenuStartLayout.java
License:Open Source License
public MenuStartLayout() { Label welcome = new Label("Witaj w systemie"); Label systemName = new Label("<h1>e<strong>Museo</strong></h1>", ContentMode.HTML); addComponent(welcome);// ww w . j a va 2 s .co m addComponent(systemName); setComponentAlignment(welcome, Alignment.BOTTOM_CENTER); setComponentAlignment(systemName, Alignment.TOP_CENTER); welcome.setSizeUndefined(); systemName.setSizeUndefined(); setWidth(100, Unit.PERCENTAGE); setHeight(60, Unit.PERCENTAGE); }