static BrowserType getBrowserType() { if (browserType == null) { String userAgent = Navigator.getUserAgent(); System.out.println("UA: " + userAgent); if (userAgent == null) { browserType = BrowserType.OTHER; } else if (userAgent.indexOf("Chrome/") != -1) { browserType = BrowserType.CHROME; } else if (userAgent.indexOf("Safari/") != -1) { browserType = BrowserType.SAFARI; } else if (userAgent.indexOf("Firefox/") != -1 || userAgent.indexOf("Minefield/") != -1) { browserType = BrowserType.FIREFOX; } else { browserType = BrowserType.OTHER; } } return browserType; }
/** * This is the entry point method. */ public void onModuleLoad() { if(Navigator.getUserAgent().contains("MSIE")) { NodeList<Element> divs = RootPanel.getBodyElement().getElementsByTagName("div"); for(int j = 0; j < divs.getLength(); j++) { Element element = divs.getItem(j); if(element.hasAttribute("name") && element.getAttribute("name").equals("opennms-interfacelist")) { createView(element); } } }else { NodeList<Element> nodes = RootPanel.getBodyElement().getElementsByTagName("opennms:interfacelist"); if(nodes.getLength() > 0) { for(int i = 0; i < nodes.getLength(); i++) { Element elem = nodes.getItem(i); createView(elem); } } } }
@Override public void onModuleLoad() { if(Navigator.getUserAgent().contains("MSIE")) { NodeList<Element> divs = RootPanel.getBodyElement().getElementsByTagName("div"); for(int j = 0; j < divs.getLength(); j++) { Element element = divs.getItem(j); if(element.hasAttribute("name") && element.getAttribute("name").equals("opennms-snmpSelectList")) { createView(element); } } }else { NodeList<Element> nodes = RootPanel.getBodyElement().getElementsByTagName("opennms:snmpSelectList"); if(nodes.getLength() > 0) { for(int i = 0; i < nodes.getLength(); i++) { Element elem = nodes.getItem(i); createView(elem); } } } }
private Handler<GWTVertex> vertexClickHandler() { return new D3Events.Handler<GWTVertex>(){ public void call(GWTVertex vertex, int index) { NativeEvent event = D3.getEvent(); SVGGElement vertexElement = event.getCurrentEventTarget().cast(); vertexElement.getParentElement().appendChild(vertexElement); m_client.updateVariable(m_paintableId, "clickedVertex", vertex.getId(), false); m_client.updateVariable(m_paintableId, "shiftKeyPressed", event.getShiftKey(), false); m_client.updateVariable(m_paintableId, "metaKeyPressed", event.getMetaKey(), false); m_client.updateVariable(m_paintableId, "ctrlKeyPressed", event.getCtrlKey(), false); m_client.updateVariable(m_paintableId, "platform", Navigator.getPlatform(), false); event.preventDefault(); event.stopPropagation(); m_client.sendPendingVariableChanges(); } }; }
public static void checkJava() throws Throwable { if (!Navigator.isJavaEnabled()) { BrowserCheck.openInstallJavaPage(); throw new Exception( "This application requires Java but it is not installed. Please <a href=\"" + BrowserCheck.INSTALL_JAVA + "\">install Java</a>. "); } }
/** * Checks if the user agent belongs to mobile browser. (iPhone, iPad, android blackberry or Nokia) Note that not all * mobile devices are supported see detectmobilebrowsers.com for the most recent mobile user agents * * @return whether the browser is mobile (true or false) */ public static boolean isMobile() { if (GWT.isClient()) { String userAgent = Navigator.getUserAgent(); for (String platform : MOBILE_PLATFORMS) { if (userAgent.toLowerCase().indexOf(platform) != -1) { return true; } } } return false; }
/** * Check if this is a tablet. */ public static boolean isTablet() { if (Navigator.getUserAgent().contains("iPad") || Navigator.getUserAgent().contains("Android")) { return true; } return false; }
private void initIosScroollHack() { needsIos6ScrollingWorkaround = Navigator.getUserAgent().contains( " OS 6_") && Navigator.getUserAgent().contains(" afari"); // Disable hack if "fullscreen", the hack disturbs e.g. SwipeView a // LOT as it slows down "warming up" the hardware accelerated layer if (needsIos6ScrollingWorkaround && getOffsetWidth() == RootPanel.get().getOffsetWidth()) { needsIos6ScrollingWorkaround = false; } }
public static boolean isIE() { String ua = Navigator.getUserAgent().toLowerCase(); return ua.indexOf("msie") != -1; }
public static boolean isChromeFrame() { String ua = Navigator.getUserAgent().toLowerCase(); return ua.indexOf("chromeframe") != -1; }