List of usage examples for com.vaadin.ui Button addStyleName
@Override public void addStyleName(String style)
From source file:de.symeda.sormas.ui.utils.CssStyles.java
License:Open Source License
/** * Styles and (de-)activates the given buttons. * //from ww w. java 2 s.c o m * @param activeButton * This button is styled as active but disabled. * @param allOrOtherButtons * These buttons lose their active styling and become enabled. {@code activeButton} may be included here. */ public static <B extends Button> void styleSectionFilterButton(Button activeButton, Iterable<B> allOrOtherButtons) { for (Button button : allOrOtherButtons) { button.setEnabled(true); button.removeStyleName(CssStyles.LINK_ACTIVE); } activeButton.setEnabled(false); activeButton.addStyleName(CssStyles.LINK_ACTIVE); }
From source file:de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent.java
License:Open Source License
public EpiWeekAndDateFilterComponent(Button applyButton, boolean fillAutomatically, boolean showCaption, String infoText, Class<E> dateType, String dateTypePrompt, Enum<E> defaultDateType) { setSpacing(true);// w ww .j a v a2 s . c om Calendar c = Calendar.getInstance(); c.setTime(new Date()); dateFilterOptionFilter = new ComboBox(); dateTypeSelector = new ComboBox(); weekFromFilter = new ComboBox(); weekToFilter = new ComboBox(); dateFromFilter = new PopupDateField(); dateToFilter = new PopupDateField(); // Date filter options dateFilterOptionFilter.setWidth(200, Unit.PIXELS); dateFilterOptionFilter.addItems((Object[]) DateFilterOption.values()); dateFilterOptionFilter.setNullSelectionAllowed(false); dateFilterOptionFilter.select(DateFilterOption.EPI_WEEK); if (showCaption) { CssStyles.style(dateFilterOptionFilter, CssStyles.FORCE_CAPTION); } dateFilterOptionFilter.addValueChangeListener(e -> { if (e.getProperty().getValue() == DateFilterOption.DATE) { int newIndex = getComponentIndex(weekFromFilter); removeComponent(weekFromFilter); removeComponent(weekToFilter); addComponent(dateFromFilter, newIndex); addComponent(dateToFilter, newIndex + 1); if (fillAutomatically) { dateFromFilter.setValue(DateHelper.subtractDays(c.getTime(), 7)); } if (fillAutomatically) { dateToFilter.setValue(c.getTime()); } } else { int newIndex = getComponentIndex(dateFromFilter); removeComponent(dateFromFilter); removeComponent(dateToFilter); addComponent(weekFromFilter, newIndex); addComponent(weekToFilter, newIndex + 1); if (fillAutomatically) { weekFromFilter.setValue(DateHelper.getEpiWeek(c.getTime())); } if (fillAutomatically) { weekToFilter.setValue(DateHelper.getEpiWeek(c.getTime())); } } }); addComponent(dateFilterOptionFilter); // New case date type selector if (dateType != null) { dateTypeSelector.setWidth(200, Unit.PIXELS); dateTypeSelector.addItems((Object[]) dateType.getEnumConstants()); if (dateTypePrompt != null) { dateTypeSelector.setInputPrompt(dateTypePrompt); } if (defaultDateType != null) { dateTypeSelector.select(defaultDateType); } if (showCaption) { CssStyles.style(dateTypeSelector, CssStyles.FORCE_CAPTION); } addComponent(dateTypeSelector); if (!StringUtils.isEmpty(infoText)) { Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML); infoLabel.setSizeUndefined(); infoLabel.setDescription(infoText); CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY); addComponent(infoLabel); } } // Epi week filter List<EpiWeek> epiWeekList = DateHelper.createEpiWeekList(c.get(Calendar.YEAR), c.get(Calendar.WEEK_OF_YEAR)); weekFromFilter.setWidth(200, Unit.PIXELS); for (EpiWeek week : epiWeekList) { weekFromFilter.addItem(week); } weekFromFilter.setNullSelectionAllowed(false); if (fillAutomatically) { weekFromFilter.setValue(DateHelper.getEpiWeek(c.getTime())); } if (showCaption) { weekFromFilter.setCaption(I18nProperties.getCaption(Captions.epiWeekFrom)); } if (applyButton != null) { weekFromFilter.addValueChangeListener(e -> { applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY); }); } addComponent(weekFromFilter); weekToFilter.setWidth(200, Unit.PIXELS); for (EpiWeek week : epiWeekList) { weekToFilter.addItem(week); } weekToFilter.setNullSelectionAllowed(false); if (fillAutomatically) { weekToFilter.setValue(DateHelper.getEpiWeek(c.getTime())); } if (showCaption) { weekToFilter.setCaption(I18nProperties.getCaption(Captions.epiWeekTo)); } if (applyButton != null) { weekToFilter.addValueChangeListener(e -> { applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY); }); } addComponent(weekToFilter); // Date filter dateFromFilter.setWidth(200, Unit.PIXELS); if (showCaption) { dateFromFilter.setCaption(I18nProperties.getCaption(Captions.from)); } if (applyButton != null) { dateFromFilter.addValueChangeListener(e -> { applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY); }); } dateToFilter.setWidth(200, Unit.PIXELS); if (showCaption) { dateToFilter.setCaption(I18nProperties.getCaption(Captions.to)); } if (applyButton != null) { dateToFilter.addValueChangeListener(e -> { applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY); }); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.MultiscaleComponent.java
License:Open Source License
void buildEmptyComments() { // add comments VerticalLayout addComment = new VerticalLayout(); addComment.setMargin(true);// w w w. j av a 2 s .co m addComment.setWidth(100, Unit.PERCENTAGE); final TextArea comments = new TextArea(); comments.setInputPrompt("Write your comment here..."); comments.setWidth(100, Unit.PERCENTAGE); comments.setRows(2); Button commentsOk = new Button("Add Comment"); commentsOk.addStyleName(ValoTheme.BUTTON_FRIENDLY); commentsOk.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = -5369241494545155677L; public void buttonClick(ClickEvent event) { if ("".equals(comments.getValue())) return; String newComment = comments.getValue(); // reset comments comments.setValue(""); // use some date format Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Note note = new Note(); note.setComment(newComment); note.setUsername(controller.getUser()); note.setTime(ft.format(dNow)); // show it now // pastcomments.getContainerDataSource().addItem(note); notes.add(note); // TODO write back Label commentsLabel = new Label(translateComments(notes), ContentMode.HTML); commentsPanel.setContent(commentsLabel); // write back to openbis if (!controller.addNote(note)) { Notification.show("Could not add comment to sample. How did you do that?"); } } }); HorizontalLayout inputPrompt = new HorizontalLayout(); inputPrompt.addComponent(comments); inputPrompt.addComponent(commentsOk); inputPrompt.setWidth(50, Unit.PERCENTAGE); inputPrompt.setComponentAlignment(commentsOk, Alignment.TOP_RIGHT); inputPrompt.setExpandRatio(comments, 1.0f); // addComment.addComponent(comments); // addComment.addComponent(commentsOk); addComment.addComponent(commentsPanel); addComment.addComponent(inputPrompt); // addComment.setComponentAlignment(comments, Alignment.TOP_CENTER); // addComment.setComponentAlignment(commentsOk, Alignment.MIDDLE_CENTER); addComment.setComponentAlignment(commentsPanel, Alignment.TOP_CENTER); addComment.setComponentAlignment(inputPrompt, Alignment.MIDDLE_CENTER); mainlayout.addComponent(addComment); // mainlayout.addComponent(pastcomments); Label commentsLabel = new Label("No comments added so far.", ContentMode.HTML); commentsPanel.setContent(commentsLabel); // mainlayout.addComponent(commentsPanel); // mainlayout.setComponentAlignment(commentsPanel, // Alignment.TOP_CENTER); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.QbicmainportletUI.java
License:Open Source License
/** * /*from ww w . j a va 2s . 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:de.uni_tuebingen.qbic.qbicmainportlet.SearchBarView.java
License:Open Source License
public void initUI() { mainlayout = new Panel(); mainlayout.addStyleName(ValoTheme.PANEL_BORDERLESS); // static information for the user // Label info = new Label(); // info.setValue(infotext); // info.setStyleName(ValoTheme.LABEL_LIGHT); // info.setStyleName(ValoTheme.LABEL_H4); // mainlayout.addComponent(info); // Search bar // *----------- search text field .... search button-----------* HorizontalLayout searchbar = new HorizontalLayout(); searchbar.setSpacing(true);// w w w .ja va 2s. co m final TextField searchfield = new TextField(); searchfield.setHeight("44px"); searchfield.setImmediate(true); searchfield.setInputPrompt("search for sample"); // TODO would be nice to have a autofill or something similar searchbar.addComponent(searchfield); Button searchOk = new Button("GoTo"); searchOk.addStyleName(ValoTheme.BUTTON_BORDERLESS); searchOk.setIcon(FontAwesome.SEARCH); searchOk.addClickListener(new ClickListener() { private static final long serialVersionUID = -2409450448301908214L; @Override public void buttonClick(ClickEvent event) { // TODO how to deal with entities Pattern pattern = Pattern.compile("Q[A-Z0-9]{4}[0-9]{3}[A-Z0-9]{2}"); Pattern pattern2 = Pattern.compile("Q[A-Z0-9]{4}ENTITY-[0-9]+"); LOGGER.info("searching for sample: " + (String) searchfield.getValue()); if (searchfield.getValue() == null || searchfield.getValue().toString().equals("")) { Notification.show("Please provide a Barcode before clicking GoTo.", Type.WARNING_MESSAGE); } else { String entity = (String) searchfield.getValue().toString(); Matcher matcher = pattern.matcher(entity); Matcher matcher2 = pattern2.matcher(entity); Boolean patternFound1 = matcher.find(); Boolean patternFound2 = matcher2.find(); if (patternFound1) { try { Sample foundSample = datahandler.getOpenBisClient() .getSampleByIdentifier(matcher.group(0).toString()); String identifier = foundSample.getIdentifier(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(identifier); message.add("sample"); state.notifyObservers(message); } catch (Exception e) { Notification.show("No Sample found for given barcode.", Type.WARNING_MESSAGE); } } else if (patternFound2) { try { Sample foundSample = datahandler.getOpenBisClient() .getSampleByIdentifier(matcher2.group(0).toString()); String identifier = foundSample.getIdentifier(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(identifier); message.add("sample"); state.notifyObservers(message); } catch (Exception e) { Notification.show("No Sample found for given barcode.", Type.WARNING_MESSAGE); } } else { Notification.show("Please provide a valid Sample Barcode.", Type.WARNING_MESSAGE); } } } }); // setClickShortcut() would add global shortcut, instead we // 'scope' the shortcut to the panel: mainlayout.addAction(new com.vaadin.ui.Button.ClickShortcut(searchOk, KeyCode.ENTER)); // searchfield.addItems(this.getSearchResults("Q")); searchfield.setDescription(infotext); searchfield.addValidator(new NullValidator("Field must not be empty", false)); searchfield.setValidationVisible(false); searchbar.addComponent(searchOk); // searchbar.setMargin(new MarginInfo(true, false, true, false)); mainlayout.setContent(searchbar); // mainlayout.setComponentAlignment(searchbar, Alignment.MIDDLE_RIGHT); // mainlayout.setWidth(100, Unit.PERCENTAGE); setCompositionRoot(mainlayout); }
From source file:dhbw.clippinggorilla.userinterface.views.ClippingView.java
public ClippingView(Clipping clipping) { User user = UserUtils.getCurrent();/*from w w w.j a v a 2 s . c o m*/ clippingArticlesLayout = new VerticalLayout(); clippingArticlesLayout.setSpacing(true); clippingArticlesLayout.setMargin(false); clippingArticlesLayout.setSizeFull(); HorizontalLayout clippingOptionsLayout = new HorizontalLayout(); clippingOptionsLayout.setSpacing(true); clippingOptionsLayout.setMargin(false); clippingOptionsLayout.setWidth("100%"); ComboBox<SortOptions> comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY)); Language.setCustom(Word.SORT_BY, s -> { comboBoxSortOptions.setCaption(s); comboBoxSortOptions.getDataProvider().refreshAll(); }); comboBoxSortOptions.setItems(EnumSet.allOf(SortOptions.class)); comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName()); comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon()); comboBoxSortOptions.setValue(SortOptions.BYPROFILE); comboBoxSortOptions.setTextInputAllowed(false); comboBoxSortOptions.setEmptySelectionAllowed(false); comboBoxSortOptions.addStyleName("comboboxsort"); comboBoxSortOptions.addValueChangeListener(e -> { switch (e.getValue()) { case BYDATE: createClippingViewByDate(clipping); break; case BYPROFILE: createClippingViewByProfile(clipping); break; case BYSOURCE: createClippingViewBySource(clipping); break; } }); Button buttonRegenerateClipping = new Button(VaadinIcons.REFRESH); buttonRegenerateClipping.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonRegenerateClipping.addClickListener(ce -> { user.setLastClipping(ClippingUtils.generateClipping(user, false)); ClippingGorillaUI.getCurrent().setMainContent(ClippingView.getCurrent()); }); clippingOptionsLayout.addComponents(comboBoxSortOptions, buttonRegenerateClipping); clippingOptionsLayout.setExpandRatio(comboBoxSortOptions, 5); clippingOptionsLayout.setComponentAlignment(buttonRegenerateClipping, Alignment.BOTTOM_CENTER); addComponents(clippingOptionsLayout, clippingArticlesLayout); createClippingViewByProfile(clipping); if (clipping.getArticles().keySet().isEmpty() && clipping.getArticlesFromGroup().keySet().isEmpty()) { Label labelNoProfile = new Label(); Language.setCustom(Word.NO_PROFILE_PRESENT, s -> labelNoProfile.setValue(s)); labelNoProfile.addStyleName(ValoTheme.LABEL_H2); clippingArticlesLayout.addComponent(labelNoProfile); } }
From source file:dhbw.clippinggorilla.userinterface.views.FooterBar.java
public FooterBar() { setColumns(6);/*w w w .ja v a 2 s . c o m*/ setRows(1); addStyleName("menubar"); setWidth("100%"); setHeightUndefined(); setColumnExpandRatio(4, 5); setSpacing(true); setMargin(true); Image logo = new Image(); try { logo.setSource(new FileResource(FileUtils.getFile("images/logo_small.png").toFile())); } catch (FileNotFoundException ex) { Log.error("Could not find logo!", ex); } logo.setHeight("100%"); addComponent(logo); setComponentAlignment(logo, Alignment.MIDDLE_CENTER); Button aboutUs = new Button(); Language.set(Word.ABOUT_US, aboutUs); aboutUs.addClickListener((ce) -> { ClippingGorillaUI.getCurrent().setMainContent(AboutUsView.getCurrent()); }); aboutUs.setIcon(VaadinIcons.USERS); aboutUs.addStyleName(ValoTheme.BUTTON_BORDERLESS); addComponent(aboutUs); setComponentAlignment(aboutUs, Alignment.MIDDLE_CENTER); Button docs = new Button(); Language.set(Word.DOCUMENTS, docs); docs.addClickListener(ce -> { ClippingGorillaUI.getCurrent().setMainContent(DocumentsView.getCurrent()); }); docs.setIcon(VaadinIcons.ARCHIVE); docs.addStyleName(ValoTheme.BUTTON_BORDERLESS); addComponent(docs); setComponentAlignment(docs, Alignment.MIDDLE_CENTER); Button impressum = new Button(); Language.set(Word.IMPRESSUM, impressum); impressum.addClickListener(ce -> { ClippingGorillaUI.getCurrent().setMainContent(ImpressumView.getCurrent()); }); impressum.setIcon(VaadinIcons.SCALE); impressum.addStyleName(ValoTheme.BUTTON_BORDERLESS); addComponent(impressum); setComponentAlignment(impressum, Alignment.MIDDLE_CENTER); Label spacing = new Label(); addComponent(spacing); setComponentAlignment(spacing, Alignment.MIDDLE_CENTER); ComboBox<Locale> languages = new ComboBox<>(null, Language.getAllLanguages().keySet()); languages.setItemCaptionGenerator(loc -> loc.getDisplayLanguage(loc)); if (!Language.getAllLanguages().containsKey(VaadinSession.getCurrent().getLocale())) { languages.setValue(Locale.ENGLISH); } else { languages.setValue(VaadinSession.getCurrent().getLocale()); } languages.setEmptySelectionAllowed(false); languages.setItemIconGenerator(FooterBar::getIcon); languages.addValueChangeListener( (HasValue.ValueChangeEvent<Locale> loc) -> Language.setLanguage(loc.getValue())); languages.setTextInputAllowed(false); addComponent(languages); setComponentAlignment(languages, Alignment.MIDDLE_CENTER); SESSIONS.put(VaadinSession.getCurrent(), this); }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
public GroupView() { User user = UserUtils.getCurrent();/*from ww w . jav a 2s . co m*/ Set<Group> groups = UserUtils.getAllGroups(user); CssLayout newGroupGroup = new CssLayout(); newGroupGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldNewGroupName = new TextField(); Language.setCustom(Word.GROUP_NAME, s -> textFieldNewGroupName.setPlaceholder(s)); textFieldNewGroupName.setWidth("260px"); textFieldNewGroupName.setMaxLength(255); newGroupGroup.addComponent(textFieldNewGroupName); Button buttonNewGroup = new Button(); buttonNewGroup.setIcon(VaadinIcons.PLUS); buttonNewGroup.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonNewGroup.addClickListener(e -> { TabSheet.Tab newTab = accordion.addTab(createTab(createEmptyGroup(textFieldNewGroupName.getValue())), textFieldNewGroupName.getValue()); accordion.setSelectedTab(newTab); accordion.setWidth("100%"); textFieldNewGroupName.clear(); }); newGroupGroup.addComponent(buttonNewGroup); textFieldNewGroupName .addFocusListener(f -> buttonNewGroup.setClickShortcut(ShortcutAction.KeyCode.ENTER, null)); textFieldNewGroupName.addBlurListener(f -> buttonNewGroup.removeClickShortcut()); groups.forEach(g -> { accordion.addTab(createTab(g), g.getName()); }); addComponents(newGroupGroup, accordion); //SESSIONS.put(user, this); }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
public VerticalLayout createTab(Group g) { User u = UserUtils.getCurrent();//w ww . j av a2s .c o m VerticalLayout groupSettingsLayout = new VerticalLayout(); groupSettingsLayouts.put(g, groupSettingsLayout); GridLayout tabContent; TextField textFieldName = new TextField(); if (GroupUtils.isAdmin(g, u)) { tabContent = new GridLayout(3, 2); Language.set(Word.NAME, textFieldName); textFieldName.setWidth("100%"); textFieldName.setValue(g.getName()); textFieldName.setMaxLength(255); tabContent.addComponent(textFieldName); tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT); } else { tabContent = new GridLayout(3, 1); } buttonLeave = new Button(); Language.set(Word.LEAVE, buttonLeave); buttonLeave.setIcon(VaadinIcons.MINUS); buttonLeave.addStyleName(ValoTheme.BUTTON_DANGER); buttonLeave.addClickListener(ce -> { ConfirmationDialog.show(Language.get(Word.REALLY_LEAVE_GROUP).replace("[GROUP]", g.getName()), () -> { long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count(); if (amountAdmins > 1 || !GroupUtils.isAdmin(g, u)) { GroupUtils.removeUser(g, u); refreshAll(g); } else { VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP)); } }); }); buttonDelete = new Button(); Language.set(Word.DELETE, buttonDelete); buttonDelete.setIcon(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.addClickListener(ce -> { ConfirmationDialog.show(Language.get(Word.REALLY_DELETE_GROUP).replace("[GROUP]", g.getName()), () -> { GroupUtils.removeGroup(g); refreshAll(g); }); }); Button buttonSave = new Button(); Language.set(Word.SAVE, buttonSave); buttonSave.setIcon(VaadinIcons.CHECK); buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSave.addClickListener(ce -> { if (GroupUtils.isAdmin(g, u)) { GroupUtils.changeName(g, textFieldName.getValue()); accordion.getTab(groupSettingsLayout).setCaption(textFieldName.getValue()); } VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED)); }); buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); Label placeholder = new Label(); Label placeholder2 = new Label(); placeholder2.setWidth("100%"); Label placeholder3 = new Label(); GridLayout footer = new GridLayout(4, 1); footer.setSpacing(true); footer.setMargin(new MarginInfo(false, true)); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth("100%"); footer.addStyleName("menubar"); if (GroupUtils.isAdmin(g, u)) { footer.addComponents(placeholder, buttonDelete, buttonLeave, buttonSave); footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER); } else { footer.addComponents(placeholder, placeholder3, buttonLeave, buttonSave); } footer.setColumnExpandRatio(0, 5); footer.setComponentAlignment(buttonLeave, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER); if (GroupUtils.isAdmin(g, u)) { tabContent.addComponent(getProfiles(g), 0, 1, 1, 1); tabContent.addComponent(getMembers(g), 2, 1); } else { tabContent.addComponent(getProfiles(g), 0, 0, 1, 0); tabContent.addComponent(getMembers(g), 2, 0); } tabContent.setWidth("100%"); tabContent.setSpacing(true); tabContent.setMargin(true); tabContent.addStyleName("profiles"); groupSettingsLayout.addComponents(tabContent, footer); groupSettingsLayout.setMargin(false); groupSettingsLayout.setSpacing(false); groupSettingsLayout.setWidth("100%"); return groupSettingsLayout; }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
private Component getProfiles(Group g) { VerticalLayout layoutRootProfiles = new VerticalLayout(); layoutRootProfiles.setMargin(false); layoutRootProfiles.setWidth("100%"); Panel panelProfiles = new Panel(Language.get(Word.PROFILES)); Language.setCustom(Word.PROFILES, s -> panelProfiles.setCaption(s)); panelProfiles.setWidth("100%"); panelProfiles.setHeight("200px"); VerticalLayout layoutProfiles = new VerticalLayout(); mapLayoutProfiles.put(g, layoutProfiles); layoutProfiles.setWidth("100%"); refreshProfiles(g, layoutProfiles);/*from w ww.java2 s . co m*/ panelProfiles.setContent(layoutProfiles); layoutRootProfiles.addComponent(panelProfiles); if (GroupUtils.isAdmin(g, UserUtils.getCurrent())) { CssLayout addProfileGroup = new CssLayout(); addProfileGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); addProfileGroup.setWidth("100%"); TextField textFieldAddProfile = new TextField(); Language.setCustom(Word.PROFILE_NAME, s -> textFieldAddProfile.setPlaceholder(s)); textFieldAddProfile.setMaxLength(255); textFieldAddProfile.setWidth("35%"); addProfileGroup.addComponent(textFieldAddProfile); Button buttonAddProfile = new Button(); buttonAddProfile.setIcon(VaadinIcons.PLUS); buttonAddProfile.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonAddProfile.setWidth("15%"); buttonAddProfile.addClickListener(e -> { try { String name = textFieldAddProfile.getValue(); textFieldAddProfile.clear(); Runnable onClose = () -> refreshAll(g); UI.getCurrent().addWindow(GroupProfileWindow.create(g, name, true, onClose)); } catch (UserNotFoundException ex) { VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND)); } }); addProfileGroup.addComponent(buttonAddProfile); layoutRootProfiles.addComponent(addProfileGroup); } return layoutRootProfiles; }