List of usage examples for com.vaadin.server VaadinSession getLocale
public Locale getLocale()
From source file:com.ocs.dynamo.domain.model.impl.EntityModelFactoryImpl.java
License:Apache License
protected Locale getLocale() { VaadinSession session = VaadinSession.getCurrent(); if (session != null) { return session.getLocale(); }// www . ja v a 2 s. co m return Locale.getDefault(); }
From source file:com.ocs.dynamo.service.impl.MessageServiceImpl.java
License:Apache License
private Locale getLocale() { VaadinSession session = VaadinSession.getCurrent(); if (session != null) { return session.getLocale(); }/* w ww . j a v a 2s.com*/ return Locale.getDefault(); }
From source file:info.magnolia.ui.form.field.factory.AbstractFieldFactoryTestCase.java
License:Open Source License
@Before public void setUp() throws Exception { // Init Message & Providers i18NAuthoringSupport = mock(I18NAuthoringSupport.class); ComponentsTestUtil.setInstance(I18NAuthoringSupport.class, i18NAuthoringSupport); ComponentsTestUtil.setImplementation(TypeMapping.class, TypeMappingImpl.class); ComponentsTestUtil.setImplementation(Node2BeanTransformer.class, Node2BeanTransformerImpl.class); ComponentsTestUtil.setImplementation(Node2BeanProcessor.class, Node2BeanProcessorImpl.class); ComponentsTestUtil.setImplementation(MessagesManager.class, DefaultMessagesManager.class); SystemContext systemContext = mock(SystemContext.class); when(systemContext.getLocale()).thenReturn(DEFAULT_LOCALE); ComponentsTestUtil.setInstance(SystemContext.class, systemContext); VaadinSession vaadinSession = mock(VaadinSession.class); when(vaadinSession.getConverterFactory()).thenReturn(new DefaultConverterFactory()); when(vaadinSession.getLocale()).thenReturn(DEFAULT_LOCALE); when(vaadinSession.hasLock()).thenReturn(true); ComponentsTestUtil.setInstance(VaadinSession.class, vaadinSession); // Init Session session = new MockSession(workspaceName); MockContext ctx = new MockContext(); ctx.addSession(workspaceName, session); MgnlContext.setInstance(ctx);//from w w w . j ava 2 s .c om // Create ConfiguredField POJO createConfiguredFieldDefinition(); // Init Node and Item. Node rootNode = session.getRootNode(); baseNode = rootNode.addNode(itemName); baseItem = new JcrNodeAdapter(baseNode); componentProvider = new MockComponentProvider(); componentProvider.setInstance(I18NAuthoringSupport.class, mock(I18NAuthoringSupport.class)); componentProvider.setInstance(UiContext.class, mock(UiContext.class)); }
From source file:org.adho.dhconvalidator.ui.VaadinSessionLocaleProvider.java
@Override public Locale getLocale() { VaadinSession session = VaadinSession.getCurrent(); if (session != null) { return session.getLocale(); }/*from ww w . ja v a2 s . c o m*/ return null; }