summaryrefslogtreecommitdiffstats
path: root/java/vaadin/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'java/vaadin/src/main')
-rw-r--r--java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/help.pngbin0 -> 1582 bytes
-rw-r--r--java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/layouts/About.html10
-rw-r--r--java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss18
-rw-r--r--java/vaadin/src/main/java/ch/asynk/Daddy.java25
-rw-r--r--java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java1
-rw-r--r--java/vaadin/src/main/java/ch/asynk/HelloWorldUI.java130
-rw-r--r--java/vaadin/src/main/java/ch/asynk/ui/Icons.java9
-rw-r--r--java/vaadin/src/main/java/ch/asynk/ui/ViewMain.java32
8 files changed, 192 insertions, 33 deletions
diff --git a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/help.png b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/help.png
new file mode 100644
index 0000000..e91d95a
--- /dev/null
+++ b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/icons/help.png
Binary files differ
diff --git a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/layouts/About.html b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/layouts/About.html
new file mode 100644
index 0000000..7020e1d
--- /dev/null
+++ b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/layouts/About.html
@@ -0,0 +1,10 @@
+<div style='margin:10px'>
+<h1>HelloWorld 0.0.0</h1>
+
+<p>powered by <ul>
+<li><a target="_blank" href="https://vaadin.com">vaadin</a> java framework for building modern web applications</li>
+<li><a target="_blank" href="http://debian.org">debian</a> a free operating system (OS) for your computer.</li>
+</ul></p>
+<p>written by <a target="_blank" href="mailto:jeremy@asynk.ch">Jérémy Zurcher</a>
+as a part of <a target="_blank" href="https://github.com/jeremyz/share">share</a></p>.
+</div>
diff --git a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss
index f1c36c3..ad29293 100644
--- a/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss
+++ b/java/vaadin/src/main/WebContent/VAADIN/themes/mytheme/mytheme.scss
@@ -3,13 +3,15 @@
@mixin mytheme {
@include valo;
-
- .v-app {
- background-color: #e6e6e9;
- }
- .v-button {
- color: #ff6660;
- background-image: none;
- background-color: #eee666;
+ .v-app { background-color: #e6e6e9; }
+ .mybg { background-color: #e6e6e6; }
+ .v-verticallayout-margin-top { padding-top: $v-layout-margin-top; }
+ .v-verticallayout-margin-right { padding-right: $v-layout-margin-top; }
+ .v-menubar {
+ .v-menubar-menuitem-menuRight {
+ position: absolute;
+ right: 10px;
+ top: 0;
+ }
}
}
diff --git a/java/vaadin/src/main/java/ch/asynk/Daddy.java b/java/vaadin/src/main/java/ch/asynk/Daddy.java
new file mode 100644
index 0000000..3f279fd
--- /dev/null
+++ b/java/vaadin/src/main/java/ch/asynk/Daddy.java
@@ -0,0 +1,25 @@
+package ch.asynk;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Daddy
+{
+ private static final long serialVersionUID = 1L;
+
+ public static final String SESSION_STATUS = "SESSION_STATUS";
+
+ private static final Logger logger;
+
+ static {
+ logger = LoggerFactory.getLogger(Daddy.class);
+ warn("beware Daddy is up");
+ }
+
+ public static void trace(String msg) { logger.trace(msg); }
+ public static void debug(String msg) { logger.debug(msg); }
+ public static void warn(String msg) { logger.warn(msg); }
+ public static void info(String msg) { logger.info(msg); }
+ public static void error(String msg) { logger.error(msg); }
+ public static void error(String msg, Exception e) { logger.error(String.format("%s : %s", msg, e.getMessage())); }
+}
diff --git a/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java b/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java
index e4157c4..d0e8374 100644
--- a/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java
+++ b/java/vaadin/src/main/java/ch/asynk/HelloWorldServlet.java
@@ -27,6 +27,7 @@ public class HelloWorldServlet extends VaadinServlet implements SessionInitListe
public void sessionInit(SessionInitEvent event) throws ServiceException
{
event.getSession().setLocale(new java.util.Locale("fr", "CH"));
+ event.getSession().setAttribute(Daddy.SESSION_STATUS, "unknown");
System.err.println("sessionInit");
}
diff --git a/java/vaadin/src/main/java/ch/asynk/HelloWorldUI.java b/java/vaadin/src/main/java/ch/asynk/HelloWorldUI.java
index f4579be..be65387 100644
--- a/java/vaadin/src/main/java/ch/asynk/HelloWorldUI.java
+++ b/java/vaadin/src/main/java/ch/asynk/HelloWorldUI.java
@@ -3,50 +3,130 @@ package ch.asynk;
import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
+import com.vaadin.navigator.Navigator;
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;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomLayout;
+import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Label;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.Command;
+import com.vaadin.ui.MenuBar.MenuItem;
import com.vaadin.ui.Notification;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import ch.asynk.ui.Icons;
+import ch.asynk.ui.ViewMain;
@PreserveOnRefresh
-@Title("Hello!!")
@Theme("mytheme")
+@Title("Hello!!")
public class HelloWorldUI extends UI
{
- private static final long serialVersionUID = 511085335415683713L;
- private static Logger logger = null;
+ private static final long serialVersionUID = 1L;
+
+ private static final String HOME = "Home";
+ private static final String ABOUT = "About";
+
+ private Navigator navigator;
@Override
protected void init(VaadinRequest request)
{
- logger = LoggerFactory.getLogger(this.getClass());
- VerticalLayout content = new VerticalLayout();
- setContent(content);
-
- 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;
+ final VerticalLayout vl = new VerticalLayout();
+ vl.setSizeFull();
+ vl.setMargin(true);
+ setContent(vl);
+
+ final MenuBar menu = createMenuBar();
+
+ final HorizontalSplitPanel hsplit = new HorizontalSplitPanel();
+ hsplit.setSplitPosition(80f);
+ hsplit.addComponent(createLeftPanel());
+ hsplit.addComponent(createRightPanel());
+
+ vl.addComponents(menu, hsplit);
+ vl.setExpandRatio(menu, 0);
+ vl.setExpandRatio(hsplit, 1);
+
+ navigateToHome();
+ }
+
+ private Component createLeftPanel()
+ {
+ final VerticalLayout vl = new VerticalLayout();
+ vl.addStyleName("margin-top");
+ vl.addStyleName("margin-right");
+ navigator = new Navigator(this, vl);
+ navigator.addView(HOME, ViewMain.class);
+ return vl;
+ }
+
+ private Component createRightPanel()
+ {
+ final VerticalLayout vl = new VerticalLayout();
+ vl.setMargin(true);
+ vl.addStyleName("mybg");
+ // vl.addStyleName("margin-top");
+ // vl.addStyleName("margin-right");
+ vl.addComponent(new Label("Hello World using mytheme"));
+ Button btn = new Button("Push Me!", Icons.home);
+ btn.addClickListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 1L;
@Override
- public void buttonClick(ClickEvent event) {
+ public void buttonClick(Button.ClickEvent event) {
Notification.show("Pushed!");
- System.out.println("System.out");
- System.err.println("System.err");
- logger.trace("trace");
- logger.debug("debug");
- logger.info("info");
- logger.warn("warn");
- logger.error("error");
+ Daddy.trace("trace");
+ Daddy.debug("debug");
+ Daddy.info("info");
+ Daddy.warn("warn");
+ Daddy.error("error");
}
});
- content.addComponent(btn);
+ vl.addComponent(btn);
+ return vl;
+ }
+
+ private MenuBar createMenuBar()
+ {
+ Command menuCommand = new Command() {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public void menuSelected(MenuItem selectedItem) {
+ String itemText = selectedItem.getText();
+ if (itemText.equals(HOME)) {
+ navigateToHome();
+ } else if (itemText.equals(ABOUT)) {
+ showAbout();
+ } else {
+ Daddy.error("unhandeled MenuItem : " + itemText);
+ }
+ }
+ };
+
+ final MenuBar menu = new MenuBar();
+ menu.addItem(HOME, Icons.home, menuCommand);
+ menu.addItem(ABOUT, Icons.help, menuCommand);
+ MenuBar.MenuItem login = menu.addItem((String) UI.getCurrent().getSession().getAttribute(Daddy.SESSION_STATUS), menuCommand);
+ login.setStyleName("menuRight");
+ menu.setWidth("100%");
+
+ return menu;
+ }
+
+ public void navigateToHome() { navigator.navigateTo(HOME); }
+
+ private void showAbout()
+ {
+ final Window about = new Window(ABOUT);
+ about.setContent( new CustomLayout(ABOUT) );
+ about.setHeight("50%");
+ about.setWidth("600px");
+ about.center();
+ about.setModal(true);
+ UI.getCurrent().addWindow(about);
}
}
diff --git a/java/vaadin/src/main/java/ch/asynk/ui/Icons.java b/java/vaadin/src/main/java/ch/asynk/ui/Icons.java
new file mode 100644
index 0000000..98bfb5f
--- /dev/null
+++ b/java/vaadin/src/main/java/ch/asynk/ui/Icons.java
@@ -0,0 +1,9 @@
+package ch.asynk.ui;
+
+import com.vaadin.server.ThemeResource;
+
+public class Icons
+{
+ public static final ThemeResource help = new ThemeResource("icons/help.png");
+ public static final ThemeResource home = new ThemeResource("icons/home.png");
+}
diff --git a/java/vaadin/src/main/java/ch/asynk/ui/ViewMain.java b/java/vaadin/src/main/java/ch/asynk/ui/ViewMain.java
new file mode 100644
index 0000000..489e328
--- /dev/null
+++ b/java/vaadin/src/main/java/ch/asynk/ui/ViewMain.java
@@ -0,0 +1,32 @@
+package ch.asynk.ui;
+
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
+
+public class ViewMain extends TabSheet implements View
+{
+ private static final long serialVersionUID = 1L;
+
+ public ViewMain()
+ {
+ addStyleName("framed");
+ addTab(content("0"), "Tab 0", Icons.home, 0);
+ addTab(content("1"), "Tab 1");
+ setSelectedTab(2);
+ }
+
+ @Override
+ public void enter(ViewChangeEvent event) {
+ System.err.println(this.getClass().getName()+"::enter");
+ }
+
+ private VerticalLayout content(String s)
+ {
+ VerticalLayout ly = new VerticalLayout();
+ ly.addComponent(new Label(" Hi, this is " + s));
+ return ly;
+ }
+}