1. Harald Schilly
  2. gtug-vienna-gwt

Commits

Harald Schilly  committed 949564b

initial import

  • Participants
  • Branches default

Comments (0)

Files changed (12)

File .classpath

View file
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" output="test-classes" path="test"/>
+	<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="lib/gwtquery-1.0.0-SNAPSHOT-2.2.0.jar"/>
+	<classpathentry kind="output" path="war/WEB-INF/classes"/>
+</classpath>

File .hgignore

View file
+
+syntax: regexp
+^optimize/solution/.*$
+^db/backup/.*$
+^.gwt/.*$
+^war/lecturewishing$
+^www-test$
+^tomcat$
+^war/WEB-INF/classes$
+^war/WEB-INF/deploy/.*$
+^test-classes$
+^db/data$
+^db/.*.log$
+^extras$
+.*.pyc$
+^\.apt_generated/evenbus\.properties
+lecturewishing.war
+gurobi.log

File .project

View file
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>GwtQueryDemo</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>com.google.gwt.eclipse.core.gwtNature</nature>
+	</natures>
+</projectDescription>

File .settings/com.google.gdt.eclipse.core.prefs

View file
+#Sat Mar 26 00:59:18 CET 2011
+eclipse.preferences.version=1
+warSrcDir=war
+warSrcDirIsOutput=true

File .settings/com.google.gwt.eclipse.core.prefs

View file
+#Sat Mar 26 15:27:57 CET 2011
+eclipse.preferences.version=1
+filesCopiedToWebInfLib=gwt-servlet.jar
+gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy1vcHRpbWl6ZSAwIC1zdHlsZSBERVRBSUxFRCAgLVhkaXNhYmxlQ2xhc3NNZXRhZGF0YSAtWGRpc2FibGVDYXN0Q2hlY2tpbmddXT48L2V4dHJhLWFyZ3M+PHZtLWFyZ3M+PCFbQ0RBVEFbLVhteDUxMm1dXT48L3ZtLWFyZ3M+PC9nd3QtY29tcGlsZS1zZXR0aW5ncz4\=

File src/at/schilly/gwtquerydemo/GwtQueryDemo.gwt.xml

View file
+<?xml version="1.0" encoding="UTF-8"?>
+<module rename-to='gwtquerydemo'>
+  <!-- Inherit the core Web Toolkit stuff. -->
+  <inherits name='com.google.gwt.user.User' />
+
+  <!-- Inherit the default GWT style sheet. You can change -->
+  <!-- the theme of your GWT application by uncommenting -->
+  <!-- any one of the following lines. -->
+  <inherits name='com.google.gwt.user.theme.standard.Standard' />
+  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
+  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
+
+  <!-- Other module inherits -->
+  <inherits name='com.google.gwt.query.Query' />
+
+  <!-- Specify the app entry point class. -->
+  <entry-point class='at.schilly.gwtquerydemo.client.GwtQueryDemo' />
+
+  <!-- Specify the paths for translatable code -->
+  <source path='client' />
+  <source path='shared' />
+
+</module>

File src/at/schilly/gwtquerydemo/client/GwtQueryDemo.java

View file
+package at.schilly.gwtquerydemo.client;
+
+import static com.google.gwt.query.client.GQuery.$;
+import static com.google.gwt.query.client.css.CSS.BACKGROUND_COLOR;
+import static com.google.gwt.query.client.css.CSS.FONT_SIZE;
+import static com.google.gwt.query.client.css.CSS.TEXT_ALIGN;
+
+import com.google.gwt.animation.client.Animation;
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Style.Unit;
+import com.google.gwt.query.client.Function;
+import com.google.gwt.query.client.GQuery;
+import com.google.gwt.query.client.Selector;
+import com.google.gwt.query.client.Selectors;
+import com.google.gwt.query.client.css.FontSizeProperty.FontSize;
+import com.google.gwt.query.client.css.RGBColor;
+import com.google.gwt.query.client.css.TextAlignProperty.TextAlign;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.RootPanel;
+
+public class GwtQueryDemo implements EntryPoint {
+  MyGWTQuerySelectors selectors = GWT.create(MyGWTQuerySelectors.class);
+  
+  interface MyGWTQuerySelectors extends Selectors {
+    @Selector(".A")
+    GQuery getAs();
+    
+    @Selector(".B")
+    GQuery getBs();
+    
+    /** this is the alink below the list */
+    @Selector("#link1")
+    GQuery getLink();
+  }
+  
+  // global constants
+  static final double INDENT  = 40;
+  
+  // application's internal state
+  static Boolean      animate = false;
+  boolean             state   = false;
+  
+  /**
+   * This is where the application starts.
+   */
+  public void onModuleLoad() {
+    
+    // page contents
+    RootPanel.get().add(new MainPage());
+    
+    // generate 30 entries
+    list(30);
+    
+    selectors.getLink().click(new Function() {
+      @Override
+      public void f() {
+        RGBColor c = state ? RGBColor.GREEN : RGBColor.RED;
+        selectors.getAs().css(BACKGROUND_COLOR.with(c));
+        state = !state;
+      }
+    });
+    
+    selectors.getBs().mouseover(new Function() {
+      @Override
+      public void f(Element e) {
+        if (!animate) {
+          $(e).css(FONT_SIZE.with(FontSize.LARGE));
+          e.getStyle().setPaddingLeft(20, Unit.PX);
+        } else {
+          FadeInOrOut fioo = new FadeInOrOut(e, FadeInOrOut.Type.In);
+          fioo.run(2000);
+        }
+      }
+    });
+    
+    selectors.getBs().mouseout(new Function() {
+      @Override
+      public void f(Element e) {
+        if (!animate) {
+          e.getStyle().clearFontSize();
+          e.getStyle().setPaddingLeft(0, Unit.PX);
+        } else {
+          FadeInOrOut fioo = new FadeInOrOut(e, FadeInOrOut.Type.Out);
+          fioo.run(2000);
+        }
+      }
+    });
+    
+    selectors.getAs().click(new Function() {
+      @Override
+      public void f(Element e) {
+        boolean o = $(e).get(0).getPropertyBoolean("state");
+        $(e).css(TEXT_ALIGN.with(o ? TextAlign.LEFT : TextAlign.RIGHT));
+        $(e).get(0).setPropertyBoolean("state", !o);
+      }
+    });
+    
+  }
+  
+  private void list(int anz) {
+    Element container = $("#container").get(0);
+    for (int i = 0; i < anz; i++) {
+      Element div = DOM.createDiv();
+      div.setInnerText("line " + i);
+      div.setAttribute("class", (i % 2 == 0) ? "A" : "B");
+      container.appendChild(div);
+    }
+  }
+}
+
+/**
+ * custom animation
+ * 
+ * @author schilly
+ */
+class FadeInOrOut extends Animation {
+  
+  enum Type {
+    In, Out
+  }
+  
+  final private static double s = 2;
+  private Type                t;
+  private Element             e;
+  private double              start;
+  
+  FadeInOrOut(Element e, Type t) {
+    this.e = e;
+    this.t = t;
+    this.start = GwtQueryDemo.INDENT;
+    
+    // attach each animation object to the respective element
+    // and cancel animations immediately when they are ongoing.
+    if (e.getPropertyObject("animation") != null) {
+      FadeInOrOut a = ((FadeInOrOut) e.getPropertyObject("animation"));
+      a.cancel();
+    }
+    e.setPropertyObject("animation", this);
+  }
+  
+  @Override
+  protected void onUpdate(double x) {
+    // in our out
+    x = (t == Type.In) ? x : 1 - x;
+    // overshoot cubic
+    x = (s + 1) * x * x * x - s * x * x;
+    e.getStyle().setPaddingLeft(x * start, Unit.PX);
+  }
+}

File src/at/schilly/gwtquerydemo/client/MainPage.java

View file
+package at.schilly.gwtquerydemo.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Anchor;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.ToggleButton;
+
+class MainPage extends Composite {
+  
+  private static MainPageUiBinder uiBinder = GWT.create(MainPageUiBinder.class);
+  
+  interface MainPageUiBinder extends UiBinder<HTMLPanel, MainPage> {}
+  
+  @UiField
+  Anchor       link2;
+  
+  @UiField
+  ToggleButton animate;
+  
+  public MainPage() {
+    initWidget(uiBinder.createAndBindUi(this));
+    
+    // more init code
+  }
+  
+  @UiHandler("animate")
+  void onAnimateToggle(ClickEvent e) {
+    GwtQueryDemo.animate = animate.getValue();
+  }
+  
+  @UiHandler("link2")
+  void onLink2Click(ClickEvent e) {
+    Window.alert("Hello, UiHandler talking!");
+  }
+  
+  public void setText(String text) {
+    link2.setText(text);
+  }
+  
+  public String getText() {
+    return link2.getText();
+  }
+  
+}

File src/at/schilly/gwtquerydemo/client/MainPage.ui.xml

View file
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
+
+  <ui:style>
+    .important {
+      text-align: center;
+      font-size: 200%;
+      font-weight: bold;
+    }
+  </ui:style>
+
+
+  <g:HTMLPanel>
+
+    <h1>GWT Query Demo</h1>
+    <div id="container"></div>
+    <div styleName="{style.important}" style="text-align:center; font-size: 200%;">
+      <a href="#" id="link1">click me</a>
+      or
+      <g:Anchor ui:field="link2">me</g:Anchor>.
+      <br/>
+      <g:ToggleButton ui:field="animate">animate?</g:ToggleButton>
+    </div>
+
+  </g:HTMLPanel>
+</ui:UiBinder> 

File war/GwtQueryDemo.css

View file
+/** Add css rules here for your application. */
+
+
+/** Example rules used by the template application (remove for your app) */
+h1 {
+  font-size: 2em;
+  font-weight: bold;
+  color: #777777;
+  text-align: center;
+}
+
+html { background: grey; 
+  margin: 30px;}
+
+body {
+  width: 300px;
+}
+
+.sendButton {
+  display: block;
+  font-size: 16pt;
+}
+
+/** Most GWT widgets already have a style name defined */
+.gwt-DialogBox {
+  width: 400px;
+}
+
+.dialogVPanel {
+  margin: 5px;
+}
+
+.serverResponseLabelError {
+  color: red;
+}
+
+/** Set ids using widget.getElement().setId("idOfElement") */
+#closeButton {
+  margin: 15px 6px 6px;
+}

File war/GwtQueryDemo.html

View file
+<!doctype html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+
+<link type="text/css" rel="stylesheet" href="GwtQueryDemo.css">
+
+<title>GWT Query Demo</title>
+<script type="text/javascript" language="javascript"
+  src="gwtquerydemo/gwtquerydemo.nocache.js"></script>
+</head>
+
+<body>
+</body>
+</html>

File war/WEB-INF/web.xml

View file
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app
+    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+    "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+  
+  <!-- Servlets -->
+  
+  <!-- Default page to serve -->
+  <welcome-file-list>
+    <welcome-file>GwtQueryDemo.html</welcome-file>
+  </welcome-file-list>
+
+</web-app>