Skip to content

Instantly share code, notes, and snippets.

@ghillairet
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghillairet/d0a212f016dc3e326e19 to your computer and use it in GitHub Desktop.
Save ghillairet/d0a212f016dc3e326e19 to your computer and use it in GitHub Desktop.
gef3-draw2d for gwt basic example
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="app">
<inherits name="com.google.gwt.user.User" />
<inherits name="org.eclipse.gef.Gef" />
<entry-point class='app.App'/>
<source path="" />
<!-- Super Dev Mode -->
<add-linker name="xsiframe" />
<set-configuration-property name="devModeRedirectEnabled" value="true"/>
<set-property name="compiler.useSourceMaps" value="true" />
<!-- Only support recent browsers -->
<set-property name="user.agent" value="ie10,gecko1_8,safari" />
</module>
package app;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Ellipse;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Point;
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
public class App implements EntryPoint {
public void onModuleLoad() {
Canvas canvas = Canvas.createIfSupported();
canvas.setWidth("500px");
canvas.setHeight("500px");
canvas.setCoordinateSpaceHeight(500);
canvas.setCoordinateSpaceWidth(500);
LightweightSystem ls = new LightweightSystem(new org.eclipse.swt.widgets.Canvas(canvas));
Figure parent = new Figure();
parent.setLayoutManager(new XYLayout());
ls.setContents(parent);
Ellipse e = new Ellipse();
e.setSize(30, 30);
e.setLocation(new Point(40, 50));
e.setForegroundColor(ColorConstants.red);
RectangleFigure r = new RectangleFigure();
r.setSize(50, 60);
r.setLocation(new Point(140, 150));
r.setForegroundColor(ColorConstants.green);
r.setBackgroundColor(ColorConstants.yellow);
parent.add(e);
parent.add(r);
RootPanel.get().add(canvas);
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sample</groupId>
<artifactId>app</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<properties>
<gwt.module>app.App</gwt.module>
<gwt.genParam>false</gwt.genParam>
<!-- keep in sync with app-server -->
<runTarget>http://localhost:8080/</runTarget>
</properties>
<repositories>
<repository>
<id>emfgwt-repository</id>
<url>http://repository-ghillairet.forge.cloudbees.com/snapshot</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.6.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipselabs</groupId>
<artifactId>org.eclipse.gef</artifactId>
<version>3.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.6.1</version>
<configuration>
<module>${gwt.module}</module>
<strict>false</strict>
<genParam>${gwt.genParam}</genParam>
<noserver>true</noserver>
<runTarget>${runTarget}</runTarget>
<deploy>${project.build.directory}/gwtc/extra</deploy>
<extra>${project.build.directory}/gwtc/extra</extra>
<gen>${project.build.directory}/gwtc/gen</gen>
<!-- There's an issue on Mac: see http://code.google.com/p/google-web-toolkit/issues/detail?id=7474
<workDir>${project.build.directory}/gwtc/work</workDir> <codeServerWorkDir>${project.build.directory}/gwtc/superDevMode</codeServerWorkDir> -->
</configuration>
<executions>
<execution>
<id>gwt-compile</id>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.1.2.v20140210</version>
<configuration>
<scanIntervalSeconds>1</scanIntervalSeconds>
<webApp>
<baseResource implementation="org.eclipse.jetty.util.resource.ResourceCollection">
<resourcesAsCSV>webapp,${basedir}/target/app-${project.version}/</resourcesAsCSV>
</baseResource>
</webApp>
<systemProperties>
<systemProperty>
<name>gwt.codeserver.port</name>
<value>9876</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment