Skip to content

Instantly share code, notes, and snippets.

@barmic
Created August 5, 2018 09:08
Show Gist options
  • Save barmic/be18783d3c4fba874e73f0d75ca62e44 to your computer and use it in GitHub Desktop.
Save barmic/be18783d3c4fba874e73f0d75ca62e44 to your computer and use it in GitHub Desktop.
HelloWorld Atlas
import info.q37.atlas.*;
class Hello extends Atlas {
public void handle( DOM dom, String action, String id )
{
String head =
"<title>\"Hello, World !\" example</title>" +
"<style type=\"text/css\">" +
" html, body { height: 100%; padding: 0; margin: 0; }" +
" .vcenter-out, .hcenter { display: table; height: 100%; margin: auto; }" +
" .vcenter-in { display: table-cell; vertical-align: middle; }" +
"</style>";
String html =
"<div class=\"vcenter-out\">" +
" <div class=\"vcenter-in\">" +
" <fieldset>" +
" <label>Name:</label>" +
" <input id=\"input\" maxlength=\"20\" placeholder=\"Enter a name here\"'" +
" type=\"text\" data-xdh-onevent=\"input|Typing\"/>" +
" <button data-xdh-onevent=\"Clear\">Clear</button>" +
" <hr/>" +
" <h1>" +
" <span>Hello </span>" +
" <span style=\"font-style: italic;\" id=\"name\"></span>" +
" <span>!</span>" +
" </h1>" +
" </fieldset>" +
" </div>" +
"</div>";
if ( "Connect".equals( action ) ) {
dom.headUp( head );
dom.setLayout("", html);
} else if ("Typing".equals( action ) ) {
dom.setContent("name", dom.getContent(id));
} else if ( "Clear".equals( action ) ) {
if ( dom.confirm( "Are you sure ?" ) )
dom.setContents( new String[][] { { "input", ""}, { "name", ""} } );
} else {
throw new RuntimeException( "Unknown action '" + action + "' !!!");
}
}
public static void main(String[] args) throws Exception {
launch("Connect" );
for (;;)
new Hello();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<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>org.atlas</groupId>
<artifactId>atlas</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.atlas</groupId>
<artifactId>atlas</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>HelloWorldAtlas</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<!-- This tells Maven to include all dependencies -->
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>Hello</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- Configure the execution of the compiler to execute the codegen processor -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment