Skip to content

Instantly share code, notes, and snippets.

@niloc132
niloc132 / Log.java
Created February 17, 2014 20:20 — forked from carchrae/Log.java
public class Log {
/*
* type - is "INFO", "DEBUG", "ERROR" etc
* object - is an "id" of the person calling it. as a convention, I use 'this' unless it is a static method, then I pass in the class
* msg - the log message
*/
public static void log(String type, Object object, String msg) {
@niloc132
niloc132 / HowDoIInnterHtml.java
Created February 4, 2014 18:17
In non-IE browsers, changing the innerHTML of an element detaches its children, but leaves them intact. In IE, it also clears the innerhtml property of all children, detaching all descendants.
public class HowDoIInnerHtml implements EntryPoint {
@Override
public void onModuleLoad() {
Element body = Document.get().getBody();
DivElement newDiv = Document.get().createDivElement();
newDiv.setClassName("foo");
newDiv.setInnerText("Text in the div");
SpanElement newSpan = Document.get().createSpanElement();
Window.alert("about to add handlers");
Window.addCloseHandler(new CloseHandler<Window>() {
@Override
public void onClose(CloseEvent<Window> event) {
Window.alert("close");
}
}) ;
Window.addWindowClosingHandler(new ClosingHandler() {
@Override
public void onWindowClosing(ClosingEvent event) {
public interface OptionsObj {
public List<String> getKeys();
public void setKeys(List<String> keys);
@PropertyName("include_docs")
public boolean isIncludeDocs();
@PropertyName("include_docs")
publiv void setIncludeDocs(boolean includeDocs);
}
@niloc132
niloc132 / Module.gwt.xml
Last active December 20, 2015 04:29
Full stack traces in compiled code
<!-- Turn on GWT logging -->
<set-property name="gwt.logging.logLevel" value="FINEST" />
<set-property name="gwt.logging.enabled" value="TRUE" />
<!-- ...except the popup handler, which is just about useless -->
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<!-- optional: turn on gxt internal logging -->
<set-property name="gxt.logging.enabled" value="true" />
<!-- emulated stack traces so you can see the full error -->
public class MyGinModule extends AbstractGinModule {
public void configure() {
//...
//OPTION 1 part 1
bind(Scheduler.class).toProvider(MySchedulerProvider.class);
//...
}
//OPTION 2
public class Sample implements IsWidget {
private final Binder binder = GWT.create(Binder.class);
private Widget root;
@UiField(provided=true) MyBundle bundle = GWT.create(MyBundle.class);
public Sample() {
//first, provided items
bundle.myCss().ensureInjected();
@niloc132
niloc132 / gxt230.patch
Created April 26, 2013 15:57
Quick draft at bringing Sigma-h up to GXT 2.3.0-gwt22
Index: pom.xml
===================================================================
--- pom.xml (revision 1297)
+++ pom.xml (working copy)
@@ -139,7 +139,7 @@
<dependency>
<groupId>com.extjs</groupId>
<artifactId>gxt</artifactId>
- <version>2.2.5-gwt22</version>
+ <version>2.3.0-gwt22</version>
Compiling module com.sencha.gxt.test.TestRunner
---------------------------
JAVA INITIAL:
---------------------------
public void display(Splittable result){
Window.alert("boolean value? " + result.asBoolean() + "\n" + "is null? " + (result == null));
}
---------------------------
FinalizeVisitor:
---------------------------
@niloc132
niloc132 / Snippet.java
Last active December 15, 2015 10:49 — forked from icfantv/Snippet.java
String xml = "<root><elt>sum stuff</elt><elt anAttribute=\"attr_value\">more stuff</elt></root>";
XmlXhtmlRenderer renderer = new XmlXhtmlRenderer();
try
{
result = renderer.highlight("some-text-can-be-anything", xml, "UTF-8", true);
LOGGER.trace("added syntax highlighting to XML: {}", result);
}
catch (IOException ex)
{
LOGGER.error("unable to syntax hightlight adi xml for asset: {}", assetKey, ex);