List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:de.metas.procurement.webui.LoggingConfiguration.java
License:Open Source License
public void updateMDC() { ///*from w w w. j a v a2 s. co m*/ // Remote address try { final VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); if (vaadinRequest != null) { final String remoteAddr = vaadinRequest.getRemoteAddr(); MDC.put(MDC_Param_RemoteAddr, remoteAddr); } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_RemoteAddr, "?"); } // // LoggedUser try { final MFSession mfSession = MFProcurementUI.getCurrentMFSession(); if (mfSession != null) { final User user = mfSession.getUser(); if (user != null) { final String email = user.getEmail(); if (email != null) { MDC.put(MDC_Param_LoggedUser, email); } } } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_LoggedUser, "?"); } // // UserAgent try { final Page page = Page.getCurrent(); if (page != null) { final WebBrowser webBrowser = page.getWebBrowser(); if (webBrowser != null) { final String userAgent = webBrowser.getBrowserApplication(); MDC.put(MDC_Param_UserAgent, userAgent); } } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_UserAgent, "?"); } // // SessionId try { final VaadinSession session = VaadinSession.getCurrent(); if (session != null) { final int sessionId = System.identityHashCode(session); MDC.put(MDC_Param_SessionId, Integer.toString(sessionId)); } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_SessionId, "?"); } // // UI Id try { final UI ui = UI.getCurrent(); if (ui != null) { final int uiId = ui.getUIId(); MDC.put(MDC_Param_UIId, Integer.toString(uiId)); } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_UIId, "?"); } }
From source file:de.metas.ui.web.vaadin.session.UserSession.java
License:Open Source License
public static final UserSession getCurrent() { final VaadinSession vaadinSession = VaadinSession.getCurrent(); if (vaadinSession == null) { return null; }//from w w w . ja va 2 s .c o m if (vaadinSession.hasLock()) { return getCurrent(vaadinSession); } else { final Mutable<UserSession> userSessionRef = new Mutable<UserSession>(); vaadinSession.accessSynchronously(new Runnable() { @Override public void run() { userSessionRef.setValue(getCurrent(vaadinSession)); } }); return userSessionRef.getValue(); } }
From source file:de.steinwedel.messagebox.MessageBox.java
License:Apache License
/** * Here you can configure a default language for the dialogs session scoped. * * @param locale The new session-scoped language *//*from www .ja va2s . c o m*/ public static void setDialogSessionLanguage(Locale locale) { VaadinSession.getCurrent().setAttribute(ButtonCaptionFactory.LANGUAGE_SESSION_KEY, locale); }
From source file:de.symeda.sormas.ui.login.LoginHelper.java
License:Open Source License
public static boolean logout() { try {//from w w w . jav a 2s. co m VaadinServletService.getCurrentServletRequest().logout(); } catch (ServletException e) { return false; } VaadinSession.getCurrent().getSession().invalidate(); Page.getCurrent().reload(); return true; }
From source file:de.symeda.sormas.ui.login.LoginUI.java
License:Open Source License
@Override public void init(VaadinRequest vaadinRequest) { setErrorHandler(SormasErrorHandler.get()); setLocale(vaadinRequest.getLocale()); Responsive.makeResponsive(this); VaadinSession.getCurrent().setConverterFactory(new SormasDefaultConverterFactory()); getPage().setTitle("SORMAS"); setContent(new LoginScreen(new LoginListener() { @Override/*from w ww .j a v a 2 s .c o m*/ public void loginSuccessful() { UI.getCurrent().getPage() .setLocation(VaadinServletService.getCurrentServletRequest().getContextPath() + "#" + DataHelper.toStringNullable(UI.getCurrent().getPage().getUriFragment())); } })); }
From source file:de.symeda.sormas.ui.SormasUI.java
License:Open Source License
@Override public void init(VaadinRequest vaadinRequest) { setErrorHandler(SormasErrorHandler.get()); setLocale(vaadinRequest.getLocale()); Responsive.makeResponsive(this); VaadinSession.getCurrent().setConverterFactory(new SormasDefaultConverterFactory()); getPage().setTitle("SORMAS"); initMainScreen();/*from w ww.java 2 s .c o m*/ }
From source file:de.unioninvestment.eai.portal.portlet.crud.CrudUI.java
License:Apache License
/** * Initialisierung des PortletPresenter. * /* w w w . j av a2 s .c o m*/ */ @Override public void doInit(VaadinRequest request) { setId(UUID.randomUUID().toString()); logLifecycleEvent(LifecycleEvent.CRUD2GO_UI_INIT); autowireUiDependencies(request); uiHistory.add(this); VaadinSession.getCurrent().setErrorHandler(new CrudErrorHandler()); applyBrowserLocale(); helpPage = initializeHelpPage(); setContent(viewPage); tryToSetPortletTitle(Context.getMessage("portlet.crud.window.name")); recreateEditPage(); refreshViews(); getPortletSession().addPortletListener(this); }
From source file:de.unioninvestment.eai.portal.portlet.crud.export.AbstractTableExportTask.java
License:Apache License
/** * Wait for background task to finish releasing the UI lock for that time *//*from w ww .j ava 2s.c om*/ private void waitForFinishing() { try { VaadinSession.getCurrent().getLockInstance().unlock(); while (true) { if (finished) { return; } try { Thread.sleep(100); } catch (InterruptedException e) { return; } } } finally { VaadinSession.getCurrent().getLockInstance().lock(); } }
From source file:de.unioninvestment.eai.portal.support.vaadin.ParameterRetrievalRequestHandler.java
License:Apache License
@SuppressWarnings("unchecked") public Map<String, String[]> getParameters() { return (Map<String, String[]>) VaadinSession.getCurrent().getAttribute("parameters"); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.WorkflowComponent.java
License:Open Source License
private void updateParameterView(Workflow workFlow, BeanItemContainer<DatasetBean> projectDatasets) { this.submission.setCaption(SUBMISSION_CAPTION + ": " + workFlow.getName()); this.submission.removeAllComponents(); if (workFlow.getName().equals("MaxQuant")) { BeanItemContainer<RawFilesBean> rawFilesBeans = new BeanItemContainer<RawFilesBean>(RawFilesBean.class); BeanItemContainer<FastaBean> selectedfastas = new BeanItemContainer<FastaBean>(FastaBean.class); BeanItemContainer<FastaBean> fastas = new BeanItemContainer<FastaBean>(FastaBean.class); FastaDB db = new FastaDB(); fastas.addAll(db.getAll());//from w ww . java 2 s.c om Map<String, Parameter> params = workFlow.getData().getData(); BeanItemContainer<DatasetBean> subContainer = new BeanItemContainer<DatasetBean>(DatasetBean.class); for (Map.Entry<String, Parameter> entry : params.entrySet()) { if (entry.getValue() instanceof FileParameter || entry.getValue() instanceof FileListParameter) { List<String> associatedDataTypes = new ArrayList<String>(); if (entry.getValue() instanceof FileParameter) { associatedDataTypes = ((FileParameter) entry.getValue()).getRange(); } else if (entry.getValue() instanceof FileListParameter) { associatedDataTypes = ((FileListParameter) entry.getValue()).getRange(); } if (associatedDataTypes.contains("fasta") || associatedDataTypes.contains("gtf")) { continue; } else { for (java.util.Iterator<DatasetBean> i = projectDatasets.getItemIds().iterator(); i .hasNext();) { DatasetBean dataset = i.next(); if (associatedDataTypes.contains(dataset.getFileType())) { subContainer.addBean(dataset); } } } } } MaxQuantModel model = new MaxQuantModel(rawFilesBeans, subContainer, selectedfastas, fastas); VaadinSession.getCurrent().setConverterFactory(new MaxquantConverterFactory()); MaxQuantComponent maxquantComponent = new MaxQuantComponent(model, controller); maxquantComponent.setWorkflow(workFlow); maxquantComponent.addSubmissionListener(new MaxQuantSubmissionListener(maxquantComponent)); this.submission.addComponent(maxquantComponent); } else if (workFlow.getName().contains("Microarray QC")) { MicroarrayQCComponent qcComp = new MicroarrayQCComponent(controller); qcComp.update(workFlow, projectDatasets); qcComp.addResetListener(new MicroarrayQCResetListener(qcComp)); qcComp.addSubmissionListener(new MicroarrayQCSubmissionListener(qcComp)); this.submission.addComponent(qcComp); } else if ((workFlow.getName().contains("NGS Read Alignment")) || (workFlow.getName().contains("RNA-seq"))) { NGSMappingComponent mappComp = new NGSMappingComponent(controller); mappComp.update(workFlow, projectDatasets); mappComp.addResetListener(new NGSMappingResetListener(mappComp)); mappComp.addSubmissionListener(new NGSMappingSubmissionListener(mappComp)); this.submission.addComponent(mappComp); } else if (workFlow.getName().contains("Differential")) { DifferentialExpressionComponent diffComp = new DifferentialExpressionComponent(controller); diffComp.update(workFlow, projectDatasets); diffComp.addResetListener(new DifferentialExpressionResetListener(diffComp)); diffComp.addSubmissionListener(new DifferentialExpressionSubmissionListener(diffComp)); this.submission.addComponent(diffComp); } else { StandardWorkflowComponent standardComponent = new StandardWorkflowComponent(controller); standardComponent.update(workFlow, projectDatasets); standardComponent.addResetListener(new ResetListener(standardComponent)); standardComponent.addSubmissionListener(new StandardSubmissionListener(standardComponent)); this.submission.addComponent(standardComponent); } }