List of usage examples for com.vaadin.server VaadinServlet getCurrent
public static VaadinServlet getCurrent()
From source file:org.opennms.features.vaadin.surveillanceviews.ui.dashboard.SurveillanceViewNotificationTable.java
License:Open Source License
/** * Constructor for instantiating this component. * * @param surveillanceViewService the surveillance view service to be used * @param enabled the flag should links be enabled? *//*from w ww . j a va2 s. c o m*/ public SurveillanceViewNotificationTable(SurveillanceViewService surveillanceViewService, boolean enabled) { /** * calling the super constructor */ super("Notifications", surveillanceViewService, enabled); /** * set the datasource */ setContainerDataSource(m_beanItemContainer); /** * set the base style name */ addStyleName("surveillance-view"); /** * add node column */ addGeneratedColumn("nodeLabel", new ColumnGenerator() { @Override public Object generateCell(final Table table, final Object itemId, final Object propertyId) { final Notification notification = (Notification) itemId; Button icon = getClickableIcon("glyphicon glyphicon-bell", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/notification/detail.jsp?quiet=true¬ice=" + notification.getId(); LOG.debug("notification {} clicked, current location = {}, uri = {}", notification.getId(), currentLocation, redirectFragment); try { SurveillanceViewNotificationTable.this.getUI() .addWindow(new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new InfoWindow.LabelCreator() { @Override public String getLabel() { return "Notification Info " + notification.getId(); } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } }); Button button = new Button(notification.getNodeLabel()); button.setPrimaryStyleName(BaseTheme.BUTTON_LINK); button.setEnabled(m_enabled); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/element/node.jsp?quiet=true&node=" + notification.getNodeId(); ; LOG.debug("node {} clicked, current location = {}, uri = {}", notification.getNodeId(), currentLocation, redirectFragment); try { SurveillanceViewNotificationTable.this.getUI() .addWindow(new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new InfoWindow.LabelCreator() { @Override public String getLabel() { return "Node Info " + notification.getNodeId(); } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } }); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.addComponent(icon); horizontalLayout.addComponent(button); horizontalLayout.setSpacing(true); return horizontalLayout; } }); /** * set the cell style generator */ setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(final Table source, final Object itemId, final Object propertyId) { Notification notification = ((Notification) itemId); return notification.getSeverity().toLowerCase(); } }); /** * set column headers */ setColumnHeader("nodeLabel", "Node"); setColumnHeader("serviceType", "Service"); setColumnHeader("textMsg", "Message"); setColumnHeader("pageTime", "Sent Time"); setColumnHeader("answeredBy", "Responder"); setColumnHeader("respondTime", "Respond Time"); setColumnExpandRatio("nodeLabel", 2.0f); setColumnExpandRatio("serviceType", 1.0f); setColumnExpandRatio("textMsg", 4.0f); setColumnExpandRatio("pageTime", 2.0f); setColumnExpandRatio("answeredBy", 1.0f); setColumnExpandRatio("respondTime", 2.0f); /** * define visible columns */ setVisibleColumns("nodeLabel", "serviceType", "textMsg", "pageTime", "answeredBy", "respondTime"); }
From source file:org.ozkar.vaadinBootstrapp.common.MasterPage.java
public MasterPage() { VerticalLayout root = new VerticalLayout(); SpringContextHelper helper = new SpringContextHelper(VaadinServlet.getCurrent().getServletContext()); menu = (Menu) helper.getBean("menu"); root.addComponent(menu);/*from www .j a v a 2 s . co m*/ root.addComponent(view); view.setSizeFull(); this.setSizeFull(); this.setWidth("100%"); this.setHeight("100%"); this.setCompositionRoot(root); }
From source file:org.ripla.web.internal.services.RiplaEventDispatcher.java
License:Open Source License
private String getAppLocation() { return VaadinServlet.getCurrent().getServletContext().getContextPath() + VaadinServletService.getCurrentServletRequest().getServletPath(); }
From source file:org.ripla.web.util.RiplaRequestHandler.java
License:Open Source License
/** * RequestHandler constructor.//from w ww .j a va 2s .c o m */ public RiplaRequestHandler() { requestURL = VaadinServlet.getCurrent().getServletContext().getContextPath() + VaadinServletService.getCurrentServletRequest().getServletPath(); }
From source file:org.vaadin.spring.samples.mvp.ui.component.listener.LogoutLinkListener.java
License:Apache License
@Override public void buttonClick(ClickEvent event) { SecurityContextHolder.clearContext(); BannerView banner = (BannerView) event.getComponent().getParent(); String contextPath = VaadinServlet.getCurrent().getServletContext().getContextPath(); String urlMapping = env.getProperty("vaadin.servlet.urlMapping"); String uiPath = urlMapping.substring(0, urlMapping.length() - 2); String location = contextPath.concat(uiPath); banner.getUI().getPage().setLocation(location); }
From source file:uk.co.intec.keyDatesApp.utils.AppUtils.java
License:Apache License
/** * Gets the context parameter dataDbFilePath from web.xml * * @return String path of NSF that stores the data, on this server *//* w ww . j a v a 2 s . co m*/ public static String getDataDbFilepath() { return VaadinServlet.getCurrent().getServletContext().getInitParameter("dataDbFilePath"); }