Created
February 22, 2013 11:00
-
-
Save ibaca/5012631 to your computer and use it in GitHub Desktop.
GWT.isSuperDevMode()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.intendia.igestion.web.util.info; | |
import com.google.gwt.core.client.GWT; | |
import com.google.gwt.dom.client.Document; | |
import com.google.gwt.dom.client.Element; | |
import com.google.gwt.dom.client.ScriptElement; | |
public class DefaultRuntimeInfo implements RuntimeInfo { | |
@Override | |
public boolean isProdMode() { | |
return GWT.isProdMode() && !isSuperDevMode(); | |
} | |
@Override | |
public boolean isScript() { | |
return GWT.isScript(); | |
} | |
@Override | |
public boolean isAssertionEnabled() { | |
return getClass().desiredAssertionStatus(); | |
} | |
private boolean isSuperDevMode() { | |
Element head = Document.get().getElementsByTagName("head").getItem(0); | |
Element scriptNode = head.getFirstChildElement(); | |
if (!ScriptElement.is(scriptNode)) { | |
return false; // Super dev mode is always the first script | |
} | |
ScriptElement scriptElement = ScriptElement.as(scriptNode); | |
String scriptSrc = scriptElement.getSrc(); | |
if (scriptSrc != null && scriptSrc.startsWith("http://localhost:")) { | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment