Skip to content
Browse files

* Activities and places example, not finished

  • Loading branch information...
1 parent 321841c commit 2cbe189d43e81d426009bd7147a450f651e83a64 @IvanLazov committed Jun 26, 2012
Showing with 361 additions and 0 deletions.
  1. BIN activitiesandplaces/lib/gwt-user.jar
  2. +11 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/App.gwt.xml
  3. +10 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/App.java
  4. +17 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/AppFactory.java
  5. +36 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/AppFactoryImpl.java
  6. +24 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/activity/GoodbyeActivity.java
  7. +39 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/activity/HelloActivity.java
  8. +10 −0 ...iesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/mapper/AppPlaceHistoryMapper.java
  9. +32 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/places/GoodbyePlace.java
  10. +31 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/places/HelloPlace.java
  11. +9 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/GoodbyeView.java
  12. +28 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/GoodbyeViewImpl.java
  13. +6 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/GoodbyeViewImpl.ui.xml
  14. +16 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/HelloView.java
  15. +49 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/HelloViewImpl.java
  16. +16 −0 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/HelloViewImpl.ui.xml
  17. +9 −0 activitiesandplaces/war/App.css
  18. +10 −0 activitiesandplaces/war/App.html
  19. +8 −0 activitiesandplaces/war/WEB-INF/web.xml
View
BIN activitiesandplaces/lib/gwt-user.jar
Binary file not shown.
View
11 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/App.gwt.xml
@@ -0,0 +1,11 @@
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0//EN"
+ "http://google-web-toolkit.googlecode.com/svn/releases/2.0/distro-source/core/src/gwt-module.dtd">
+<module rename-to="App">
+
+ <inherits name='com.google.gwt.user.User'/>
+ <inherits name="com.google.gwt.place.Place"/>
+ <inherits name="com.google.gwt.activity.Activity"/>
+
+ <entry-point class='com.clouway.gwt.activitiesandplaces.app.client.App'/>
+
+</module>
View
10 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/App.java
@@ -0,0 +1,10 @@
+package com.clouway.gwt.activitiesandplaces.app.client;
+
+import com.google.gwt.core.client.EntryPoint;
+
+public class App implements EntryPoint {
+
+ public void onModuleLoad() {
+
+ }
+}
View
17 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/AppFactory.java
@@ -0,0 +1,17 @@
+package com.clouway.gwt.activitiesandplaces.app.client;
+
+import com.clouway.gwt.activitiesandplaces.app.client.ui.GoodbyeView;
+import com.clouway.gwt.activitiesandplaces.app.client.ui.HelloView;
+import com.google.gwt.place.shared.PlaceController;
+import com.google.web.bindery.event.shared.EventBus;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public interface AppFactory {
+
+ EventBus getEventBus();
+ PlaceController getPlaceController();
+ HelloView getHelloView();
+ GoodbyeView getGoodbyeView();
+}
View
36 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/AppFactoryImpl.java
@@ -0,0 +1,36 @@
+package com.clouway.gwt.activitiesandplaces.app.client;
+
+import com.clouway.gwt.activitiesandplaces.app.client.ui.GoodbyeView;
+import com.clouway.gwt.activitiesandplaces.app.client.ui.GoodbyeViewImpl;
+import com.clouway.gwt.activitiesandplaces.app.client.ui.HelloView;
+import com.clouway.gwt.activitiesandplaces.app.client.ui.HelloViewImpl;
+import com.google.gwt.place.shared.PlaceController;
+import com.google.web.bindery.event.shared.EventBus;
+import com.google.web.bindery.event.shared.SimpleEventBus;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public class AppFactoryImpl implements AppFactory {
+
+ private static final EventBus eventBus = new SimpleEventBus();
+ private static final PlaceController placeController = new PlaceController(eventBus);
+ private static final HelloView helloView = new HelloViewImpl();
+ private static final GoodbyeView goodbyeView = new GoodbyeViewImpl();
+
+ public EventBus getEventBus() {
+ return eventBus;
+ }
+
+ public PlaceController getPlaceController() {
+ return placeController;
+ }
+
+ public HelloView getHelloView() {
+ return helloView;
+ }
+
+ public GoodbyeView getGoodbyeView() {
+ return goodbyeView;
+ }
+}
View
24 ...ndplaces/src/com/clouway/gwt/activitiesandplaces/app/client/activity/GoodbyeActivity.java
@@ -0,0 +1,24 @@
+package com.clouway.gwt.activitiesandplaces.app.client.activity;
+
+import com.clouway.gwt.activitiesandplaces.app.client.AppFactory;
+import com.google.gwt.activity.shared.AbstractActivity;
+import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.user.client.ui.AcceptsOneWidget;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public class GoodbyeActivity extends AbstractActivity {
+
+ private AppFactory appFactory;
+ private String name;
+
+
+ public void start(AcceptsOneWidget panel, EventBus eventBus) {
+
+ }
+
+ public String mayStop() {
+ return null;
+ }
+}
View
39 ...sandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/activity/HelloActivity.java
@@ -0,0 +1,39 @@
+package com.clouway.gwt.activitiesandplaces.app.client.activity;
+
+import com.clouway.gwt.activitiesandplaces.app.client.AppFactory;
+import com.clouway.gwt.activitiesandplaces.app.client.places.HelloPlace;
+import com.clouway.gwt.activitiesandplaces.app.client.ui.HelloView;
+import com.google.gwt.activity.shared.AbstractActivity;
+import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.place.shared.Place;
+import com.google.gwt.user.client.ui.AcceptsOneWidget;
+import com.google.gwt.user.client.ui.IsWidget;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public class HelloActivity extends AbstractActivity implements HelloView.Presenter {
+
+ private AppFactory appFactory;
+ private String name;
+
+ public HelloActivity(HelloPlace helloPlace, AppFactory appFactory) {
+ //TODO: this.name = helloPlace.getName();
+ this.appFactory = appFactory;
+ }
+
+ public void start(AcceptsOneWidget panel, EventBus eventBus) {
+ HelloView helloView = appFactory.getHelloView();
+ helloView.setName(name);
+ helloView.setPresenter(this);
+ panel.setWidget((IsWidget) helloView);
+ }
+
+ public void goTo(Place place) {
+ appFactory.getPlaceController().goTo(place);
+ }
+
+ public String mayStop() {
+ return null;
+ }
+}
View
10 ...aces/src/com/clouway/gwt/activitiesandplaces/app/client/mapper/AppPlaceHistoryMapper.java
@@ -0,0 +1,10 @@
+package com.clouway.gwt.activitiesandplaces.app.client.mapper;
+
+import com.google.gwt.place.shared.PlaceHistoryMapper;
+
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public interface AppPlaceHistoryMapper extends PlaceHistoryMapper {
+}
View
32 ...tiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/places/GoodbyePlace.java
@@ -0,0 +1,32 @@
+package com.clouway.gwt.activitiesandplaces.app.client.places;
+
+import com.google.gwt.place.shared.Place;
+import com.google.gwt.place.shared.PlaceTokenizer;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public class GoodbyePlace extends Place {
+
+ private String token;
+
+ public GoodbyePlace(String token) {
+ this.token = token;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public static class Tokenizer implements PlaceTokenizer<GoodbyePlace> {
+
+ public GoodbyePlace getPlace(String token) {
+ return new GoodbyePlace(token);
+ }
+
+ @Override
+ public String getToken(GoodbyePlace place) {
+ return place.getToken();
+ }
+ }
+}
View
31 ...vitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/places/HelloPlace.java
@@ -0,0 +1,31 @@
+package com.clouway.gwt.activitiesandplaces.app.client.places;
+
+import com.google.gwt.place.shared.Place;
+import com.google.gwt.place.shared.PlaceTokenizer;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public class HelloPlace extends Place {
+
+ private String token;
+
+ public HelloPlace(String token) {
+ this.token = token;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public static class Tokenizer implements PlaceTokenizer<HelloPlace> {
+
+ public String getToken(HelloPlace place) {
+ return place.getToken();
+ }
+
+ public HelloPlace getPlace(String token) {
+ return new HelloPlace(token);
+ }
+ }
+}
View
9 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/GoodbyeView.java
@@ -0,0 +1,9 @@
+package com.clouway.gwt.activitiesandplaces.app.client.ui;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public interface GoodbyeView {
+
+ void setName(String name);
+}
View
28 ...itiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/GoodbyeViewImpl.java
@@ -0,0 +1,28 @@
+package com.clouway.gwt.activitiesandplaces.app.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public class GoodbyeViewImpl extends Composite implements GoodbyeView {
+
+ interface GoodbyeViewImplUiBinder extends UiBinder<Widget, GoodbyeViewImpl> {}
+ private static GoodbyeViewImplUiBinder uiBinder = GWT.create(GoodbyeViewImplUiBinder.class);
+
+ @UiField
+ Label name;
+
+ public GoodbyeViewImpl() {
+ initWidget(uiBinder.createAndBindUi(this));
+ }
+
+ public void setName(String name) {
+ this.name.setText("Goodbye, " + name);
+ }
+}
View
6 ...iesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/GoodbyeViewImpl.ui.xml
@@ -0,0 +1,6 @@
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui'>
+ <g:HTMLPanel>
+ <g:Label ui:field="name" />.
+ </g:HTMLPanel>
+</ui:UiBinder>
View
16 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/HelloView.java
@@ -0,0 +1,16 @@
+package com.clouway.gwt.activitiesandplaces.app.client.ui;
+
+import com.google.gwt.place.shared.Place;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public interface HelloView {
+
+ void setName(String name);
+ void setPresenter(Presenter presenter);
+
+ public interface Presenter {
+ void goTo(Place place);
+ }
+}
View
49 activitiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/HelloViewImpl.java
@@ -0,0 +1,49 @@
+package com.clouway.gwt.activitiesandplaces.app.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.ui.Anchor;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * @author Ivan Lazov <darkpain1989@gmail.com>
+ */
+public class HelloViewImpl extends Composite implements HelloView {
+
+ interface HelloViewImplUiBinder extends UiBinder<Widget, HelloViewImpl> {}
+ private static HelloViewImplUiBinder uiBinder = GWT.create(HelloViewImplUiBinder.class);
+
+ @UiField
+ Label label;
+
+ @UiField
+ Anchor link;
+
+ private Presenter presenter;
+
+ private String name;
+
+ public HelloViewImpl() {
+ initWidget(uiBinder.createAndBindUi(this));
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ label.setText(name);
+ }
+
+ public void setPresenter(Presenter presenter) {
+ this.presenter = presenter;
+ }
+
+ @UiHandler("link")
+ public void onLinkClick(ClickEvent event) {
+ //TODO: presenter.goTo(new GoodbyePlace(name));
+
+ }
+}
View
16 ...itiesandplaces/src/com/clouway/gwt/activitiesandplaces/app/client/ui/HelloViewImpl.ui.xml
@@ -0,0 +1,16 @@
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui'>
+
+ <ui:style>
+ .important {
+ font-weight: bold;
+ }
+ </ui:style>
+
+ <g:HTMLPanel>
+ Hello,
+ <g:Label addStyleNames="{style.important}" ui:field="label"/>
+ <g:Anchor ui:field="link" text="Say goodbye"/>
+ </g:HTMLPanel>
+
+</ui:UiBinder>
View
9 activitiesandplaces/war/App.css
@@ -0,0 +1,9 @@
+h1 {
+ font-size: 2em;
+ font-weight: bold;
+ text-align: center;
+}
+
+body, td, a, div, .p {
+ font-family: arial, sans-serif
+}
View
10 activitiesandplaces/war/App.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+ <title>Activities and Places</title>
+ <link type="text/css" rel="stylesheet" href="App.css">
+ <script type="text/javascript" language="javascript" src="App/App.nocache.js"></script>
+</head>
+<body>
+
+</body>
+</html>
View
8 activitiesandplaces/war/WEB-INF/web.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+</web-app>

0 comments on commit 2cbe189

Please sign in to comment.
Something went wrong with that request. Please try again.