├── .gitignore ├── README.md ├── gwt-polymer-starter-kit-with-di ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gwidgets │ │ ├── activities │ │ └── MainPageActivity.java │ │ ├── client │ │ ├── AppComponent.java │ │ ├── MVPModule.java │ │ ├── MyActivityMapper.java │ │ ├── MyHistoryMapper.java │ │ └── PolymerStarter.java │ │ ├── places │ │ ├── ContactPlace.java │ │ ├── HomePlace.java │ │ └── UsersPlace.java │ │ ├── polymerstarter.gwt.xml │ │ └── ui │ │ ├── MainPage.java │ │ └── MainPage.ui.xml │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── polymer-imports.html │ ├── polymerstarter.html │ └── styles │ ├── app-theme.html │ ├── main.css │ └── shared-styles.html ├── gwt-polymer-starter-kit ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── gwidgets │ │ ├── activities │ │ └── MainPageActivity.java │ │ ├── client │ │ ├── ClientFactory.java │ │ ├── ClientFactoryImpl.java │ │ ├── MyActivityMapper.java │ │ ├── MyHistoryMapper.java │ │ └── PolymerStarter.java │ │ ├── places │ │ ├── ContactPlace.java │ │ ├── HomePlace.java │ │ └── UsersPlace.java │ │ ├── polymerstarter.gwt.xml │ │ └── ui │ │ ├── MainPage.java │ │ └── MainPage.ui.xml │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── polymer-imports.html │ ├── polymerstarter.html │ └── styles │ ├── app-theme.html │ ├── main.css │ └── shared-styles.html └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | src/test 3 | .settings 4 | .classpath 5 | .project -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | gwt-polymer-starter kit is an adaptation of the [Polymer Starter Kit](https://github.com/PolymerElements/polymer-starter-kit) developed by the Polymer team to GWT. It is a starting point for developing Web applications using Polymer. This adaptation uses GWT, Vaadin's [gwt-polymer-elements](https://github.com/vaadin/gwt-polymer-elements), and [Maven GWT Plugin](https://github.com/gwt-maven-plugin/gwt-maven-plugin) as a build tool. 4 | 5 | ## Building and Running 6 | 7 | * Dev Mode: 8 | 9 | 10 | Before the first run and after each clean 11 | ```sh 12 | mvn package gwt:run 13 | ``` 14 | after the first run, there is no need for mvn package 15 | ```sh 16 | mvn gwt:run 17 | ``` 18 | 19 | * Production: 20 | 21 | ```sh 22 | mvn clean gwt:compile package 23 | ``` 24 | 25 | ## Browser Histroy management 26 | 27 | The application uses GWT Activities and Places to handle routing and section change. 28 | 29 | ## Dependency Injection 30 | 31 | There are two versions so far. The version that uses DI is under the directory gwt-polymer-starter-kit-with-di. Google Dagger 2 is used for dependency injection, as GIN is outdated and not maintained anymore. Annotations are automatically processed after running mvn compile. 32 | 33 | ## GWT version 34 | 35 | The project uses version 2.8.1 -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | gwt-polymer-starter-kit-with-di 7 | war 8 | 9 | com.gwidgets 10 | gwt-polymer 11 | 0.1 12 | 13 | 14 | GWT Polymer Starter Kit - With Dependency Injection using Dagger 15 | 16 | 17 | 18 | javax.inject 19 | javax.inject 20 | 1 21 | provided 22 | 23 | 24 | com.google.dagger 25 | dagger-gwt 26 | 2.5 27 | provided 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.apache.maven.plugins 35 | maven-compiler-plugin 36 | 3.5.1 37 | 38 | 1.8 39 | 1.8 40 | 41 | 42 | com.google.dagger 43 | dagger-compiler 44 | 2.5 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/activities/MainPageActivity.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.activities; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Singleton; 5 | 6 | import com.google.gwt.activity.shared.AbstractActivity; 7 | import com.google.gwt.core.shared.GWT; 8 | import com.google.gwt.event.shared.EventBus; 9 | import com.google.gwt.place.shared.Place; 10 | import com.google.gwt.user.client.ui.AcceptsOneWidget; 11 | import com.gwidgets.places.ContactPlace; 12 | import com.gwidgets.places.HomePlace; 13 | import com.gwidgets.places.UsersPlace; 14 | import com.gwidgets.ui.MainPage; 15 | 16 | @Singleton 17 | public class MainPageActivity extends AbstractActivity implements MainPage.Presenter { 18 | 19 | MainPage mainPage; 20 | 21 | 22 | @Inject 23 | public MainPageActivity(MainPage mainPage) { 24 | GWT.log("creating main activity"); 25 | this.mainPage = mainPage; 26 | 27 | } 28 | 29 | @Override 30 | public void start(AcceptsOneWidget panel, EventBus bus) { 31 | GWT.log("starting main activity"); 32 | panel.setWidget(mainPage); 33 | 34 | } 35 | 36 | public void refreshPlace(Place place){ 37 | GWT.log("refreshing place"); 38 | if(place instanceof HomePlace){ 39 | placeChangeWithoutClickEvent("home"); 40 | }else if(place instanceof ContactPlace){ 41 | placeChangeWithoutClickEvent("contact"); 42 | }else if(place instanceof UsersPlace){ 43 | placeChangeWithoutClickEvent("users"); 44 | } 45 | } 46 | 47 | @Override 48 | public void placeChangeWithoutClickEvent(String placeName) { 49 | // TODO Auto-generated method stub 50 | mainPage.getIronPagesElement().select(placeName); 51 | mainPage.getPaperMenu().select(placeName); 52 | 53 | } 54 | 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/client/AppComponent.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | import javax.inject.Singleton; 4 | 5 | import com.google.gwt.place.shared.PlaceController; 6 | import com.google.gwt.place.shared.PlaceHistoryHandler; 7 | import com.google.web.bindery.event.shared.EventBus; 8 | 9 | 10 | 11 | import com.gwidgets.ui.MainPage; 12 | 13 | import dagger.Component; 14 | 15 | 16 | @Singleton 17 | @Component(modules=MVPModule.class) 18 | public interface AppComponent { 19 | 20 | EventBus eventBus(); 21 | 22 | MainPage getMainPage(); 23 | 24 | PlaceController getPlaceController(); 25 | 26 | PlaceHistoryHandler getHistoryHandler(); 27 | 28 | MyActivityMapper mainActivityMapper(); 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/client/MVPModule.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | import javax.inject.Singleton; 4 | 5 | import com.google.gwt.activity.shared.ActivityManager; 6 | import com.google.gwt.core.shared.GWT; 7 | import com.google.gwt.place.shared.PlaceController; 8 | import com.google.gwt.place.shared.PlaceHistoryHandler; 9 | import com.google.gwt.user.client.ui.SimplePanel; 10 | import com.google.web.bindery.event.shared.EventBus; 11 | import com.google.web.bindery.event.shared.SimpleEventBus; 12 | import com.gwidgets.activities.MainPageActivity; 13 | import com.gwidgets.places.HomePlace; 14 | import com.gwidgets.ui.MainPage; 15 | 16 | import dagger.Module; 17 | import dagger.Provides; 18 | 19 | @Module 20 | public class MVPModule { 21 | 22 | @Provides @Singleton 23 | public 24 | MainPage getMainPage(){ 25 | return new MainPage(); 26 | } 27 | 28 | @Provides @Singleton 29 | public EventBus getEventBus() { 30 | return new SimpleEventBus(); 31 | } 32 | 33 | @Provides @Singleton 34 | public MyHistoryMapper getHistoryMapper() { 35 | return GWT.create(MyHistoryMapper.class); 36 | } 37 | 38 | 39 | @Provides @Singleton 40 | public PlaceController getPlaceController(EventBus eventBus) { 41 | return new PlaceController(eventBus); 42 | } 43 | 44 | @Provides @Singleton 45 | public PlaceHistoryHandler getHistoryHandler(PlaceController placeController, 46 | MyHistoryMapper historyMapper, 47 | EventBus eventBus) { 48 | PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); 49 | historyHandler.register(placeController, eventBus, new HomePlace("home")); 50 | return historyHandler; 51 | } 52 | 53 | @Provides @Singleton 54 | public ActivityManager getActivityManager(MyActivityMapper mapper, 55 | EventBus eventBus, SimplePanel appwidget) { 56 | ActivityManager activityManager = new ActivityManager(mapper, eventBus); 57 | activityManager.setDisplay(appwidget); 58 | return activityManager; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/client/MyActivityMapper.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | import javax.inject.Inject; 4 | import javax.inject.Provider; 5 | import javax.inject.Singleton; 6 | 7 | import com.google.gwt.activity.shared.Activity; 8 | import com.google.gwt.activity.shared.ActivityMapper; 9 | import com.google.gwt.core.shared.GWT; 10 | import com.google.gwt.place.shared.Place; 11 | import com.gwidgets.activities.*; 12 | 13 | 14 | 15 | 16 | @Singleton 17 | public class MyActivityMapper implements ActivityMapper { 18 | 19 | @Inject Provider activityProvider; 20 | 21 | @Inject 22 | public MyActivityMapper(){ 23 | GWT.log("creating activity mapper"); 24 | } 25 | 26 | @Override 27 | public Activity getActivity(Place place) { 28 | GWT.log("changing activity"); 29 | //No need to check if activity is null, it is injected by dagger 30 | MainPageActivity activity = activityProvider.get(); 31 | activity.refreshPlace(place); 32 | return activity; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/client/MyHistoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | 4 | 5 | import com.google.gwt.place.shared.PlaceHistoryMapper; 6 | import com.google.gwt.place.shared.WithTokenizers; 7 | import com.gwidgets.places.*; 8 | 9 | 10 | @WithTokenizers({ContactPlace.Tokenizer.class, HomePlace.Tokenizer.class, UsersPlace.Tokenizer.class}) 11 | public interface MyHistoryMapper extends PlaceHistoryMapper { 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/client/PolymerStarter.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | import java.util.Arrays; 4 | 5 | import com.google.gwt.activity.shared.ActivityManager; 6 | import com.google.gwt.activity.shared.ActivityMapper; 7 | import com.google.gwt.core.client.EntryPoint; 8 | import com.google.gwt.core.shared.GWT; 9 | import com.google.gwt.place.shared.PlaceController; 10 | import com.google.gwt.place.shared.PlaceHistoryHandler; 11 | import com.google.gwt.user.client.ui.RootPanel; 12 | import com.google.gwt.user.client.ui.SimplePanel; 13 | import com.google.web.bindery.event.shared.EventBus; 14 | import com.gwidgets.places.HomePlace; 15 | import com.gwidgets.ui.MainPage; 16 | import com.vaadin.polymer.Polymer; 17 | import com.vaadin.polymer.elemental.Function; 18 | 19 | 20 | public class PolymerStarter implements EntryPoint { 21 | private HomePlace homePlace = new HomePlace("home"); 22 | private SimplePanel appWidget = new SimplePanel(); 23 | 24 | public void onModuleLoad() { 25 | 26 | //don't worry of the IDE complains about DaggerAppComponent, it is generated by the dagger comppiler 27 | AppComponent component = DaggerAppComponent.builder() 28 | .mVPModule(new MVPModule()) 29 | .build(); 30 | 31 | MyActivityMapper mainMapper = component.mainActivityMapper(); 32 | ActivityManager mainManager = new ActivityManager(mainMapper, component.eventBus()); 33 | mainManager.setDisplay(appWidget); 34 | 35 | RootPanel.get().add(appWidget); 36 | component.getMainPage().initializeEvents(component.getPlaceController()); 37 | 38 | component.getHistoryHandler().handleCurrentHistory(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/places/ContactPlace.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.places; 2 | 3 | import com.google.gwt.place.shared.Place; 4 | import com.google.gwt.place.shared.PlaceTokenizer; 5 | import com.google.gwt.place.shared.Prefix; 6 | 7 | 8 | public class ContactPlace extends Place { 9 | 10 | private String name; 11 | 12 | public ContactPlace(String name) { 13 | this.name = name; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | @Prefix("!") 21 | public static class Tokenizer implements PlaceTokenizer { 22 | @Override 23 | public String getToken(ContactPlace place) { 24 | return place.getName(); 25 | } 26 | 27 | @Override 28 | public ContactPlace getPlace(String token) { 29 | return new ContactPlace(token); 30 | } 31 | } 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/places/HomePlace.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.places; 2 | 3 | import com.google.gwt.place.shared.Place; 4 | import com.google.gwt.place.shared.PlaceTokenizer; 5 | import com.google.gwt.place.shared.Prefix; 6 | 7 | public class HomePlace extends Place{ 8 | 9 | private String name; 10 | 11 | public HomePlace(String name) { 12 | this.name = name; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | @Prefix("") 20 | public static class Tokenizer implements PlaceTokenizer { 21 | @Override 22 | public String getToken(HomePlace place) { 23 | return place.getName(); 24 | } 25 | 26 | @Override 27 | public HomePlace getPlace(String token) { 28 | return new HomePlace(token); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/places/UsersPlace.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.places; 2 | 3 | import com.google.gwt.place.shared.Place; 4 | import com.google.gwt.place.shared.PlaceTokenizer; 5 | import com.google.gwt.place.shared.Prefix; 6 | 7 | public class UsersPlace extends Place{ 8 | 9 | 10 | private String name; 11 | 12 | public UsersPlace(String name) { 13 | this.name = name; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | @Prefix("§") 21 | public static class Tokenizer implements PlaceTokenizer { 22 | @Override 23 | public String getToken(UsersPlace place) { 24 | return place.getName(); 25 | } 26 | 27 | @Override 28 | public UsersPlace getPlace(String token) { 29 | return new UsersPlace(token); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/polymerstarter.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/ui/MainPage.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.ui; 2 | 3 | import com.google.gwt.core.client.GWT; 4 | import com.google.gwt.dom.client.AnchorElement; 5 | import com.google.gwt.dom.client.Element; 6 | import com.google.gwt.place.shared.PlaceController; 7 | import com.google.gwt.uibinder.client.UiBinder; 8 | import com.google.gwt.uibinder.client.UiField; 9 | import com.google.gwt.user.client.Event; 10 | import com.google.gwt.user.client.Window; 11 | import com.google.gwt.user.client.ui.Composite; 12 | import com.google.gwt.user.client.ui.IsWidget; 13 | import com.google.gwt.user.client.ui.UIObject; 14 | import com.google.gwt.user.client.ui.Widget; 15 | import com.gwidgets.places.ContactPlace; 16 | import com.gwidgets.places.HomePlace; 17 | import com.gwidgets.places.UsersPlace; 18 | import com.vaadin.polymer.Polymer; 19 | import com.vaadin.polymer.iron.IronPagesElement; 20 | import com.vaadin.polymer.paper.PaperDrawerPanelElement; 21 | import com.vaadin.polymer.paper.PaperMenuElement; 22 | 23 | public class MainPage extends Composite { 24 | 25 | @UiField 26 | PaperMenuElement paperMenu; 27 | @UiField 28 | AnchorElement homeLink; 29 | @UiField 30 | AnchorElement usersLink; 31 | @UiField 32 | AnchorElement contactLink; 33 | @UiField 34 | IronPagesElement ironPages; 35 | 36 | 37 | private static MainPageUiBinder uiBinder = GWT 38 | .create(MainPageUiBinder.class); 39 | 40 | interface MainPageUiBinder extends UiBinder { 41 | } 42 | 43 | public MainPage() { 44 | setElement(uiBinder.createAndBindUi(this)); 45 | GWT.log("creating main page"); 46 | } 47 | 48 | 49 | public void initializeEvents(PlaceController controller){ 50 | Event.sinkEvents(usersLink, Event.ONCLICK); 51 | Event.sinkEvents(homeLink, Event.ONCLICK); 52 | Event.sinkEvents(contactLink, Event.ONCLICK); 53 | 54 | Event.setEventListener(contactLink, e -> { 55 | if(Event.ONCLICK == e.getTypeInt()) { 56 | ironPages.select("contact"); 57 | paperMenu.select("contact"); 58 | controller.goTo(new ContactPlace("contact")); 59 | slideDrawerIfMobile(); 60 | 61 | } 62 | }); 63 | 64 | Event.setEventListener(homeLink, e -> { 65 | if(Event.ONCLICK == e.getTypeInt()) { 66 | ironPages.select("home"); 67 | paperMenu.select("home"); 68 | controller.goTo(new HomePlace("home")); 69 | slideDrawerIfMobile(); 70 | } 71 | }); 72 | 73 | Event.setEventListener(usersLink, e -> { 74 | if(Event.ONCLICK == e.getTypeInt()) { 75 | ironPages.select("users"); 76 | paperMenu.select("users"); 77 | controller.goTo(new UsersPlace("users")); 78 | slideDrawerIfMobile(); 79 | 80 | } 81 | }); 82 | 83 | 84 | } 85 | 86 | 87 | public AnchorElement getContactLink(){ 88 | return contactLink; 89 | 90 | } 91 | 92 | public AnchorElement getHomeLink(){ 93 | return homeLink; 94 | 95 | } 96 | 97 | public AnchorElement getUsersLink(){ 98 | return usersLink; 99 | 100 | } 101 | 102 | public PaperMenuElement getPaperMenu(){ 103 | return paperMenu; 104 | } 105 | 106 | public IronPagesElement getIronPagesElement(){ 107 | return ironPages; 108 | 109 | } 110 | 111 | public interface Presenter { 112 | //handles clicking on back and forward buttons of the browser 113 | public void placeChangeWithoutClickEvent(String placeName); 114 | } 115 | 116 | private void slideDrawerIfMobile(){ 117 | if( Window.getClientWidth() < 600 ){ 118 | PaperDrawerPanelElement drawer = (PaperDrawerPanelElement) Polymer.getDocument().getElementById("paperDrawerPanel"); 119 | drawer.closeDrawer(); 120 | } 121 | 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/java/com/gwidgets/ui/MainPage.ui.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Menu 17 | 18 | 19 | 20 | 21 | 22 | 23 | Home 24 | 25 | 26 | 27 | 28 | Users 29 | 30 | 31 | 32 | 33 | Contact 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
55 |
GWT Polymer Starter Kit
56 |
57 | 58 | 59 |
60 |
description
61 |
62 |
63 | 64 | 65 |
66 | 67 |
68 | 69 |

Home

70 |

For copyright and license, checkout the project's Github page: 71 | 72 | https://github.com/gwidgets/gwt-polymer-starter-kit

73 |
74 | 75 |
76 | 77 |
78 | 79 |

Users

80 |

This is the users section

81 |
82 |
83 | 84 |
85 | 86 |

Contact

87 |

This is the contact section

88 |
89 |
90 |
91 |
92 |
93 |
94 | 95 | 96 |
97 | 98 |
-------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 18 | 19 | 20 | 21 | polymerstarter.html 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/webapp/polymer-imports.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/webapp/polymerstarter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | GWT Polymer Starter Kit 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/webapp/styles/app-theme.html: -------------------------------------------------------------------------------- 1 | 236 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/webapp/styles/main.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 3 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 4 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 5 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 6 | Code distributed by Google as part of the polymer project is also 7 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 8 | */ 9 | 10 | body { 11 | background: #fafafa; 12 | font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif; 13 | color: #333; 14 | } 15 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit-with-di/src/main/webapp/styles/shared-styles.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | gwt-polymer-starter-kit 7 | war 8 | 9 | GWT Polymer starter Kit 10 | 11 | 12 | com.gwidgets 13 | gwt-polymer 14 | 0.1 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/activities/MainPageActivity.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.activities; 2 | 3 | import com.google.gwt.activity.shared.AbstractActivity; 4 | import com.google.gwt.core.shared.GWT; 5 | import com.google.gwt.event.shared.EventBus; 6 | import com.google.gwt.place.shared.Place; 7 | import com.google.gwt.place.shared.PlaceController; 8 | import com.google.gwt.user.client.ui.AcceptsOneWidget; 9 | import com.gwidgets.client.ClientFactory; 10 | import com.gwidgets.places.ContactPlace; 11 | import com.gwidgets.places.HomePlace; 12 | import com.gwidgets.places.UsersPlace; 13 | import com.gwidgets.ui.MainPage; 14 | 15 | public class MainPageActivity extends AbstractActivity implements MainPage.Presenter { 16 | 17 | MainPage mainPage; 18 | PlaceController controller; 19 | Place currentPlace; 20 | 21 | public MainPageActivity(ClientFactory factory, Place place) { 22 | this.mainPage = factory.getMainPageView(); 23 | this.controller = factory.getPlaceController(); 24 | this.currentPlace = place; 25 | } 26 | 27 | @Override 28 | public void start(AcceptsOneWidget panel, EventBus bus) { 29 | panel.setWidget(mainPage); 30 | } 31 | 32 | public void refreshPlace(Place place){ 33 | this.currentPlace = place; 34 | 35 | 36 | if(place instanceof HomePlace){ 37 | placeChangeWithoutClickEvent("home"); 38 | }else if(place instanceof ContactPlace){ 39 | placeChangeWithoutClickEvent("contact"); 40 | }else if(place instanceof UsersPlace){ 41 | placeChangeWithoutClickEvent("users"); 42 | } 43 | 44 | } 45 | 46 | @Override 47 | public void placeChangeWithoutClickEvent(String placeName) { 48 | // TODO Auto-generated method stub 49 | mainPage.getIronPagesElement().select(placeName); 50 | mainPage.getPaperMenu().select(placeName); 51 | 52 | } 53 | 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/client/ClientFactory.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | import com.google.gwt.place.shared.PlaceController; 4 | import com.google.web.bindery.event.shared.EventBus; 5 | import com.gwidgets.ui.MainPage; 6 | 7 | 8 | public interface ClientFactory { 9 | MainPage getMainPageView(); 10 | EventBus getEventBus(); 11 | PlaceController getPlaceController(); 12 | } 13 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/client/ClientFactoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | import com.google.gwt.place.shared.PlaceController; 4 | import com.google.web.bindery.event.shared.EventBus; 5 | import com.google.web.bindery.event.shared.SimpleEventBus; 6 | import com.gwidgets.ui.MainPage; 7 | 8 | public class ClientFactoryImpl implements ClientFactory { 9 | 10 | 11 | EventBus eventBus = new SimpleEventBus(); 12 | PlaceController controller = new PlaceController(eventBus); 13 | MainPage mainPage = new MainPage(); 14 | 15 | 16 | @Override 17 | public MainPage getMainPageView() { 18 | return mainPage; 19 | } 20 | 21 | @Override 22 | public EventBus getEventBus() { 23 | return eventBus; 24 | } 25 | 26 | @Override 27 | public PlaceController getPlaceController() { 28 | return controller; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/client/MyActivityMapper.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | import com.google.gwt.activity.shared.Activity; 4 | import com.google.gwt.activity.shared.ActivityMapper; 5 | import com.google.gwt.place.shared.Place; 6 | import com.gwidgets.activities.*; 7 | 8 | 9 | 10 | public class MyActivityMapper implements ActivityMapper { 11 | 12 | ClientFactory factory; 13 | 14 | MainPageActivity activity; 15 | 16 | 17 | 18 | public MyActivityMapper(ClientFactory factory ){ 19 | this.factory = factory; 20 | 21 | } 22 | 23 | @Override 24 | public Activity getActivity(Place place) { 25 | 26 | 27 | if(activity == null){ 28 | 29 | activity = new MainPageActivity(factory, place); 30 | }else{ 31 | 32 | activity.refreshPlace(place); 33 | } 34 | 35 | return activity; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/client/MyHistoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | 4 | 5 | import com.google.gwt.place.shared.PlaceHistoryMapper; 6 | import com.google.gwt.place.shared.WithTokenizers; 7 | import com.gwidgets.places.*; 8 | 9 | 10 | @WithTokenizers({ContactPlace.Tokenizer.class, HomePlace.Tokenizer.class, UsersPlace.Tokenizer.class}) 11 | public interface MyHistoryMapper extends PlaceHistoryMapper { 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/client/PolymerStarter.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.client; 2 | 3 | import com.google.gwt.activity.shared.ActivityManager; 4 | import com.google.gwt.activity.shared.ActivityMapper; 5 | import com.google.gwt.core.client.EntryPoint; 6 | import com.google.gwt.core.shared.GWT; 7 | import com.google.gwt.place.shared.PlaceController; 8 | import com.google.gwt.place.shared.PlaceHistoryHandler; 9 | import com.google.gwt.user.client.ui.RootPanel; 10 | import com.google.gwt.user.client.ui.SimplePanel; 11 | import com.google.web.bindery.event.shared.EventBus; 12 | import com.gwidgets.places.HomePlace; 13 | import com.vaadin.polymer.Polymer; 14 | import com.vaadin.polymer.elemental.HTMLElement; 15 | 16 | 17 | public class PolymerStarter implements EntryPoint { 18 | private HomePlace homePlace = new HomePlace("home"); 19 | private SimplePanel appWidget = new SimplePanel(); 20 | 21 | public void onModuleLoad() { 22 | 23 | ClientFactory clientFactory = GWT.create(ClientFactory.class); 24 | PlaceController controller = clientFactory.getPlaceController(); 25 | 26 | EventBus bus = clientFactory.getEventBus(); 27 | ActivityMapper activityMapper = new MyActivityMapper(clientFactory); 28 | ActivityManager activityManager = new ActivityManager(activityMapper, bus); 29 | activityManager.setDisplay(appWidget); 30 | 31 | MyHistoryMapper historyMapper= GWT.create(MyHistoryMapper.class); 32 | final PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); 33 | historyHandler.register(controller, bus, homePlace); 34 | 35 | clientFactory.getMainPageView().initializeEvents(controller); 36 | 37 | RootPanel.get().add(appWidget); 38 | 39 | historyHandler.handleCurrentHistory(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/places/ContactPlace.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.places; 2 | 3 | import com.google.gwt.place.shared.Place; 4 | import com.google.gwt.place.shared.PlaceTokenizer; 5 | import com.google.gwt.place.shared.Prefix; 6 | 7 | 8 | public class ContactPlace extends Place { 9 | 10 | private String name; 11 | 12 | public ContactPlace(String name) { 13 | this.name = name; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | @Prefix("!") 21 | public static class Tokenizer implements PlaceTokenizer { 22 | @Override 23 | public String getToken(ContactPlace place) { 24 | return place.getName(); 25 | } 26 | 27 | @Override 28 | public ContactPlace getPlace(String token) { 29 | return new ContactPlace(token); 30 | } 31 | } 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/places/HomePlace.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.places; 2 | 3 | import com.google.gwt.place.shared.Place; 4 | import com.google.gwt.place.shared.PlaceTokenizer; 5 | import com.google.gwt.place.shared.Prefix; 6 | 7 | public class HomePlace extends Place{ 8 | 9 | private String name; 10 | 11 | public HomePlace(String name) { 12 | this.name = name; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | @Prefix("") 20 | public static class Tokenizer implements PlaceTokenizer { 21 | @Override 22 | public String getToken(HomePlace place) { 23 | return place.getName(); 24 | } 25 | 26 | @Override 27 | public HomePlace getPlace(String token) { 28 | return new HomePlace(token); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/places/UsersPlace.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.places; 2 | 3 | import com.google.gwt.place.shared.Place; 4 | import com.google.gwt.place.shared.PlaceTokenizer; 5 | import com.google.gwt.place.shared.Prefix; 6 | 7 | public class UsersPlace extends Place{ 8 | 9 | 10 | private String name; 11 | 12 | public UsersPlace(String name) { 13 | this.name = name; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | @Prefix("§") 21 | public static class Tokenizer implements PlaceTokenizer { 22 | @Override 23 | public String getToken(UsersPlace place) { 24 | return place.getName(); 25 | } 26 | 27 | @Override 28 | public UsersPlace getPlace(String token) { 29 | return new UsersPlace(token); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/polymerstarter.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/ui/MainPage.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.ui; 2 | 3 | import com.google.gwt.core.client.GWT; 4 | import com.google.gwt.dom.client.AnchorElement; 5 | import com.google.gwt.dom.client.Element; 6 | import com.google.gwt.place.shared.PlaceController; 7 | import com.google.gwt.uibinder.client.UiBinder; 8 | import com.google.gwt.uibinder.client.UiField; 9 | import com.google.gwt.user.client.Event; 10 | import com.google.gwt.user.client.Window; 11 | import com.google.gwt.user.client.ui.Composite; 12 | import com.google.gwt.user.client.ui.Widget; 13 | import com.gwidgets.places.ContactPlace; 14 | import com.gwidgets.places.HomePlace; 15 | import com.gwidgets.places.UsersPlace; 16 | import com.vaadin.polymer.Polymer; 17 | import com.vaadin.polymer.iron.IronPagesElement; 18 | import com.vaadin.polymer.paper.PaperDrawerPanelElement; 19 | import com.vaadin.polymer.paper.PaperMenuElement; 20 | 21 | public class MainPage extends Composite { 22 | 23 | @UiField 24 | PaperMenuElement paperMenu; 25 | @UiField 26 | AnchorElement homeLink; 27 | @UiField 28 | AnchorElement usersLink; 29 | @UiField 30 | AnchorElement contactLink; 31 | @UiField 32 | IronPagesElement ironPages; 33 | 34 | private static MainPageUiBinder uiBinder = GWT 35 | .create(MainPageUiBinder.class); 36 | 37 | interface MainPageUiBinder extends UiBinder { 38 | } 39 | 40 | public MainPage() { 41 | initWidget(uiBinder.createAndBindUi(this)); 42 | GWT.debugger(); 43 | Polymer.endLoading(this.getElement(), (Element) paperMenu); 44 | } 45 | 46 | 47 | public void initializeEvents(PlaceController controller){ 48 | Event.sinkEvents(usersLink, Event.ONCLICK); 49 | Event.sinkEvents(homeLink, Event.ONCLICK); 50 | Event.sinkEvents(contactLink, Event.ONCLICK); 51 | 52 | Event.setEventListener(contactLink, e -> { 53 | if(Event.ONCLICK == e.getTypeInt()) { 54 | ironPages.select("contact"); 55 | paperMenu.select("contact"); 56 | controller.goTo(new ContactPlace("contact")); 57 | slideDrawerIfMobile(); 58 | 59 | } 60 | }); 61 | 62 | Event.setEventListener(homeLink, e -> { 63 | if(Event.ONCLICK == e.getTypeInt()) { 64 | ironPages.select("home"); 65 | paperMenu.select("home"); 66 | controller.goTo(new HomePlace("home")); 67 | slideDrawerIfMobile(); 68 | } 69 | }); 70 | 71 | Event.setEventListener(usersLink, e -> { 72 | if(Event.ONCLICK == e.getTypeInt()) { 73 | ironPages.select("users"); 74 | paperMenu.select("users"); 75 | controller.goTo(new UsersPlace("users")); 76 | slideDrawerIfMobile(); 77 | 78 | } 79 | }); 80 | 81 | 82 | } 83 | 84 | 85 | public AnchorElement getContactLink(){ 86 | return contactLink; 87 | 88 | } 89 | 90 | public AnchorElement getHomeLink(){ 91 | return homeLink; 92 | 93 | } 94 | 95 | public AnchorElement getUsersLink(){ 96 | return usersLink; 97 | 98 | } 99 | 100 | public PaperMenuElement getPaperMenu(){ 101 | return paperMenu; 102 | } 103 | 104 | public IronPagesElement getIronPagesElement(){ 105 | return ironPages; 106 | 107 | } 108 | 109 | public interface Presenter { 110 | //handles clicking on back and forward buttons of the browser 111 | public void placeChangeWithoutClickEvent(String placeName); 112 | } 113 | 114 | private void slideDrawerIfMobile(){ 115 | if( Window.getClientWidth() < 600 ){ 116 | PaperDrawerPanelElement drawer = (PaperDrawerPanelElement) Polymer.getDocument().getElementById("paperDrawerPanel"); 117 | drawer.closeDrawer(); 118 | } 119 | 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/java/com/gwidgets/ui/MainPage.ui.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Menu 17 | 18 | 19 | 20 | 21 | 22 | 23 | Home 24 | 25 | 26 | 27 | 28 | Users 29 | 30 | 31 | 32 | 33 | Contact 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
55 |
GWT Polymer Starter Kit
56 |
57 | 58 | 59 |
60 |
description
61 |
62 |
63 | 64 | 65 |
66 | 67 |
68 | 69 |

Home

70 |

For copyright and license, checkout the project's Github page: 71 | 72 | https://github.com/gwidgets/gwt-polymer-starter-kit

73 |
74 | 75 |
76 | 77 |
78 | 79 |

Users

80 |

This is the users section

81 |
82 |
83 | 84 |
85 | 86 |

Contact

87 |

This is the contact section

88 |
89 |
90 |
91 |
92 |
93 |
94 | 95 | 96 |
97 | 98 |
-------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 18 | 19 | 20 | 21 | polymerstarter.html 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/webapp/polymer-imports.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/webapp/polymerstarter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | GWT Polymer Starter Kit 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/webapp/styles/app-theme.html: -------------------------------------------------------------------------------- 1 | 236 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/webapp/styles/main.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 3 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 4 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 5 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 6 | Code distributed by Google as part of the polymer project is also 7 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 8 | */ 9 | 10 | body { 11 | background: #fafafa; 12 | font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif; 13 | color: #333; 14 | } 15 | -------------------------------------------------------------------------------- /gwt-polymer-starter-kit/src/main/webapp/styles/shared-styles.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | com.gwidgets 4 | gwt-polymer 5 | 0.1 6 | pom 7 | GWT Polymer Starter Kit - A starting point for developing Web applications using GWT and Polymer 8 | https://github.com/gwidgets/gwt-polymer-starter-kit 9 | 10 | G-Widgets 11 | www.g-widgets.com 12 | 13 | 14 | 15 | gwt-polymer-starter-kit 16 | gwt-polymer-starter-kit-with-di 17 | 18 | 19 | 20 | 2.8.2 21 | 1.7.0.0 22 | ${project.build.directory} 23 | ${project.build.directory}/${project.build.finalName} 24 | 1.8 25 | 1.8 26 | UTF-8 27 | 28 | 29 | 30 | 31 | com.google.gwt 32 | gwt-user 33 | ${gwt.version} 34 | provided 35 | 36 | 37 | com.google.gwt 38 | gwt-dev 39 | ${gwt.version} 40 | provided 41 | 42 | 43 | com.vaadin.polymer 44 | vaadin-gwt-polymer-elements 45 | ${gwtPolymerVersion} 46 | provided 47 | 48 | 49 | 50 | ${project.build.directory}/${project.build.finalName}/WEB-INF/classes 51 | 52 | 53 | ${project.build.directory}/generated-sources/annotations 54 | true 55 | 56 | 57 | 58 | 59 | org.codehaus.mojo 60 | gwt-maven-plugin 61 | ${gwt.version} 62 | 63 | 64 | 65 | compile 66 | test 67 | 68 | 69 | 70 | 72 | 73 | polymerstarter.html 74 | 75 | com.gwidgets.polymerstarter 76 | 77 | 1 78 | ${webappDirectory} 79 | ${war} 80 | true 81 | 82 | 83 | 84 | org.apache.maven.plugins 85 | maven-war-plugin 86 | 2.3 87 | 88 | 89 | compile 90 | 91 | 92 | 93 | ${webappDirectory} 94 | 95 | 96 | 97 | org.apache.maven.plugins 98 | maven-compiler-plugin 99 | 3.5.1 100 | 101 | 1.8 102 | 1.8 103 | 104 | 105 | 106 | 107 | --------------------------------------------------------------------------------