@Override protected LegacyApplication createApplication() { VaadinServlet servlet = VaadinServlet.getCurrent(); if (servlet instanceof LegacyVaadinServlet) { LegacyVaadinServlet legacyServlet = (LegacyVaadinServlet) servlet; HttpServletRequest request = VaadinServletService .getCurrentServletRequest(); try { if (legacyServlet.shouldCreateApplication(request)) { return legacyServlet.getNewApplication(request); } } catch (ServletException e) { throw new RuntimeException(e); } } return null; } };
/** * Returns the current cms context.<p> * * @return the current cms context */ public static CmsObject getCmsObject() { return ((CmsUIServlet)VaadinServlet.getCurrent()).getCmsObject(); }
/** * Allows the only UI's Guice component provider to be injected. */ @Provides GuiceComponentProvider getUiGuiceComponentProvider() { return (GuiceComponentProvider) VaadinServlet.getCurrent().getServletContext().getAttribute("componentProvider"); }
@Override protected InputStream getApplicationResourceAsStream(Class<?> contextClass, String fileName) { ServletContext servletContext = VaadinServlet.getCurrent().getServletContext(); return servletContext.getResourceAsStream("/VAADIN/" + fileName); } }
private static URL getURL(int nodeId) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/element/node.jsp?node=" + nodeId; try { return new URL(currentLocation.toURL(), redirectFragment); } catch (MalformedURLException e) { throw Throwables.propagate(e); } }
protected String getFullUrl(final String urlFragment) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); try { return new URL(currentLocation.toURL(), contextRoot + "/" + urlFragment).toString(); } catch (final MalformedURLException e) { throw new RuntimeException("Failed to create full URL from current location: " + currentLocation + ", context root: " + contextRoot + ", url: " + urlFragment); } } }
protected String getFullUrl(final String urlFragment) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); try { return new URL(currentLocation.toURL(), contextRoot + "/" + urlFragment).toString(); } catch (final MalformedURLException e) { throw new RuntimeException("Failed to create full URL from current location: " + currentLocation + ", context root: " + contextRoot + ", url: " + urlFragment); } } }
protected String getFullUrl(final String urlFragment) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); try { return new URL(currentLocation.toURL(), contextRoot + "/" + urlFragment).toString(); } catch (final MalformedURLException e) { throw new RuntimeException("Failed to create full URL from current location: " + currentLocation + ", context root: " + contextRoot + ", url: " + urlFragment); } } }
private static URL getURL(int nodeId) { final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/element/node.jsp?node=" + nodeId; try { return new URL(currentLocation.toURL(), redirectFragment); } catch (MalformedURLException e) { throw Throwables.propagate(e); } }
private void init() { VaadinServlet vaadinServlet = VaadinServlet.getCurrent(); if (vaadinServlet == null) { System.err.println("Couldn't get current instance of VaadinServlet"); return; } context = WebApplicationContextUtils.getRequiredWebApplicationContext(vaadinServlet.getServletContext()); }
public UiContextBoundComponentProvider(UiContextReference uiContextReference) { this(uiContextReference, (GuiceComponentProvider) VaadinServlet.getCurrent().getServletContext().getAttribute("componentProvider"), CurrentUiContextReference.get()); }
@Override public void execute(final List<VertexRef> targets, final OperationContext operationContext) { final Collection<VertexRef> availableNodes = m_geoAssetProvider.getNodesWithCoordinates(); final StringBuilder sb = new StringBuilder(); sb.append(VaadinServlet.getCurrent().getServletContext().getContextPath()); sb.append("/node-maps#search/nodeId%20in%20"); final List<String> nodeIds = new ArrayList<>(); for (final VertexRef ref : targets) { if (availableNodes.contains(ref)) { nodeIds.add(ref.getId()); } } final Iterator<String> i = nodeIds.iterator(); while (i.hasNext()) { sb.append(i.next()); if (i.hasNext()) { sb.append(","); } } final String redirectUrl = sb.toString(); LOG.info("redirecting to: " + redirectUrl); final UI ui = operationContext.getMainWindow(); ui.getPage().getJavaScript().execute("window.location = '" + redirectUrl + "';"); }
@Override public void execute(final List<VertexRef> targets, final OperationContext operationContext) { final Collection<VertexRef> availableNodes = m_geoAssetProvider.getNodesWithCoordinates(); final StringBuilder sb = new StringBuilder(); sb.append(VaadinServlet.getCurrent().getServletContext().getContextPath()); sb.append("/node-maps#search/nodeId%20in%20"); final List<String> nodeIds = new ArrayList<>(); for (final VertexRef ref : targets) { if (availableNodes.contains(ref)) { nodeIds.add(ref.getId()); } } final Iterator<String> i = nodeIds.iterator(); while (i.hasNext()) { sb.append(i.next()); if (i.hasNext()) { sb.append(","); } } final String redirectUrl = sb.toString(); LOG.info("redirecting to: " + redirectUrl); final UI ui = operationContext.getMainWindow(); ui.getPage().getJavaScript().execute("window.location = '" + redirectUrl + "';"); }
@Override public void buttonClick(ClickEvent event) { // try if alarm is there, otherwise show information dialog OnmsAlarm alarm = alarmDao.get(alarmId); if (alarm == null) { new DialogWindow(source.getUI(), "Alarm does not exist!", "The alarm information cannot be shown. \nThe alarm does not exist anymore. \n\nPlease refresh the Alarm Table."); return; } // alarm still exists, show alarm details final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/alarm/detail.htm?quiet=true&id=" + alarmId; LOG.debug("alarm {} clicked, current location = {}, uri = {}", alarmId, currentLocation, redirectFragment); try { source.getUI().addWindow( new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new LabelCreator() { @Override public String getLabel() { return "Alarm Info " + alarmId; } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } });
@Override public void buttonClick(ClickEvent event) { // try if alarm is there, otherwise show information dialog OnmsAlarm alarm = alarmDao.get(alarmId); if (alarm == null) { new DialogWindow(source.getUI(), "Alarm does not exist!", "The alarm information cannot be shown. \nThe alarm does not exist anymore. \n\nPlease refresh the Alarm Table."); return; } // alarm still exists, show alarm details final URI currentLocation = Page.getCurrent().getLocation(); final String contextRoot = VaadinServlet.getCurrent().getServletContext().getContextPath(); final String redirectFragment = contextRoot + "/alarm/detail.htm?quiet=true&id=" + alarmId; LOG.debug("alarm {} clicked, current location = {}, uri = {}", alarmId, currentLocation, redirectFragment); try { source.getUI().addWindow( new InfoWindow(new URL(currentLocation.toURL(), redirectFragment), new LabelCreator() { @Override public String getLabel() { return "Alarm Info " + alarmId; } })); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); } } });
public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (shouldShowLogin() && !isLoginUIRequest(request)) { String link = OpenCms.getLinkManager().substituteLinkForUnknownTarget( ((CmsUIServlet)getCurrent()).getCmsObject(), CmsWorkplaceLoginHandler.LOGIN_FORM); String requestedUri = ((HttpServletRequest)request).getRequestURI(); if (!requestedUri.endsWith(OpenCms.getSystemInfo().getWorkplaceContext())) { link += "?" + CmsWorkplaceManager.PARAM_LOGIN_REQUESTED_RESOURCE + URLEncoder.encode(requestedUri, "UTF-8"); } OpenCms.getAuthorizationHandler().requestAuthorization( (HttpServletRequest)request, (HttpServletResponse)response, link); return true; } return false; } };
HttpServletRequest request = (HttpServletRequest)VaadinService.getCurrentRequest(); svc.setRequest(request); CmsObject cms = ((CmsUIServlet)getCurrent()).getCmsObject(); svc.setCms(cms);
m_cms = ((CmsUIServlet)VaadinServlet.getCurrent()).getCmsObject(); m_messages = Messages.get().getBundle(UI.getCurrent().getLocale()); m_resource = resource;