List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:dhbw.clippinggorilla.objects.user.UserUtils.java
/** * Returns the current User or null if there is no User logged in * * @return The requested User or null/* w w w . j av a 2 s .c om*/ */ public static User getCurrent() { return USERS.get(VaadinSession.getCurrent()); }
From source file:dhbw.clippinggorilla.objects.user.UserUtils.java
public static void setCurrentUser(User u) { VaadinSession session = VaadinSession.getCurrent(); if (session != null) { USERS.put(session, u); } }
From source file:dhbw.clippinggorilla.objects.user.UserUtils.java
public static void removeCurrentUser() { VaadinSession session = VaadinSession.getCurrent(); USERS.remove(session); }
From source file:dhbw.clippinggorilla.userinterface.views.AboutUsView.java
public AboutUsView() { setMargin(true);/*www . j a v a2 s .c o m*/ setWidth("55%"); Label aboutUsHeader = new Label(); Language.set(Word.ABOUT_US, aboutUsHeader); aboutUsHeader.setStyleName(ValoTheme.LABEL_H1); addComponent(aboutUsHeader); Label aboutUsGroupHeadline = new Label(); Language.set(Word.GROUP_PROJECT_OF_GROUP_4, aboutUsGroupHeadline); aboutUsGroupHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(aboutUsGroupHeadline); Label aboutUsText = new Label(); Language.set(Word.GROUP_PROJECT_BODY, aboutUsText); aboutUsText.setWidth("100%"); aboutUsText.setContentMode(com.vaadin.shared.ui.ContentMode.HTML); addComponent(aboutUsText); Label theTeamHeader = new Label(); Language.set(Word.OUR_TEAM, theTeamHeader); theTeamHeader.setStyleName(ValoTheme.LABEL_H2); addComponent(theTeamHeader); Grid<Person> theTeamGrid = new Grid<>(); List<Person> persons = Arrays.asList(new Person("Dan-Pierre", "Drehlich", Person.Function.TEAMLEADER), new Person("Stefan", "Schmid", Person.Function.RESPONSIBLE_FOR_RESEARCH), new Person("Jan", "Striegel", Person.Function.TECHNICAL_ASSISTANT), new Person("Lisa", "Hartung", Person.Function.RESPONSIBLE_FOR_MODELING_QUALITY_ASSURANCE_AND_DOCUMENTATION), new Person("Tim", "Heinzelmann", Person.Function.RESPONSIBLE_FOR_TESTS), new Person("Josua", "Frank", Person.Function.RESPONSIBLE_FOR_IMPLEMENTATION)); Grid.Column c1 = theTeamGrid.addColumn(p -> p.getFirstName()); Language.setCustom(Word.FIRST_NAME, s -> c1.setCaption(s)); Grid.Column c2 = theTeamGrid.addColumn(p -> p.getLastName()); Language.setCustom(Word.LAST_NAME, s -> c2.setCaption(s)); Grid.Column c3 = theTeamGrid.addColumn(p -> p.getResposibility()); Language.setCustom(Word.RESPONSIBILITY, s -> { c3.setCaption(s); theTeamGrid.getDataProvider().refreshAll(); }); theTeamGrid.setItems(persons); theTeamGrid.setWidth("100%"); theTeamGrid.setHeightByRows(6); addComponent(theTeamGrid); SESSIONS.put(VaadinSession.getCurrent(), this); }
From source file:dhbw.clippinggorilla.userinterface.views.DocumentsView.java
public DocumentsView() { for (int i = 1; i < 12; i++) { setWidth("55%"); GridLayout layout = new GridLayout(3, 1); layout.setMargin(true);//from w ww . j ava 2 s . co m layout.setSpacing(true); try { List<Path> files = FileUtils.listFiles("docs/week" + i); layout.setRows(files.size() > 0 ? files.size() : 1); files.stream().sorted(Comparator.naturalOrder()).forEach(f -> { generateLine(f, layout); }); } catch (IOException ex) { Logger.getLogger(DocumentsView.class.getName()).log(Level.SEVERE, null, ex); } addTab(layout, Language.get(Word.WEEK) + " " + i); } Language.setCustom(Word.WEEK, t -> t + " 1", v -> getTab(0).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 2", v -> getTab(1).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 3", v -> getTab(2).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 4", v -> getTab(3).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 5", v -> getTab(4).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 6", v -> getTab(5).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 7", v -> getTab(6).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 8", v -> getTab(7).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 9", v -> getTab(8).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 10", v -> getTab(9).setCaption(v)); Language.setCustom(Word.WEEK, t -> t + " 11", v -> getTab(10).setCaption(v)); SESSIONS.put(VaadinSession.getCurrent(), this); }
From source file:dhbw.clippinggorilla.userinterface.views.FooterBar.java
public FooterBar() { setColumns(6);//from w w w. ja v a 2 s .com 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.ImpressumView.java
public ImpressumView() { setMargin(true);// www . j av a 2 s. c om setWidth("55%"); Label impressumHeader = new Label(); Language.set(Word.IMPRESSUM, impressumHeader); impressumHeader.setStyleName(ValoTheme.LABEL_H1); addComponent(impressumHeader); Label impressumText = new Label(); Language.set(Word.IMPRESSUM_BODY, impressumText); impressumText.setWidth("100%"); impressumText.setContentMode(com.vaadin.shared.ui.ContentMode.HTML); addComponent(impressumText); Grid<Person> studentsGrid = new Grid<>(); List<Person> persons = Arrays.asList(new Person("Dan-Pierre", "Drehlich", Person.Function.TEAMLEADER), new Person("Stefan", "Schmid", Person.Function.RESPONSIBLE_FOR_RESEARCH), new Person("Jan", "Striegel", Person.Function.TECHNICAL_ASSISTANT), new Person("Lisa", "Hartung", Person.Function.RESPONSIBLE_FOR_MODELING_QUALITY_ASSURANCE_AND_DOCUMENTATION), new Person("Tim", "Heinzelmann", Person.Function.RESPONSIBLE_FOR_TESTS), new Person("Josua", "Frank", Person.Function.RESPONSIBLE_FOR_IMPLEMENTATION)); Column c1 = studentsGrid.addColumn(p -> p.getFirstName()); Language.setCustom(Word.FIRST_NAME, s -> c1.setCaption(s)); Column c2 = studentsGrid.addColumn(p -> p.getLastName()); Language.setCustom(Word.LAST_NAME, s -> c2.setCaption(s)); Column c3 = studentsGrid.addColumn(p -> p.getResposibility()); Language.setCustom(Word.RESPONSIBILITY, s -> { c3.setCaption(s); studentsGrid.getDataProvider().refreshAll(); }); studentsGrid.setItems(persons); studentsGrid.setWidth("100%"); studentsGrid.setHeightByRows(6); addComponent(studentsGrid); Label liabilityHeadline = new Label(); Language.set(Word.LIABILITY, liabilityHeadline); liabilityHeadline.setStyleName(ValoTheme.LABEL_H1); addComponent(liabilityHeadline); Label liabilityContentHeadline = new Label(); Language.set(Word.LIABILITY_CONTENT, liabilityContentHeadline); liabilityContentHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(liabilityContentHeadline); Label liabilityContentText = new Label(); Language.set(Word.LIABILITY_CONTENT_BODY, liabilityContentText); liabilityContentText.setWidth("100%"); addComponent(liabilityContentText); Label liabilityLinksHeadline = new Label(); Language.set(Word.LIABILITY_LINKS, liabilityLinksHeadline); liabilityLinksHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(liabilityLinksHeadline); Label liabilityLinksText = new Label(); Language.set(Word.LIABILITY_LINKS_BODY, liabilityLinksText); liabilityLinksText.setWidth("100%"); addComponent(liabilityLinksText); Label copyrightHeadline = new Label(); Language.set(Word.COPYRIGHT, copyrightHeadline); copyrightHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(copyrightHeadline); Label copyrightText = new Label(); Language.set(Word.COPYRIGHT_BODY, copyrightText); copyrightText.setWidth("100%"); addComponent(copyrightText); Label dataProtectionHeadline = new Label(); Language.set(Word.DATAPROTECTION, dataProtectionHeadline); dataProtectionHeadline.setStyleName(ValoTheme.LABEL_H2); addComponent(dataProtectionHeadline); Label dataProtectionText = new Label(); Language.set(Word.DATAPROTECTION_BODY, dataProtectionText); dataProtectionText.setWidth("100%"); addComponent(dataProtectionText); SESSIONS.put(VaadinSession.getCurrent(), this); }
From source file:dhbw.clippinggorilla.userinterface.views.MenuBar.java
public MenuBar() { setColumns(7);/*from w w w.j av a2 s .c o m*/ setRows(1); addStyleName("menubar"); setWidth("100%"); setHeightUndefined(); setColumnExpandRatio(1, 5); setSpacing(true); setMargin(true); logo = new Image(); try { logo.setSource(new FileResource(FileUtils.getFile("images/logowide_small.png").toFile())); } catch (FileNotFoundException ex) { Log.error("Could not find logo!", ex); } logo.setHeight("100%"); spacing1 = new Label(); spacing2 = new Label(); username = new TextField(); username.focus(); Language.setCustom(Word.USERNAME_OR_EMAIL, null, v -> username.setPlaceholder(v)); username.setMaxLength(255); password = new PasswordField(); Language.setCustom(Word.PASSWORD, null, v -> password.setPlaceholder(v)); password.setMaxLength(50); passwordForgotten = new Button(VaadinIcons.KEY); Language.set(Word.PASSWORD_FORGOTTEN, passwordForgotten); passwordForgotten.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); passwordForgotten.addClickListener(ce -> UI.getCurrent().addWindow(PasswordRecoveryWindow.create())); login = new Button(); Language.set(Word.LOGIN, login); register = new Button(); login.setClickShortcut(KeyCode.ENTER, null); login.addClickListener(ce -> logInActions()); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setIcon(VaadinIcons.SIGN_IN); Language.set(Word.REGISTER, register); register.addClickListener(ce -> UI.getCurrent().addWindow(RegisterWindow.get())); register.setIcon(VaadinIcons.USER_CHECK); home = new Button(); home.setIcon(VaadinIcons.HOME); home.addClickListener(ce -> ClippingGorillaUI.getCurrent().setMainContent(ClippingView.getCurrent())); profile = new Button(Language.get(Word.PROFILES)); profile.setIcon(VaadinIcons.USER); Language.set(Word.PROFILES, profile); profile.addClickListener( ce -> ClippingGorillaUI.getCurrent().setMainContent(InterestProfileView.getCurrent())); groups = new Button(Language.get(Word.GROUPS)); groups.setIcon(VaadinIcons.GROUP); Language.set(Word.GROUPS, groups); groups.addClickListener(ce -> ClippingGorillaUI.getCurrent().setMainContent(GroupView.getCurrent())); userBar = new com.vaadin.ui.MenuBar(); addComponents(logo, spacing1, spacing2, username, password, login, register); SESSIONS.put(VaadinSession.getCurrent(), this); }
From source file:dhbw.clippinggorilla.userinterface.windows.ManageSourcesWindow.java
public static ManageSourcesWindow getCurrent() { return SESSIONS.get(VaadinSession.getCurrent()); }
From source file:dhbw.clippinggorilla.userinterface.windows.ManageSourcesWindow.java
public ManageSourcesWindow() { SESSIONS.put(VaadinSession.getCurrent(), this); setModal(true);/* w ww .ja va 2s . co m*/ setSizeUndefined(); setDraggable(true); setWidth("950px"); setHeight("850px"); center(); setClosable(false); setResizable(false); addCloseShortcut(ShortcutAction.KeyCode.ENTER, null); setContent(getSourcesList()); }