List of usage examples for com.vaadin.server FontAwesome PLUS
FontAwesome PLUS
To view the source code for com.vaadin.server FontAwesome PLUS.
Click Source Link
From source file:com.terralcode.gestion.frontend.view.widgets.example.crudtestform.CrudExampleForm.java
protected Component buildContent() { initTable();// w ww . j a va 2 s . c o m table.setPageLength(table.size()); addMenuItems(new MenuBar().new MenuItem("", FontAwesome.PLUS, add()), new MenuBar().new MenuItem("", FontAwesome.EDIT, edit()), new MenuBar().new MenuItem("", FontAwesome.SAVE, save()), new MenuBar().new MenuItem("", FontAwesome.TRASH_O, delete())); return table; }
From source file:de.metas.procurement.webui.ui.view.DailyReportingView.java
License:Open Source License
public DailyReportingView() { super();//from ww w . j a v a 2 s .c om addStyleName(STYLE); // // Top { final NavigationBar navigationBar = getNavigationBar(); navigationBar.setCaption(i18n.get("DailyReportingView.caption")); final NavigationButton logoutButton = new NavigationButton(i18n.get("Logout.caption")); logoutButton.setTargetView(this); logoutButton.addClickListener(new NavigationButtonClickListener() { @Override public void buttonClick(final NavigationButtonClickEvent event) { onLogout(); } }); navigationBar.setRightComponent(logoutButton); } // // Content { final VerticalLayout content = new VerticalLayout(); // Date { datePanel = new DateNavigation(); datePanel.addDateChangedListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent evt) { onDayChanged(datePanel.getDate()); } }); final VerticalComponentGroup datePanelGroup = new VerticalComponentGroup(); datePanelGroup.addComponent(datePanel); content.addComponent(datePanelGroup); } // Product buttons productButtons = new BeansVerticalComponentGroup<ProductQtyReport>() { @Override protected Component createItemComponent(final BeanItem<ProductQtyReport> item) { final ProductItemButton itemComp = new ProductItemButton(); itemComp.setItem(item); return itemComp; }; }; content.addComponent(productButtons); setContent(content); } // // Toolbar (bottom) { final Button weekViewButton = new Button(i18n.get("DailyReportingView.weekViewButton")); weekViewButton.setStyleName("no-decoration"); weekViewButton.setIcon(FontAwesome.CALENDAR); weekViewButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onWeekView(); } }); final Button addProductButton = new Button(i18n.get("DailyReportingView.addProductButton")); addProductButton.setStyleName("no-decoration"); addProductButton.setIcon(FontAwesome.PLUS); addProductButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onProductAdd(); } }); final Button rfqButton = new Button(i18n.get("DailyReportingView.rfqButton")); rfqButton.setStyleName("no-decoration"); rfqButton.setIcon(FontAwesome.MONEY); rfqButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onRfQ(); } }); final ISendService sendService = MFProcurementUI.getCurrentMFSession().getSendService(); final Button sendButton = new Button(i18n.get("DailyReportingView.sendButton")); sendButton.setStyleName("no-decoration"); sendButton.setIcon(FontAwesome.CHECK); final TextOverlay sendButtonOverlay = TextOverlay.extend(sendButton); sendButtonOverlay.setPropertyDataSource(sendService.getNotSentCounterProperty()); sendButtonOverlay.setConverter(TextOverlay.CONVERTER_PositiveCounterOrNull); sendButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onSend(); } }); final Button infoButton = new Button(i18n.getWithDefault("InfoMessageView.caption.short", "Info")); infoButton.setStyleName("no-decoration"); infoButton.setIcon(FontAwesome.INFO); infoButton.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { onInfo(); } }); final Toolbar toolbar = new Toolbar(); toolbar.addComponents(weekViewButton, addProductButton, sendButton, infoButton, rfqButton); setToolbar(toolbar); } // // Initialize final Date today = DateUtils.getToday(); final Date date = DateUtils.addDays(today, +1); // tomorrow (FRESH-196) datePanel.setDate(date); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.QbicmainportletUI.java
License:Open Source License
/** * /*from ww w . j a va2 s . c o m*/ * @param datahandler * @param request * @param user */ public void buildMainLayout(DataHandler datahandler, VaadinRequest request, String user) { State state = (State) UI.getCurrent().getSession().getAttribute("state"); MultiscaleController multiscaleController = new MultiscaleController(datahandler.getOpenBisClient(), user); final HomeView homeView = new HomeView(datahandler, "Your Projects", user, state, resUrl, manager.getTmpFolder()); DatasetView datasetView = new DatasetView(datahandler, state, resUrl); final SampleView sampleView = new SampleView(datahandler, state, resUrl, multiscaleController); // BarcodeView barcodeView = // new BarcodeView(datahandler.getOpenBisClient(), manager.getBarcodeScriptsFolder(), // manager.getBarcodePathVariable()); final ExperimentView experimentView = new ExperimentView(datahandler, state, resUrl, multiscaleController); // ChangePropertiesView changepropertiesView = new ChangePropertiesView(datahandler); final AddPatientView addPatientView = new AddPatientView(datahandler, state, resUrl); final SearchResultsView searchResultsView = new SearchResultsView(datahandler, "Search results", user, state, resUrl); Submitter submitter = null; try { submitter = WorkflowSubmitterFactory.getSubmitter(Type.guseSubmitter, manager); } catch (Exception e1) { e1.printStackTrace(); } WorkflowViewController controller = new WorkflowViewController(submitter, datahandler, user); final ProjectView projectView = new ProjectView(datahandler, state, resUrl, controller, manager); final PatientView patientView = new PatientView(datahandler, state, resUrl, controller, manager); VerticalLayout navigatorContent = new VerticalLayout(); // navigatorContent.setResponsive(true); final Navigator navigator = new Navigator(UI.getCurrent(), navigatorContent); navigator.addView(DatasetView.navigateToLabel, datasetView); navigator.addView(SampleView.navigateToLabel, sampleView); navigator.addView("", homeView); navigator.addView(ProjectView.navigateToLabel, projectView); // navigator.addView(BarcodeView.navigateToLabel, barcodeView); navigator.addView(ExperimentView.navigateToLabel, experimentView); navigator.addView(PatientView.navigateToLabel, patientView); navigator.addView(AddPatientView.navigateToLabel, addPatientView); navigator.addView(SearchResultsView.navigateToLabel, searchResultsView); setNavigator(navigator); // Production // mainLayout = new VerticalLayout(); for (Window w : getWindows()) { w.setSizeFull(); } mainLayout = new GridLayout(3, 3); mainLayout.setResponsive(true); mainLayout.setWidth(100, Unit.PERCENTAGE); mainLayout.addComponent(navigatorContent, 0, 1, 2, 1); mainLayout.setColumnExpandRatio(0, 0.2f); mainLayout.setColumnExpandRatio(1, 0.3f); mainLayout.setColumnExpandRatio(2, 0.5f); // Production // HorizontalLayout treeViewAndLevelView = new HorizontalLayout(); // HorizontalLayout headerView = new HorizontalLayout(); // headerView.setSpacing(false); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); // final HorizontalLayout labelLayout = new HorizontalLayout(); // headerView.addComponent(buttonLayout); // headerView.addComponent(labelLayout); Button homeButton = new Button("Home"); homeButton.setIcon(FontAwesome.HOME); homeButton.setResponsive(true); homeButton.setStyleName(ValoTheme.BUTTON_LARGE); homeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { navigator.navigateTo(""); } }); // Production buttonLayout.addComponent(homeButton); // mainLayout.addComponent(homeButton, 0, 0); Boolean includePatientCreation = false; List<Project> projects = datahandler.getOpenBisClient().getOpenbisInfoService() .listProjectsOnBehalfOfUser(datahandler.getOpenBisClient().getSessionToken(), user); int numberOfProjects = 0; for (Project project : projects) { if (project.getSpaceCode().contains("IVAC")) { includePatientCreation = true; } numberOfProjects += 1; } // add patient button if (includePatientCreation) { Button addPatient = new Button("Add Patient"); addPatient.setIcon(FontAwesome.PLUS); addPatient.setStyleName(ValoTheme.BUTTON_LARGE); addPatient.setResponsive(true); // addPatient.setStyleName("addpatient"); addPatient.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().getNavigator().navigateTo(String.format(AddPatientView.navigateToLabel)); } }); // Production buttonLayout.addComponent(addPatient); // mainLayout.addComponent(addPatient, 1, 0); } mainLayout.addComponent(buttonLayout, 0, 0); Button header = new Button(String.format("Total number of projects: %s", numberOfProjects)); header.setIcon(FontAwesome.HAND_O_RIGHT); header.setStyleName(ValoTheme.BUTTON_LARGE); header.addStyleName(ValoTheme.BUTTON_BORDERLESS); // Production // labelLayout.addComponent(header); // labelLayout.setWidth(null); SearchEngineView searchBarView = new SearchEngineView(datahandler); // headerView.setWidth("100%"); // Production // headerView.addComponent(searchBarView); // headerView.setComponentAlignment(searchBarView, Alignment.TOP_RIGHT); // searchBarView.setSizeUndefined(); // treeViewAndLevelView.addComponent(navigatorContent); // mainLayout.addComponent(headerView); // mainLayout.addComponent(treeViewAndLevelView); mainLayout.addComponent(header, 1, 0); mainLayout.addComponent(searchBarView, 2, 0); // Production VerticalLayout versionLayout = new VerticalLayout(); versionLayout.setWidth(100, Unit.PERCENTAGE); Label versionLabel = new Label(String.format("version: %s", version)); Label revisionLabel = new Label(String.format("rev: %s", revision)); revisionLabel.setWidth(null); versionLabel.setWidth(null); versionLayout.addComponent(versionLabel); if (!isInProductionMode()) { versionLayout.addComponent(revisionLabel); } // versionLayout.setMargin(new MarginInfo(true, false, false, false)); // mainLayout.addComponent(versionLayout); mainLayout.addComponent(versionLayout, 0, 2, 2, 2); mainLayout.setRowExpandRatio(2, 1.0f); // mainLayout.setSpacing(true); versionLayout.setComponentAlignment(versionLabel, Alignment.MIDDLE_RIGHT); versionLayout.setComponentAlignment(revisionLabel, Alignment.BOTTOM_RIGHT); mainLayout.setComponentAlignment(searchBarView, Alignment.BOTTOM_RIGHT); setContent(mainLayout); // getContent().setSizeFull(); // "Responsive design" /* * getPage().addBrowserWindowResizeListener(new BrowserWindowResizeListener() { * * @Override public void browserWindowResized(BrowserWindowResizeEvent event) { int height = * event.getHeight(); int width = event.getWidth(); WebBrowser browser = * event.getSource().getWebBrowser(); // tv.rebuildLayout(height, width, browser); if * (currentView instanceof HomeView) { homeView.updateView(height, width, browser); } else if * (currentView instanceof ProjectView) { projectView.updateView(height, width, browser); } else * if (currentView instanceof ExperimentView) { experimentView.updateView(height, width, * browser); } else if (currentView instanceof PatientView) { patientView.updateView(height, * width, browser); } else if (currentView instanceof AddPatientView) { * addPatientView.updateView(height, width, browser); } } }); * * navigator.addViewChangeListener(new ViewChangeListener() { * * @Override public boolean beforeViewChange(ViewChangeEvent event) { int height = * getPage().getBrowserWindowHeight(); int width = getPage().getBrowserWindowWidth(); WebBrowser * browser = getPage().getWebBrowser(); // View oldView = event.getOldView(); // * this.setEnabled(oldView, false); * * currentView = event.getNewView(); if (currentView instanceof HomeView) { * homeView.updateView(height, width, browser); } if (currentView instanceof ProjectView) { * projectView.updateView(height, width, browser); } if (currentView instanceof ExperimentView) * { experimentView.updateView(height, width, browser); } if (currentView instanceof SampleView) * { sampleView.updateView(height, width, browser); } else if (currentView instanceof * PatientView) { patientView.updateView(height, width, browser); } else if (currentView * instanceof AddPatientView) { addPatientView.updateView(height, width, browser); } return * true; } * * private void setEnabled(View view, boolean enabled) { // tv.setEnabled(enabled); if (view * instanceof HomeView) { homeView.setEnabled(enabled); } if (view instanceof ProjectView) { * projectView.setEnabled(enabled); } if (view instanceof ExperimentView) { * experimentView.setEnabled(enabled); } if (view instanceof SampleView) { * sampleView.setEnabled(enabled); } } * * @Override public void afterViewChange(ViewChangeEvent event) { currentView = * event.getNewView(); // this.setEnabled(currentView, true); Object currentBean = null; if * (currentView instanceof ProjectView) { // TODO refactoring currentBean = new HashMap<String, * AbstractMap.SimpleEntry<String, Long>>(); * * // Production // labelLayout.removeAllComponents(); Button header = new * Button(projectView.getHeaderLabel()); header.setStyleName(ValoTheme.BUTTON_LARGE); * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT); * * // labelLayout.addComponent(header); } else if (currentView instanceof HomeView) { * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>(); * * // labelLayout.removeAllComponents(); Button header = new Button(homeView.getHeader()); * header.setStyleName(ValoTheme.BUTTON_LARGE); * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT); * * // labelLayout.addComponent(header); // currentBean = projectView.getCurrentBean(); } else if * (currentView instanceof ExperimentView) { currentBean = experimentView.getCurrentBean(); * * } else if (currentView instanceof SampleView) { // TODO refactoring currentBean = new * HashMap<String, AbstractMap.SimpleEntry<String, Long>>(); * * // labelLayout.removeAllComponents(); Button header = new Button(sampleView.getHeader()); * header.setStyleName(ValoTheme.BUTTON_LARGE); * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT); * * // labelLayout.addComponent(header); * * } else if (currentView instanceof DatasetView) { currentBean = new HashMap<String, * AbstractMap.SimpleEntry<String, Long>>(); } else if (currentView instanceof PatientView) { * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>(); * * // labelLayout.removeAllComponents(); Button header = new * Button(patientView.getHeaderLabel()); header.setStyleName(ValoTheme.BUTTON_LARGE); * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT); * // labelLayout.addComponent(header); } else if (currentView instanceof AddPatientView) { * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>(); * * // labelLayout.removeAllComponents(); Button header = new Button(addPatientView.getHeader()); * header.setStyleName(ValoTheme.BUTTON_LARGE); * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT); * // labelLayout.addComponent(header); } try { PortletSession portletSession = * QbicmainportletUI.getCurrent().getPortletSession(); if (portletSession != null) { * portletSession.setAttribute("qbic_download", currentBean, PortletSession.APPLICATION_SCOPE); * } } catch (NullPointerException e) { // nothing to do. during initialization that might * happen. Nothing to worry about } * * * } * * }); */ /* * // go to correct page String requestParams = Page.getCurrent().getUriFragment(); * * // LOGGER.debug("used urifragement: " + requestParams); if (requestParams != null) { * navigator.navigateTo(requestParams.startsWith("!") ? requestParams.substring(1) : * requestParams); } else { navigator.navigateTo(""); } */ }
From source file:facs.components.Settings.java
License:Open Source License
private Component newDeviceGrid() { VerticalLayout devicesLayout = new VerticalLayout(); devicesLayout.setCaption("Devices"); HorizontalLayout buttonLayout = new HorizontalLayout(); Button add = new Button("Add"); add.setIcon(FontAwesome.PLUS); // there will now be space around the test component // components added to the test component will now not stick together but have space between // them// www . ja v a 2s .co m devicesLayout.setMargin(true); devicesLayout.setSpacing(true); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); add.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = 1920052856393517754L; @Override public void buttonClick(ClickEvent event) { addNewDevice(); } }); buttonLayout.addComponent(add); BeanItemContainer<DeviceBean> devices = getDevices(); GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(devices); gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() { /** * */ private static final long serialVersionUID = 4398909257922492690L; @Override public String getValue(Item item, Object itemId, Object propertyId) { // return FontAwesome.TRASH_O.getHtml(); // The caption return "Delete"; // The caption } @Override public Class<String> getType() { return String.class; } }); devicesGrid = new Grid(gpc); // Create a grid // devicesGrid.setWidth("100%"); devicesGrid.setSizeFull(); devicesGrid.setSelectionMode(SelectionMode.SINGLE); devicesGrid.getColumn("delete").setRenderer(new HtmlRenderer()); // Render a button that deletes the data row (item) devicesGrid.getColumn("delete") .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() { /** * */ private static final long serialVersionUID = 1217127696779125401L; @Override public void click(RendererClickEvent event) { removeDevice((DeviceBean) event.getItemId()); } })); // devicesGrid.setEditorEnabled(true); devicesLayout.addComponent(buttonLayout); devicesLayout.addComponent(devicesGrid); // TODO filtering // HeaderRow filterRow = devicesGrid.prependHeaderRow(); return devicesLayout; }
From source file:fr.univlorraine.mondossierweb.views.AdminView.java
License:Apache License
private void ajoutGestionSwap() { layoutSwapUser.setMargin(true);/*from w w w . j a v a 2 s . co m*/ layoutSwapUser.setSpacing(true); /* Boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); layoutSwapUser.addComponent(buttonsLayout); btnEditSwap = new Button(applicationContext.getMessage(NAME + ".btnEdit", null, getLocale()), FontAwesome.PENCIL); btnEditSwap.setEnabled(false); btnEditSwap.addClickListener(e -> { if (confSwapTable.getValue() instanceof UtilisateurSwap) { //configController.editConfApp((PreferencesApplication) confAppTable.getValue()); SwapUtilisateurWindow suw = new SwapUtilisateurWindow((UtilisateurSwap) confSwapTable.getValue(), false); suw.addCloseListener(f -> init()); tabSelectedPosition = 1; MainUI.getCurrent().addWindow(suw); } }); buttonsLayout.addComponent(btnEditSwap); buttonsLayout.setComponentAlignment(btnEditSwap, Alignment.MIDDLE_LEFT); btnAddSwap = new Button(applicationContext.getMessage(NAME + ".btnAdd", null, getLocale()), FontAwesome.PLUS); btnAddSwap.setEnabled(true); btnAddSwap.addClickListener(e -> { SwapUtilisateurWindow suw = new SwapUtilisateurWindow(new UtilisateurSwap(), true); suw.addCloseListener(f -> init()); tabSelectedPosition = 1; MainUI.getCurrent().addWindow(suw); }); buttonsLayout.addComponent(btnAddSwap); buttonsLayout.setComponentAlignment(btnAddSwap, Alignment.MIDDLE_CENTER); // Deconnexion Button decoBtn = new Button("Se Dconnecter", FontAwesome.SIGN_OUT); decoBtn.setEnabled(true); decoBtn.addClickListener(e -> { getUI().getPage().setLocation("j_spring_security_logout"); }); buttonsLayout.addComponent(decoBtn); buttonsLayout.setComponentAlignment(decoBtn, Alignment.MIDDLE_RIGHT); /* Table des conf */ confSwapTable = new Table(null, new BeanItemContainer<>(UtilisateurSwap.class, configController.getSwapUtilisateurs())); confSwapTable.setSizeFull(); confSwapTable.setVisibleColumns((Object[]) SWAP_FIELDS_ORDER); for (String fieldName : SWAP_FIELDS_ORDER) { confSwapTable.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".confSwapTable." + fieldName, null, getLocale())); } confSwapTable.setSortContainerPropertyId("loginSource"); confSwapTable.setColumnCollapsingAllowed(true); confSwapTable.setColumnReorderingAllowed(true); confSwapTable.setSelectable(true); confSwapTable.setImmediate(true); confSwapTable.addItemSetChangeListener(e -> confSwapTable.sanitizeSelection()); confSwapTable.addValueChangeListener(e -> { // Le bouton d'dition est actif seulement si un parametre est slectionn. boolean confIsSelected = confSwapTable.getValue() instanceof UtilisateurSwap; btnEditSwap.setEnabled(confIsSelected); }); confSwapTable.addItemClickListener(e -> { if (e.isDoubleClick()) { confSwapTable.select(e.getItemId()); btnEditSwap.click(); } }); layoutSwapUser.addComponent(confSwapTable); layoutSwapUser.setExpandRatio(confSwapTable, 1); }
From source file:gov.osti.doecode.RepositoryForm.java
/** * Create a basic form UI for editing software metadata information. * /*from w w w. j ava 2 s . co m*/ * @param ui link to the MyUI parent UI */ public RepositoryForm(MyUI ui) { this.ui = ui; setSizeUndefined(); agentGrid.setColumns("firstName", "lastName", "email"); agentGrid.setHeightMode(HeightMode.ROW); agentGrid.setHeightByRows(8); idGrid.setColumns("relationType", "identifierType", "value"); idGrid.setHeightMode(HeightMode.ROW); idGrid.setHeightByRows(8); idForm = new IdentifierForm(this); agentForm = new AgentForm(this); TabSheet tabs = new TabSheet(); tabs.addStyleName(ValoTheme.TABSHEET_FRAMED); tabs.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR); addComponent(tabs); HorizontalLayout main = new HorizontalLayout(); main.setSpacing(true); main.setMargin(true); FormLayout left = new FormLayout(); FormLayout right = new FormLayout(); countryCode.addItems(countryCodes); left.addComponents(url, loadButton, name, openSource, siteOwnershipCode, acronym, doi, countryCode); right.addComponents(keywords, rights, license, operatingSystem, siteAccessionNumber, otherRequirements); loadButton.addClickListener(e -> { try { SoftwareRepository repo = Reader.loadRepository("doecode"); setSoftwareRepository(repo); } catch (IOException ex) { setComponentError(new UserError("Unable to load: " + ex.getMessage())); } }); main.addComponents(left, right); tabs.addTab(main, "Metadata"); Button agentAddButton = new Button("New"); agentAddButton.setStyleName(BaseTheme.BUTTON_LINK); agentAddButton.setIcon(FontAwesome.PLUS); agentAddButton.addClickListener(e -> { agentForm.setAgent(new Agent()); }); VerticalLayout innerAgent = new VerticalLayout(agentAddButton, agentGrid); innerAgent.setSizeUndefined(); HorizontalLayout agentLayout = new HorizontalLayout(innerAgent, agentForm); agentLayout.setSpacing(true); agentLayout.setMargin(true); tabs.addTab(agentLayout, "Agents"); Button idAddButton = new Button("New"); idAddButton.setIcon(FontAwesome.PLUS); idAddButton.setStyleName(BaseTheme.BUTTON_LINK); idAddButton.setSizeUndefined(); idAddButton.addClickListener(e -> { idForm.setIdentifier(new Identifier()); }); VerticalLayout innerId = new VerticalLayout(idAddButton, idGrid); HorizontalLayout idTab = new HorizontalLayout(innerId, idForm); idTab.setSpacing(true); idTab.setMargin(true); tabs.addTab(idTab, "Identifiers"); agentGrid.addSelectionListener(e -> { if (!e.getSelected().isEmpty()) { Agent agent = (Agent) e.getSelected().iterator().next(); agentForm.setAgent(agent); System.out.println("Selected " + agent.getFirstName()); } }); idGrid.addSelectionListener(e -> { if (!e.getSelected().isEmpty()) { Identifier identifier = (Identifier) e.getSelected().iterator().next(); idForm.setIdentifier(identifier); } }); }
From source file:io.pivotal.pde.demo.tracker.gemfire.TrackerUI.java
@Override protected void init(VaadinRequest request) { this.grid = new Grid(); this.filter = new TextField(); this.addNewBtn = new Button("Check In", FontAwesome.PLUS); ApplicationContext ctx = (ApplicationContext) VaadinServlet.getCurrent().getServletContext() .getAttribute("spring-context"); this.repo = ctx.getBean(CheckInRepository.class); this.editor = ctx.getBean(CheckInEditor.class); // build layout HorizontalLayout actions = new HorizontalLayout(filter, addNewBtn); VerticalLayout mainLayout = new VerticalLayout(actions, grid, editor); setContent(mainLayout);//from www .j a v a2 s .com // Configure layouts and components actions.setSpacing(true); mainLayout.setMargin(true); mainLayout.setSpacing(true); grid.setHeight(300, Unit.PIXELS); grid.setWidth(550, Unit.PIXELS); grid.setColumns("plate", "city", "timestamp"); grid.setContainerDataSource(new BeanItemContainer<CheckIn>(CheckIn.class)); filter.setInputPrompt("Filter by License Plate"); // Hook logic to components // Replace listing with filtered content when user changes filter filter.addTextChangeListener(e -> refillGrid(e.getText())); // Show the form when new button is clicked addNewBtn.addClickListener(e -> editor.newCheckIn()); // Listen changes made by the editor, refresh data from backend editor.setChangeHandler(new CheckInEditor.ChangeHandler() { @Override public void onChange() { editor.setVisible(false); refillGrid(filter.getValue()); } }); CheckInCacheListener changeListener = ctx.getBean(CheckInCacheListener.class); changeListener.setHandler(this); // this.setPollInterval(5000); // Initialize listing refillGrid(null); }
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/*w ww .j av a 2 s . 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//from w ww .jav a2s . co 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:lifetime.component.CrudMenu.java
License:Apache License
/** * Add crud specific control buttons, one for each crud action. *//*from www. ja v a 2 s. com*/ @Override protected void addControls() { addButton = new LifetimeButtonLink(username, getLanguage(), "Create", FontAwesome.PLUS); addButton.setId(StyleClassName.C_BUTTON.getId()); readButton = new LifetimeButtonLink(username, getLanguage(), "Read", FontAwesome.EYE); readButton.setId(StyleClassName.R_BUTTON.getId()); updateButton = new LifetimeButtonLink(username, getLanguage(), "Update", FontAwesome.EDIT); updateButton.setId(StyleClassName.U_BUTTON.getId()); deleteButton = new LifetimeButtonLink(username, getLanguage(), "Delete", FontAwesome.TRASH_O); deleteButton.setId(StyleClassName.D_BUTTON.getId()); addControl(addButton); addControl(readButton); addControl(updateButton); addControl(deleteButton); }