List of usage examples for com.vaadin.ui ComboBox ComboBox
protected ComboBox(DataCommunicator<T> dataCommunicator)
From source file:jp.primecloud.auto.ui.WinServerNetworkConfig.java
License:Open Source License
WinServerNetworkConfig(Application ap, Long instanceNo, Long platformNo, InstanceNetworkDto instanceNetworkDto, List<InstanceNetworkDto> instanceNetworkDtos) { this.ap = ap; this.instanceNo = instanceNo; this.platformNo = platformNo; this.instanceNetworkDto = instanceNetworkDto; this.isAddMode = (this.instanceNetworkDto == null) ? true : false; this.instanceNetworkDtos = instanceNetworkDtos; // Window/*from w ww . ja v a 2s .com*/ if (isAddMode) { //? setIcon(Icons.ADD.resource()); setCaption(ViewProperties.getCaption("window.WinServerAddNetwork")); } else { //? setIcon(Icons.EDIT.resource()); setCaption(ViewProperties.getCaption("window.WinServerEditNetwork")); } setModal(true); setWidth("380px"); setResizable(false); // Layout VerticalLayout layout = (VerticalLayout) getContent(); layout.setMargin(true); layout.setSpacing(true); // Form Form form = new Form(); //?? networkSelect = new ComboBox(ViewProperties.getCaption("field.netWork")); networkSelect.setWidth(COMBOBOX_WIDTH); networkSelect.setNullSelectionAllowed(false); networkSelect.setItemCaptionPropertyId(CID_NETWORK); networkSelect.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); networkSelect.setImmediate(true); networkSelect.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { changeNetwork(event); } }); //IP? ipModeSelect = new ComboBox(ViewProperties.getCaption("caption.field.ipMode")); ipModeSelect.setWidth(COMBOBOX_WIDTH); ipModeSelect.setNullSelectionAllowed(false); ipModeSelect.setItemCaptionPropertyId(CID_IP_MODE); ipModeSelect.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); ipModeSelect.setImmediate(true); ipModeSelect.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { changeIpMode(event); } }); //IP ipAddressField = new TextField(ViewProperties.getCaption("field.ipAddress")); ipAddressField.setWidth("100%"); ipAddressField.setImmediate(true); //? netmaskField = new TextField(ViewProperties.getCaption("field.netmask")); netmaskField.setWidth("100%"); netmaskField.setReadOnly(true); netmaskField.setImmediate(true); // gateWayField = new TextField(ViewProperties.getCaption("field.gateway")); gateWayField.setWidth("100%"); gateWayField.setReadOnly(true); gateWayField.setImmediate(true); //DNS1 dns1Field = new TextField(ViewProperties.getCaption("field.dns1")); dns1Field.setWidth("100%"); dns1Field.setReadOnly(true); dns1Field.setImmediate(true); //DNS2 dns2Field = new TextField(ViewProperties.getCaption("field.dns2")); dns2Field.setWidth("100%"); dns2Field.setReadOnly(true); dns2Field.setImmediate(true); //Primary primaryOpg = new OptionGroup(ViewProperties.getCaption("field.primary")); primaryOpg.addItem(CID_PRIMARY); primaryOpg.setItemCaption(CID_PRIMARY, ""); primaryOpg.setNullSelectionAllowed(false); primaryOpg.setImmediate(true); form.getLayout().addComponent(networkSelect); form.getLayout().addComponent(ipModeSelect); form.getLayout().addComponent(ipAddressField); form.getLayout().addComponent(netmaskField); form.getLayout().addComponent(gateWayField); form.getLayout().addComponent(dns1Field); form.getLayout().addComponent(dns2Field); form.getLayout().addComponent(primaryOpg); layout.addComponent(form); // ?? HorizontalLayout buttonBar = new HorizontalLayout(); buttonBar.setSpacing(true); buttonBar.setMargin(false, true, true, false); layout.addComponent(buttonBar); layout.setComponentAlignment(buttonBar, Alignment.BOTTOM_RIGHT); // OK Button Button btnOk = new Button(ViewProperties.getCaption("button.ok")); btnOk.setDescription(ViewProperties.getCaption("description.ok")); btnOk.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { okButtonClick(event); } }); buttonBar.addComponent(btnOk); // [Enter]?OK btnOk.setClickShortcut(KeyCode.ENTER); //Cancel Button Button btnCancel = new Button(ViewProperties.getCaption("button.cancel")); btnCancel.setDescription(ViewProperties.getCaption("description.cancel")); btnCancel.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); buttonBar.addComponent(btnCancel); //? initData(); // showData(); // ?? initValidation(); }
From source file:life.qbic.components.OfferGeneratorTab.java
License:Open Source License
/** * creates the tab to generate the offers with the respective packages * @return vaadin component holding the offer generator *///from ww w .ja v a 2s.c o m static Component createOfferGeneratorTab() { Database db = qOfferManager.getDb(); TabSheet managerTabs = qOfferManager.getManagerTabs(); ComboBox selectedProjectComboBox = new ComboBox("Select Project"); selectedProjectComboBox.setInputPrompt("No project selected!"); selectedProjectComboBox.setDescription("Please select a project before its too late! :P"); selectedProjectComboBox.addItems(db.getProjects()); selectedProjectComboBox.setWidth("300px"); Button completeButton = new Button("Complete"); completeButton.setDescription("Click here to finalize the offer and save it into the DB!"); completeButton.setIcon(FontAwesome.CHECK_CIRCLE); completeButton.setEnabled(false); // get the package ids and names as a bean container final BeanItemContainer<String> packageIdsAndNamesContainer = new BeanItemContainer<>(String.class); packageIdsAndNamesContainer.addAll(db.getPackageIdsAndNames()); TwinColSelect selectPackagesTwinColSelect = new TwinColSelect(); selectPackagesTwinColSelect.setContainerDataSource(packageIdsAndNamesContainer); selectPackagesTwinColSelect.setLeftColumnCaption("Available packages"); selectPackagesTwinColSelect.setRightColumnCaption("Selected packages"); selectPackagesTwinColSelect.setSizeFull(); // text field which functions as a filter for the left side of the twin column select TextField twinColSelectFilter = new TextField(); twinColSelectFilter.setCaption("Filter available packages"); twinColSelectFilter.addTextChangeListener((FieldEvents.TextChangeListener) event -> { packageIdsAndNamesContainer.removeAllContainerFilters(); packageIdsAndNamesContainer.addContainerFilter(new Container.Filter() { @Override public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException { return ((String) itemId).toLowerCase().contains(event.getText().toLowerCase()) || ((Collection) selectPackagesTwinColSelect.getValue()).contains(itemId); } @Override public boolean appliesToProperty(Object propertyId) { return true; } }); }); VerticalLayout right = new VerticalLayout(); right.setSpacing(true); right.setMargin(true); VerticalLayout addPackLayout = new VerticalLayout(); addPackLayout.setMargin(true); addPackLayout.setSpacing(true); Panel packageDescriptionPanel = new Panel("Package Details"); packageDescriptionPanel.setContent(right); @SuppressWarnings("deprecation") Label packageDetailsLabel = new Label("Package details will appear here!", Label.CONTENT_XHTML); packageDetailsLabel.addStyleName(ValoTheme.LABEL_BOLD); right.addComponent(packageDetailsLabel); addListeners(db, managerTabs, selectedProjectComboBox, completeButton, addPackLayout, selectPackagesTwinColSelect, packageDescriptionPanel, packageDetailsLabel, twinColSelectFilter); addPackLayout.addComponent(selectedProjectComboBox); return addPackLayout; }
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/* w ww . j a va 2 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 va2s . c om*/ * @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/* w ww. ja v a 2s.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:management.limbr.ui.entity.EntityEditorViewImpl.java
License:Open Source License
private Field<?> getUIField(java.lang.reflect.Field field) { String label = messages.get(field.getName() + "FieldLabel"); Password passwordAnnotation = field.getAnnotation(Password.class); if (passwordAnnotation != null) { return new PasswordField(label); } else if (field.getType().isEnum()) { ComboBox comboBox = new ComboBox(label); comboBox.setTextInputAllowed(false); comboBox.addItems(field.getType().getEnumConstants()); return comboBox; }/*from w w w . ja va2 s .c o m*/ return new TextField(label); }
From source file:me.uni.emuseo.view.common.paging.PagedTableLayout.java
License:Open Source License
protected void createItemsPeerPageComboBox() { itemsPerPageComboBox = new ComboBox("Na stronie:"); itemsPerPageComboBox.addItem(5);/* w w w.j a va 2 s. c o m*/ itemsPerPageComboBox.addItem(10); itemsPerPageComboBox.addItem(15); itemsPerPageComboBox.addItem(25); itemsPerPageComboBox.setSizeUndefined(); itemsPerPageComboBox.setNewItemsAllowed(false); itemsPerPageComboBox.setNullSelectionAllowed(false); // select default itemsPerPageComboBox.select(getItemsPerPage()); ValueChangeListener itemListener = new ValueChangeListener() { private static final long serialVersionUID = 223620644065451804L; @Override public void valueChange(ValueChangeEvent event) { setItemsPerPage((Integer) event.getProperty().getValue()); } }; itemsPerPageComboBox.addValueChangeListener(itemListener); }
From source file:net.sf.gazpachoquest.questionnaires.views.login.OldLoginView.java
License:Open Source License
private ComboBox createLanguageSelector() { ComboBox languageSelector = new ComboBox("com.vaadin.demo.dashboard.DashboardUI.Language"); languageSelector.setImmediate(true); languageSelector.setNullSelectionAllowed(false); addLocale(Locale.ENGLISH, languageSelector); addLocale(Locale.FRENCH, languageSelector); addLocale(new Locale("es"), languageSelector); // languageSelector.setValue(I18NStaticService.getI18NServive().getLocale()); /*-languageSelector.addValueChangeListener(new ValueChangeListener() { /* ww w. j a v a 2 s.co m*/ private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { Locale locale = (Locale) (event.getProperty().getValue()); I18NStaticService.getI18NServive().setLocale(locale); getUI().requestRepaintAll(); } });*/ return languageSelector; }
From source file:net.sf.gazpachoquest.questionnaires.views.login.OldLoginView.java
License:Open Source License
public OldLoginView() { setSizeFull();//from www . ja v a 2s . c o m // Language bar in the top-right corner for selecting // invitation interface language final HorizontalLayout languageBar = new HorizontalLayout(); languageBar.setHeight("50px"); // addComponent(languageBar); // setComponentAlignment(languageBar, Alignment.TOP_RIGHT); // Allow selecting a language. We are in a constructor of a // CustomComponent, so preselecting the current // language of the application can not be done before // this (and the selection) component are attached to // the application. final ComboBox languageSelector = new ComboBox("Select a language") { @Override public void attach() { super.attach(); // setValue(getLocale()); } }; // for (int i=0; i<locales.length; i++) { String locale = "es"; languageSelector.addItem(locale); languageSelector.setItemCaption(locale, "espaol"); // Automatically select the current locale // if (locales[i].equals(getLocale())) languageSelector.setValue(locale); // } // Create the invitation input field invitationTextField = new TextField("Invitation key:"); invitationTextField.setWidth("300px"); invitationTextField.setRequired(true); invitationTextField.setInputPrompt("Your questionnair invitation key (eg. 12345678)"); invitationTextField.setInvalidAllowed(false); // Create login button enterButton = new Button("Enter", this); // Add both to a panel VerticalLayout fields = new VerticalLayout(languageSelector, invitationTextField, enterButton); fields.setCaption("Please enter your invitation key to access the questionnair"); fields.setSpacing(true); fields.setMargin(new MarginInfo(true, true, true, false)); fields.setSizeUndefined(); // The view root layout VerticalLayout viewLayout = new VerticalLayout(fields); viewLayout.setSizeFull(); viewLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER); viewLayout.setStyleName(Reindeer.LAYOUT_BLUE); setCompositionRoot(viewLayout); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.ProjectComponent.java
License:Apache License
private void init() { addStyleName(ValoTheme.FORMLAYOUT_LIGHT); type = new ComboBox(TRANSLATOR.translate("general.type")); FormLayout layout = new FormLayout(); setContent(layout);/* ww w .ja v a 2 s. c o m*/ BeanFieldGroup binder = new BeanFieldGroup(getProject().getClass()); binder.setItemDataSource(getProject()); name = (TextField) binder.buildAndBind(TRANSLATOR.translate("general.name"), "name", TextField.class); name.setNullRepresentation(""); notes = (TextArea) binder.buildAndBind(TRANSLATOR.translate("general.notes"), "notes", TextArea.class); getNotes().setNullRepresentation(""); getNotes().setSizeFull(); getName().setRequired(true); getName().setRequiredError(TRANSLATOR.translate("missing.name.message")); layout.addComponent(getName()); layout.addComponent(getNotes()); type.setNewItemsAllowed(false); type.setTextInputAllowed(false); type.addValidator(new NullValidator(TRANSLATOR.translate("message.required.field.missing").replaceAll("%f", TRANSLATOR.translate("general.type")), false)); BeanItemContainer<ProjectType> container = new BeanItemContainer<>(ProjectType.class, new ProjectTypeJpaController(DataBaseManager.getEntityManagerFactory()).findProjectTypeEntities()); type.setContainerDataSource(container); type.getItemIds().forEach(id -> { ProjectType temp = ((ProjectType) id); type.setItemCaption(id, TRANSLATOR.translate(temp.getTypeName())); }); layout.addComponent(type); binder.bind(type, "projectTypeId"); Button cancel = new Button(TRANSLATOR.translate("general.cancel")); cancel.addClickListener((Button.ClickEvent event) -> { binder.discard(); if (getProject().getId() == null) { ((VMUI) UI.getCurrent()).displayObject(((VMUI) UI.getCurrent()).getSelectdValue()); } else { ((VMUI) UI.getCurrent()).displayObject(getProject(), false); } }); if (edit) { if (getProject().getId() == null) { //Creating a new one getSave().addClickListener((Button.ClickEvent event) -> { if (getName().getValue() == null) { Notification.show(getName().getRequiredError(), Notification.Type.ERROR_MESSAGE); return; } getProject().setName(getName().getValue()); if (getNotes().getValue() != null) { getProject().setNotes(getNotes().getValue()); } if (type.getValue() == null) { Notification.show(type.getRequiredError(), Notification.Type.ERROR_MESSAGE); return; } getProject().setProjectTypeId((ProjectType) type.getValue()); new ProjectJpaController(DataBaseManager.getEntityManagerFactory()).create(getProject()); //Recreate the tree to show the addition ((VMUI) UI.getCurrent()).updateProjectList(); ((VMUI) UI.getCurrent()).buildProjectTree(getProject()); ((VMUI) UI.getCurrent()).displayObject(getProject(), false); ((VMUI) UI.getCurrent()).updateScreen(); }); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(getSave()); hl.addComponent(cancel); layout.addComponent(hl); } else { //Editing existing one getUpdate().addClickListener((Button.ClickEvent event) -> { ((VMUI) UI.getCurrent()).handleVersioning(getProject(), null); try { getProject().setName(getName().getValue()); if (getNotes().getValue() != null) { getProject().setNotes(getNotes().getValue()); } if (type.getValue() == null) { Notification.show(type.getRequiredError(), Notification.Type.ERROR_MESSAGE); return; } getProject().setProjectTypeId((ProjectType) type.getValue()); new ProjectJpaController(DataBaseManager.getEntityManagerFactory()).edit(getProject()); } catch (NonexistentEntityException ex) { LOG.log(Level.SEVERE, null, ex); Notification.show(TRANSLATOR.translate("general.error.record.update"), ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE); } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); Notification.show(TRANSLATOR.translate("general.error.record.update"), ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE); } //Recreate the tree to show the addition ((VMUI) UI.getCurrent()).updateProjectList(); ((VMUI) UI.getCurrent()).buildProjectTree(getProject()); ((VMUI) UI.getCurrent()).displayObject(getProject(), false); ((VMUI) UI.getCurrent()).updateScreen(); }); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(getUpdate()); hl.addComponent(cancel); layout.addComponent(hl); } } binder.setBuffered(true); binder.setReadOnly(!edit); binder.bindMemberFields(this); setSizeFull(); }