Skip to content

Commit

Permalink
Basic structure of a (non-working) GWT toy client
Browse files Browse the repository at this point in the history
There are still many things to fix in the code itself, see 'ant gwtc' for a
complete list of things to fix.

This commit adds the appropriate Ant targets, the GWT XML file, scaffolding
HTML code and the Java source file for the frontend (which is just an alert()
for now).

Committing this code mostly for not keeping it in my local machine, it's
unusable as of now (but the normal Ant targets should not be broken).
  • Loading branch information
lupino3 committed Jun 3, 2016
1 parent 8f67be8 commit ea5a734
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 0 deletions.
72 changes: 72 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<!-- Set build file properties -->
<property name="sourceDir" value="src/org/edumips64/" />
<property name="webDir" value="src/org/edumips64/client/" />
<property name="testDir" value="test/org/edumips64/" />
<property name="outputDir" value="build" />
<property name="javadocDir" value="javadoc" />
Expand All @@ -43,13 +44,83 @@
<property name="src_java_version" value="8" />
<property name="dst_java_version" value="8" />
<property name="debug" value="on" />

<!-- Arguments to gwtc and devmode targets -->
<property name="gwt.args" value="" />

<!-- Configure path to GWT SDK. TODO: make this auto-discovered or
something, it's not good to point to /home/andrea.-->
<property name="gwt.sdk" location="/home/andrea/gwt-2.7.0" />
<path id="project.class.path">
<pathelement location="war/WEB-INF/classes"/>
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
<pathelement location="${gwt.sdk}/gwt-dev.jar"/>
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar"/>
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar"/>
<fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
<!-- Add any additional non-server libs (such as JUnit) here -->
<pathelement location="libs/jhall.jar"/>
</path>
</target>

<target name="webLibs" depends="init" description="Copy libs to WEB-INF/lib">
<mkdir dir="war/WEB-INF/lib" />
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" />
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-deps.jar" />
<!-- Add any additional server libs that need to be copied -->
</target>

<target name="compileWeb" depends="webLibs" description="Compile java source to bytecode">
<mkdir dir="war/WEB-INF/classes"/>
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
source="1.7" target="1.7" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
<copy todir="war/WEB-INF/classes">
<fileset dir="src" excludes="**/*.java"/>
</copy>
</target>

<target name="mkdirs" depends="init">
<!-- Create directories for the compilation process. -->
<mkdir dir="${outputDir}" />
</target>

<target name="gwtc" depends="compileWeb" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler" maxmemory="256m">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="org.edumips64.webclient"/>
<arg line="-strict"/>
</java>
</target>

<target name="devmode" depends="compileWeb" description="Run development mode (pass -Dgwt.args=-nosuperDevMode to fallback to classic DevMode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode" maxmemory="1g">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.sdk}/gwt-codeserver.jar"/>
</classpath>
<arg value="-startupUrl"/>
<arg value="edumips64.html"/>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY, -logLevel DEBUG or -nosuperDevMode -->
<arg line="${gwt.args}"/>
<arg value="org.edumips64.web.WebUi"/>
<arg value="org.edumips64.web.WebUi"/>
</java>
</target>

<!-- *** clean *** target that cleans the built files and the build directory-->
<target name="clean" depends="init,cleandocs">
<delete file="${standalone_jar_filename}" />
Expand Down Expand Up @@ -125,6 +196,7 @@
destdir="${outputDir}"
debug="${debug}"
debuglevel="lines,vars,source"
excludes="client/**"
includeantruntime="false"
classpath="${base.classpath}">
<compilerarg value="-Xlint"/>
Expand Down
49 changes: 49 additions & 0 deletions edumips64.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="gwt" name="GWT">
<configuration>
<setting name="compilerMaxHeapSize" value="1024" />
<setting name="gwtScriptOutputStyle" value="DETAILED" />
<setting name="gwtSdkUrl" value="file://" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build" />
<output-test url="file://$MODULE_DIR$/out/test/edumips64" />
Expand Down Expand Up @@ -38,5 +47,45 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/gwt-2.7.0/gwt-user.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/gwt-2.7.0/gwt-user.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/gwt-2.7.0/gwt-dev.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/gwt-2.7.0/gwt-dev.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/gwt-2.7.0/validation-api-1.0.0.GA.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES />
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/gwt-2.7.0/validation-api-1.0.0.GA-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>
29 changes: 29 additions & 0 deletions src/org/edumips64/client/WebUi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.edumips64.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;

import org.edumips64.core.CPU;
import org.edumips64.core.Parser;
import org.edumips64.utils.ConfigStore;
import org.edumips64.utils.ConfigManager;

public class WebUi implements EntryPoint {
private CPU cpu;
private Parser parser;
private ConfigStore config = ConfigManager.getTmpConfig();

public void onModuleLoad() {
Button b = new Button("Start", new ClickHandler() {
public void onClick(ClickEvent event) {
Window.alert("THE RESULTS OF THE COMPUTATION.");
}
});

RootPanel.get().add(b);
}
}
7 changes: 7 additions & 0 deletions src/org/edumips64/webclient.gwt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<module rename-to="edumips64">
<inherits name="com.google.gwt.user.User"/>
<entry-point class="org.edumips64.client.WebUi"/>
<source path="client" />
<source path="core" />
<source path="utils" />
</module>
15 changes: 15 additions & 0 deletions war/edumips64.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>EduMIPS64</title>
<script type="text/javascript" language="javascript" src="webUi/webUi.nocache.js"></script>
</head>
<body bgcolor="white">
<noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color:white; border: 1px solid red; padding: 4px; font-family: sans-serif">
Your web browser must have JavaScript enabled
in order for this application to display correctly.
</div>
</noscript>
</body>
</html>

0 comments on commit ea5a734

Please sign in to comment.