List of usage examples for com.vaadin.ui JavaScript getCurrent
public static JavaScript getCurrent()
From source file:edu.nps.moves.mmowgli.modules.maps.OpenLayersMap.java
License:Open Source License
public void initGuiTL() { setSpacing(true);//from w w w . j a v a 2 s . co m setSizeUndefined(); setWidth("100%"); addStyleName("m-marginleft-20"); Label lab; addComponent(lab = new HtmlLabel(title)); lab.setWidth(null); setComponentAlignment(lab, Alignment.MIDDLE_CENTER); CssLayout cssLay = new CssLayout(); cssLay.addStyleName("m-greybackground"); cssLay.addStyleName("m-darkgreyborder"); cssLay.setWidth("960px"); cssLay.setHeight("600px"); cssLay.setId("mmowgliMap"); addComponent(cssLay); setComponentAlignment(cssLay, Alignment.TOP_CENTER); /* See http://wiki.openstreetmap.org/wiki/OpenLayers_Simple_Example This requires the "http://openlayers.org/api/OpenLayers.js" file to be loaded: see the annotation in Mmowgli2UI.java. */ /* One example layer: String js = "var m_map = new OpenLayers.Map('mmowgliMap');"+ "var m_wms = new OpenLayers.Layer.WMS( \"OpenLayers WMS\","+ "\"http://vmap0.tiles.osgeo.org/wms/vmap0\", {layers: 'basic'} );"+ "m_map.addLayer(m_wms);"+ "m_map.zoomToMaxExtent();"; */ String jsOSM = "mMap = new OpenLayers.Map('mmowgliMap');" + // "shadeLayer = new OpenLayers.Layer.WMS("+ // "\"Shaded Relief\"," + // "\"http://ims.cr.usgs.gov:80/servlet19/com.esri.wms.Esrimap/USGS_EDC_Elev_NED_3\","+ // "{layers: HR-NED.IMAGE, reaspect: false, transparent: true, visibility: false}); "+ "var osLay = new OpenLayers.Layer.OSM();" + "var fromProjection = new OpenLayers.Projection(\"EPSG:4326\");" + // Transform from WGS 1984 "var toProjection = new OpenLayers.Projection(\"EPSG:900913\");" + // to Spherical Mercator Projection "var position = new OpenLayers.LonLat(-121.875267, 36.599878).transform( fromProjection, toProjection);" + "var zoom = 15;" + " mMap.addLayer(osLay);" + //" mMap.addLayer(shadeLayer);"+ //" mMap.addControl(new OpenLayers.Control.LayerSwitcher());"+ " mMap.setCenter(position, zoom );"; /* String worldWind = "mMap = new OpenLayers.Map('mmowgliMap', {'maxResolution': .28125, tileSize: new OpenLayers.Size(512, 512)});"+ "var osLay = new OpenLayers.Layer.OSM();"+ "var ol_wms = new OpenLayers.Layer.WMS( \"OpenLayers WMS\", \"http://vmap0.tiles.osgeo.org/wms/vmap0?\", {layers: 'basic'} );"+ // "var ww = new OpenLayers.Layer.WorldWind( \"Bathy\",\"http://worldwind25.arc.nasa.gov/tile/tile.aspx?\", 36, 4,{T:\"bmng.topo.bathy.200406\"});"+ // "var ww2 = new OpenLayers.Layer.WorldWind( \"LANDSAT\",\"http://worldwind25.arc.nasa.gov/tile/tile.aspx\", 2.25, 4,{T:\"105\"});"+ "mMap.addLayers([osLay]); //,ol_wms]);"+ //, ww, ww2]);"+ // "mMap.addControl(new OpenLayers.Control.LayerSwitcher());"+ "var fromProjection = new OpenLayers.Projection(\"EPSG:4326\");"+ // Transform from WGS 1984 "var toProjection = new OpenLayers.Projection(\"EPSG:900913\");"+ // to Spherical Mercator Projection "var position = new OpenLayers.LonLat(-121.875267, 36.599878).transform( fromProjection, toProjection);"+ "var zoom = 15;"+ //"mMap.setCenter(new OpenLayers.LonLat(-71.4, 42.3), 6);"+ " mMap.setCenter(position, zoom );"+ ""; */ JavaScript.getCurrent().execute(jsOSM); }
From source file:edu.nps.moves.mmowgli.utility.BrowserWindowOpener.java
License:Open Source License
public static void open(String url) { JavaScript.getCurrent().execute("window.open('" + url + "');"); }
From source file:edu.nps.moves.mmowgli.utility.BrowserWindowOpener.java
License:Open Source License
public static void open(String url, String windowName) { JavaScript.getCurrent().execute("window.open('" + url + "','" + windowName + "');"); }
From source file:edu.nps.moves.mmowgli.utility.BrowserWindowOpener.java
License:Open Source License
public static void openWithHTML(String htmlStr, String title, String windowName) { StringBuilder javascript = new StringBuilder(); htmlStr = openCommon(htmlStr, windowName, javascript); javascript.append(winVar);/*from w w w . j a v a2 s . co m*/ javascript.append(".document.title='"); javascript.append(title); javascript.append("';\n"); javascript.append(winVar); javascript.append(".document.open();\n"); javascript.append(winVar); javascript.append(".document.write(\""); javascript.append(htmlStr); javascript.append("\");\n"); javascript.append(winVar); javascript.append(".document.close();\n"); //System.out.println(javascript.toString()); JavaScript.getCurrent().execute(javascript.toString()); }
From source file:edu.nps.moves.mmowgli.utility.BrowserWindowOpener.java
License:Open Source License
public static void openWithInnerHTML(String htmlStr, String title, String windowName) { StringBuilder javascript = new StringBuilder(); htmlStr = openCommon(htmlStr, windowName, javascript); javascript.append(winVar);/*from ww w . j a va2 s . c om*/ javascript.append(".document.title='"); javascript.append(title); javascript.append("';\n"); javascript.append(winVar); javascript.append(".document.body.innerHTML=\""); javascript.append(htmlStr); javascript.append("\";"); //System.out.println(javascript.toString()); JavaScript.getCurrent().execute(javascript.toString()); // this does work...tested on small content }
From source file:edu.nps.moves.mmowgli.utility.BrowserWindowOpener.java
License:Open Source License
public static void openHtmlReport(String htmlStr, String title, String windowName) { StringBuilder javascript = new StringBuilder(); javascript.append("var "); javascript.append(winVar);/*from w w w. j ava2 s . c om*/ javascript.append("=window.open('', '"); javascript.append(windowName); javascript.append("');\n"); htmlStr = htmlStr.replace("\n", "
"); // This was hard to find!, won't work in style elements htmlStr = htmlStr.replace("'", "'"); javascript.append(winVar); javascript.append(".document.title='"); javascript.append(title); javascript.append("';\n"); javascript.append(winVar); javascript.append(".location.href=\"data:text/html;base64,\"+"); javascript.append("btoa('"); javascript.append(htmlStr); javascript.append("');"); //System.out.println(javascript.toString()); JavaScript.getCurrent().execute(javascript.toString()); }
From source file:edu.nps.moves.mmowgli.utility.BrowserWindowOpener.java
License:Open Source License
public static void openXmlReport(String xmlStr, String title, String windowName) { StringBuilder javascript = new StringBuilder(); javascript.append("var "); javascript.append(winVar);/*from w w w.ja va2 s . c o m*/ javascript.append("=window.open('', '"); javascript.append(windowName); javascript.append("');\n"); javascript.append(winVar); javascript.append(".document.title='"); javascript.append(title); javascript.append("';\n"); javascript.append(winVar); javascript.append(".location.href=\"data:text/xml;base64,"); javascript.append(new String(Base64.encodeBase64(xmlStr.getBytes(), false))); javascript.append("\";\n"); //System.out.println(javascript.toString()); JavaScript.getCurrent().execute(javascript.toString()); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { LOG.log(Level.INFO, "Current working directory: {0}", System.getProperty("user.home")); Page.getCurrent().setTitle("Validation Manager"); updateScreen();/*ww w . ja v a 2s.c o m*/ //For the code below see: https://vaadin.com/forum#!/thread/1553240/8194235 JavaScript.getCurrent().addFunction("aboutToClose", (JsonArray arguments) -> { try { if (user != null) { int id = SESSIONS.get(VaadinSession.getCurrent().getSession().getId()); VMUserServer u = new VMUserServer(id); LOG.log(Level.FINE, "Clearing session for user: {0}", u.toString()); SESSIONS.remove(VaadinSession.getCurrent().getSession().getId()); } } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); } }); Page.getCurrent().getJavaScript().execute( "window.onbeforeunload = function (e) { var e = e || window.event; aboutToClose(); return; };"); }
From source file:org.apache.usergrid.chop.webapp.view.util.JavaScriptUtil.java
License:Apache License
private static void execute(String script) { JavaScript.getCurrent().execute(script); }
From source file:org.apache.usergrid.chop.webapp.view.util.JavaScriptUtil.java
License:Apache License
private static void addCallback(String jsCallbackName, JavaScriptFunction jsCallback) { JavaScript.getCurrent().addFunction(jsCallbackName, jsCallback); }