summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2017-03-13 11:24:41 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2017-03-13 11:24:41 +0100
commit09c4b4be9ec33bac7d814dbeb28095a7a7add835 (patch)
tree4bfda9a01916a45aa0dcc8b91305956fe75508bc
parent7b2889665d790585f4e1e0ac5c215359240a8d33 (diff)
downloadshare-09c4b4be9ec33bac7d814dbeb28095a7a7add835.zip
share-09c4b4be9ec33bac7d814dbeb28095a7a7add835.tar.gz
java : vaadin : add theme support
-rw-r--r--java/vaadin/build.xml38
-rw-r--r--java/vaadin/ivy.xml2
-rw-r--r--java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/home.pngbin0 -> 1783 bytes
-rw-r--r--java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss15
-rw-r--r--java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/styles.scss4
-rw-r--r--java/vaadin/src/main/java/ch/asynk/HelloWorld.java11
6 files changed, 60 insertions, 10 deletions
diff --git a/java/vaadin/build.xml b/java/vaadin/build.xml
index 5d9da2f..b1ee9f4 100644
--- a/java/vaadin/build.xml
+++ b/java/vaadin/build.xml
@@ -39,6 +39,7 @@
<target name="resolve" description="retrieve dependencies with Ivy">
<ivy:resolve file="ivy.xml" log="download-only"/>
<ivy:cachepath pathid="ivy.deps.server-side" conf="server-side" />
+ <ivy:cachepath pathid="ivy.deps.themes" conf="themes" />
<ivy:cachefileset setid="ivy.deps.server-side.fileset" conf="server-side"/>
</target>
@@ -66,7 +67,28 @@
</exec>
</target>
- <target name="compile-server-side" depends="configure,resolve,ctags">
+ <target name="-compile-theme" depends="configure,resolve">
+ <property name="theme.dir" value="${build.dir}/VAADIN/themes/${theme}" />
+ <delete dir="${theme.dir}"/>
+ <mkdir dir="${theme.dir}"/>
+ <java classname="com.vaadin.sass.SassCompiler" failonerror="yes" fork="true">
+ <classpath refid="ivy.deps.themes"/>
+ <jvmarg value="-Djava.awt.headless=true"/>
+ <arg value="-ignore-warnings:true"/>
+ <arg value="-compress:true"/>
+ <arg value="-minify:true"/>
+ <arg value="${web.dir}/VAADIN/themes/${theme}/styles.scss"/>
+ <arg value="${theme.dir}/styles.css"/>
+ </java>
+ </target>
+
+ <target name="compile-themes" description="compile application's themes">
+ <antcall target="-compile-theme">
+ <param name="theme" value="mytheme"/>
+ </antcall>
+ </target>
+
+ <target name="compile-server-side" description="compile server side components" depends="configure,resolve,ctags">
<record name="build.log" loglevel="verbose" action="start" />
<mkdir dir="${classes.dir}" />
<javac srcdir="${main.dir}"
@@ -84,7 +106,9 @@
</javac>
</target>
- <target name="package-war" depends="compile-server-side">
+ <target name="compile.all" description="compile everything" depends="compile-server-side,compile-themes"/>
+
+ <target name="package-war" depends="compile.all">
<mkdir dir="${lib.dir}"/>
<copy todir="${lib.dir}" flatten="true">
<fileset refid="ivy.deps.server-side.fileset"/>
@@ -105,11 +129,13 @@
<classes dir="${classes.dir}" includes="**" />
<fileset dir="${web.dir}">
<patternset>
- <include name="images/**/*" />
- <include name="VAADIN/widgetsets/**/*" />
<include name="*.html" />
<include name="WEB-INF/lib/*" />
<include name="WEB-INF/*.xml" />
+ <include name="VAADIN/widgetsets/**/*" />
+ <include name="VAADIN/themes/**/fonts/**/*" />
+ <include name="VAADIN/themes/**/icons/**/*" />
+ <include name="VAADIN/themes/**/images/**/*" />
</patternset>
</fileset>
<fileset dir="${build.dir}">
@@ -121,7 +147,7 @@
<!-- tomcat specific targets -->
- <target name="remove" depends="configure" description="Remove application on servlet container">
+ <target name="remove" depends="configure" description="remove application on servlet container">
<undeploy url="${manager.url}"
username="${manager.username}"
password="${manager.password}"
@@ -130,7 +156,7 @@
</target>
- <target name="install" depends="package-war,remove" description="Install application to servlet container">
+ <target name="install" depends="package-war,remove" description="install application to servlet container">
<copy todir="/tmp" file="${dist.dir}/${war.name}"/>
<deploy url="${manager.url}"
username="${manager.username}"
diff --git a/java/vaadin/ivy.xml b/java/vaadin/ivy.xml
index 7be4e62..57d71d3 100644
--- a/java/vaadin/ivy.xml
+++ b/java/vaadin/ivy.xml
@@ -10,6 +10,7 @@
<configurations>
<conf name="server-side" description="only needed for server side classes compilation"/>
+ <conf name="themes" extends="server-side" description="needed for theme compilation"/>
</configurations>
<dependencies defaultconf="server-side" defaultconfmapping="server-side->default">
@@ -18,5 +19,6 @@
<dependency org="com.vaadin" name="vaadin-client-compiled" rev="&vaadin.version;"/>
<dependency org="ch.qos.logback" name="logback-classic" rev="1.2.1"/>
<dependency org="org.codehaus.janino" name="janino" rev="3.0.6"/>
+ <dependency org="com.yahoo.platform.yui" name="yuicompressor" rev="2.4.8" conf="themes->default"/>
</dependencies>
</ivy-module>
diff --git a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/home.png b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/home.png
new file mode 100644
index 0000000..7362322
--- /dev/null
+++ b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/home.png
Binary files differ
diff --git a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss
new file mode 100644
index 0000000..f1c36c3
--- /dev/null
+++ b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss
@@ -0,0 +1,15 @@
+
+@import "../valo/valo.scss";
+
+@mixin mytheme {
+ @include valo;
+
+ .v-app {
+ background-color: #e6e6e9;
+ }
+ .v-button {
+ color: #ff6660;
+ background-image: none;
+ background-color: #eee666;
+ }
+}
diff --git a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/styles.scss b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/styles.scss
new file mode 100644
index 0000000..447ce98
--- /dev/null
+++ b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/styles.scss
@@ -0,0 +1,4 @@
+@import "mytheme.scss";
+.mytheme {
+ @include mytheme;
+}
diff --git a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java b/java/vaadin/src/main/java/ch/asynk/HelloWorld.java
index e811599..f15bddd 100644
--- a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java
+++ b/java/vaadin/src/main/java/ch/asynk/HelloWorld.java
@@ -3,6 +3,7 @@ package ch.asynk;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.ThemeResource;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
@@ -15,7 +16,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Title("Hello!!")
-@Theme("valo")
+@Theme("mytheme")
public class HelloWorld extends UI
{
private static final long serialVersionUID = 511085335415683713L;
@@ -28,8 +29,9 @@ public class HelloWorld extends UI
VerticalLayout content = new VerticalLayout();
setContent(content);
- content.addComponent(new Label("Hello World!"));
- content.addComponent(new Button("Push Me!", new ClickListener() {
+ content.addComponent(new Label("Hello World using mytheme"));
+ Button btn = new Button("Push Me!", new ThemeResource("icons/home.png"));
+ btn.addClickListener(new ClickListener() {
private static final long serialVersionUID = 5808429544582385114L;
@Override
public void buttonClick(ClickEvent event) {
@@ -42,6 +44,7 @@ public class HelloWorld extends UI
logger.warn("warn");
logger.error("error");
}
- }));
+ });
+ content.addComponent(btn);
}
}