From a1a9440f378e311342c53b577a888864e846396a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Du=CC=88ppe?= Date: Sat, 28 Jan 2017 01:09:38 +0100 Subject: [PATCH 1/7] Excluded tomcat for jetty. --- pom.xml | 536 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 275 insertions(+), 261 deletions(-) diff --git a/pom.xml b/pom.xml index 86d6cf2..1b29ff9 100644 --- a/pom.xml +++ b/pom.xml @@ -18,171 +18,178 @@ | under the License. --> - 4.0.0 + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - com.lofidewanto.demo - demo-gwt-springboot - 0.0.1-SNAPSHOT - jar + com.lofidewanto.demo + demo-gwt-springboot + 0.0.1-SNAPSHOT + jar - demo-gwt-springboot - Demo project for Spring Boot and GWT + demo-gwt-springboot + Demo project for Spring Boot and GWT - - org.springframework.boot - spring-boot-starter-parent - 1.4.3.RELEASE - - + + org.springframework.boot + spring-boot-starter-parent + 1.4.2.RELEASE + + - - UTF-8 - 1.8 - 2.8.0 - 2.1.2 - 0.9.3 - 1.1.0 - 2.2.0 - 1.1.6 - 2.0.0 - 2.0.2 - 1.0.0 - + + UTF-8 + 1.8 + 2.8.0 + 2.1.2 + 0.9.3 + 1.1.0 + 2.2.0 + 1.1.6 + 2.0.0 + 2.0.2 + + 1.0.0 + + - - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-actuator-docs - - - org.springframework.boot - spring-boot-starter-data-jpa - + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-actuator-docs + + + org.springframework.boot + spring-boot-starter-data-jpa + - - - + + + - - org.springframework.boot - spring-boot-starter-web - + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + - - - com.h2database - h2 - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.restdocs - spring-restdocs-mockmvc - test - + + org.springframework.boot + spring-boot-starter-jetty + - - javax.validation - validation-api - 1.1.0.Final - + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.restdocs + spring-restdocs-mockmvc + test + - - javax.ws.rs - jsr311-api - 1.1.1 - + + javax.validation + validation-api + 1.1.0.Final + - - - com.google.gwt - gwt-user - ${gwt.version} - - - validation-api - javax.validation - - - + + javax.ws.rs + jsr311-api + 1.1.1 + - - - com.google.gwt.inject - gin - ${google.gin.version} - + + + com.google.gwt + gwt-user + ${gwt.version} + + + validation-api + javax.validation + + + - - - com.google.gwt.eventbinder - eventbinder - ${gwt.eventbinder.version} - + + + com.google.gwt.inject + gin + ${google.gin.version} + - - - org.gwtbootstrap3 - gwtbootstrap3 - ${gwt.bootstrap.version} - - - com.google.gwt - gwt-user - - + + + com.google.gwt.eventbinder + eventbinder + ${gwt.eventbinder.version} + - - - org.gwtbootstrap3 - gwtbootstrap3-extras - ${gwt.bootstrap.version} - + + + org.gwtbootstrap3 + gwtbootstrap3 + ${gwt.bootstrap.version} + + + com.google.gwt + gwt-user + + - - - org.fusesource.restygwt - restygwt - ${gwt.resty.version} - + + + org.gwtbootstrap3 + gwtbootstrap3-extras + ${gwt.bootstrap.version} + - - - com.google.gwt.gwtmockito - gwtmockito - ${gwt.mockito.version} - test - + + + org.fusesource.restygwt + restygwt + ${gwt.resty.version} + - - com.google.gwt - gwt-dev - ${gwt.version} - test - - - - - org.postgresql - postgresql - - + + + com.google.gwt.gwtmockito + gwtmockito + ${gwt.mockito.version} + test + + + + com.google.gwt + gwt-dev + ${gwt.version} + test + + @@ -234,122 +241,129 @@ - - de.crowdcode.kissmda.maven - kissmda-maven-plugin - ${kissmda.maven.plugin.version} - - - - de.crowdcode.kissmda.cartridges - kissmda-cartridges-simple-java - ${kissmda.cartridges.simple.java.version} - - - de.crowdcode.kissmda.cartridges - kissmda-extensions-import-packer - ${kissmda.extensions.importpacker.version} - - - - - generate-sources - - generate - - - - - - - - de.crowdcode.kissmda.cartridges - - - - - - 2:de.crowdcode.kissmda.extensions.importpacker.ImportPackerTransformer - - - 3:de.crowdcode.kissmda.cartridges.simplejava.SimpleJavaTransformer - - - src/main/resources/model/emf/demo-gwt-springboot.uml - SEVERE - - - - + + de.crowdcode.kissmda.maven + kissmda-maven-plugin + ${kissmda.maven.plugin.version} + + + + de.crowdcode.kissmda.cartridges + kissmda-cartridges-simple-java + ${kissmda.cartridges.simple.java.version} + + + + de.crowdcode.kissmda.cartridges + kissmda-extensions-import-packer + + ${kissmda.extensions.importpacker.version} + + + + + + generate-sources + + generate + + + + + + + + + de.crowdcode.kissmda.cartridges + + + + + + + 2:de.crowdcode.kissmda.extensions.importpacker.ImportPackerTransformer + + + 3:de.crowdcode.kissmda.cartridges.simplejava.SimpleJavaTransformer + + + + src/main/resources/model/emf/demo-gwt-springboot.uml + + SEVERE + + + + - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - de.crowdcode.kissmda.maven - - - kissmda-maven-plugin - - - [2.0.0,) - - - generate - - - - - - - - - - - - - + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + de.crowdcode.kissmda.maven + + + kissmda-maven-plugin + + + [2.0.0,) + + + generate + + + + + + + + + + + + + - - - development - - - - - org.zeroturnaround - jrebel-maven-plugin - 1.1.5 - - . - - default - - - - - - - - - generate-rebel-xml - process-resources - - generate - - - - + + + development + + + + + org.zeroturnaround + jrebel-maven-plugin + 1.1.5 + + . + + default + + + + + + + + + generate-rebel-xml + process-resources + + generate + + + + From ab14f856519fd75b82937d7341e3eb65757d0669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Du=CC=88ppe?= Date: Fri, 10 Feb 2017 15:41:05 +0100 Subject: [PATCH 2/7] prettify code --- .../demo/client/DemoGwtWebApp.java | 305 +++++++++--------- 1 file changed, 152 insertions(+), 153 deletions(-) diff --git a/src/main/java/com/lofidewanto/demo/client/DemoGwtWebApp.java b/src/main/java/com/lofidewanto/demo/client/DemoGwtWebApp.java index 667bc3f..168f5eb 100644 --- a/src/main/java/com/lofidewanto/demo/client/DemoGwtWebApp.java +++ b/src/main/java/com/lofidewanto/demo/client/DemoGwtWebApp.java @@ -1,154 +1,153 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.lofidewanto.demo.client; - -import java.util.logging.Logger; - -import org.gwtbootstrap3.extras.bootbox.client.Bootbox; -import org.gwtbootstrap3.extras.bootbox.client.options.BootboxLocale; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.RunAsyncCallback; -import com.google.gwt.dom.client.Document; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.MetaElement; -import com.google.gwt.dom.client.NodeList; -import com.google.gwt.event.logical.shared.ValueChangeEvent; -import com.google.gwt.event.logical.shared.ValueChangeHandler; -import com.google.gwt.i18n.client.LocaleInfo; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.ui.RootPanel; -import com.lofidewanto.demo.client.common.ServicePreparator; -import com.lofidewanto.demo.client.common.WidgetName; -import com.lofidewanto.demo.client.ui.main.MainPanelView; - -public class DemoGwtWebApp implements EntryPoint { - - private static Logger logger = Logger - .getLogger(DemoGwtWebApp.class.getName()); - - private static final String HOST_LOADING_IMAGE = "loadingImage"; - - private static final String HISTORY_MAIN = "main"; - - private static final String LOCALE = "de_DE"; - - // Create Gin Injector - private final DemoGwtWebAppGinjector injector = GWT - .create(DemoGwtWebAppGinjector.class); - - @Override - public void onModuleLoad() { - addMetaElements(); - - // Disable Back Button - setupHistory(); - - logger.info("Test"); - - setupBootbox(); - - initServices(); - - GWT.runAsync(new RunAsyncCallback() { - @Override - public void onFailure(Throwable reason) { - } - - @Override - public void onSuccess() { - createViews(); - removeLoadingImage(); - // alert("LOFI"); - } - }); - } - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.lofidewanto.demo.client; + +import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.RunAsyncCallback; +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.MetaElement; +import com.google.gwt.dom.client.NodeList; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.i18n.client.LocaleInfo; +import com.google.gwt.user.client.History; +import com.google.gwt.user.client.ui.RootPanel; +import com.lofidewanto.demo.client.common.ServicePreparator; +import com.lofidewanto.demo.client.common.WidgetName; +import com.lofidewanto.demo.client.ui.main.MainPanelView; +import org.gwtbootstrap3.extras.bootbox.client.Bootbox; +import org.gwtbootstrap3.extras.bootbox.client.options.BootboxLocale; + +import java.util.logging.Logger; + +public class DemoGwtWebApp implements EntryPoint { + + private static Logger logger = Logger + .getLogger(DemoGwtWebApp.class.getName()); + + private static final String HOST_LOADING_IMAGE = "loadingImage"; + + private static final String HISTORY_MAIN = "main"; + + private static final String LOCALE = "de_DE"; + + // Create Gin Injector + private final DemoGwtWebAppGinjector injector = GWT + .create(DemoGwtWebAppGinjector.class); + + @Override + public void onModuleLoad() { + addMetaElements(); + + // Disable Back Button + setupHistory(); + + logger.info("Test"); + + setupBootbox(); + + initServices(); + + GWT.runAsync(new RunAsyncCallback() { + @Override + public void onFailure(Throwable reason) { + } + + @Override + public void onSuccess() { + createViews(); + removeLoadingImage(); + // alert("LOFI"); + } + }); + } + // @formatter:off - public static native void alert(String msg) /*-{ - $wnd.alert(msg); - }-*/; - // @formatter:on - - private void addMetaElements() { - logger.info("Add viewport"); - MetaElement element = Document.get().createMetaElement(); - element.setName("viewport"); - element.setContent("width=device-width, initial-scale=1.0"); - - NodeList node = Document.get().getElementsByTagName("head"); - Element elementHead = node.getItem(0); - elementHead.appendChild(element); - } - - private void removeLoadingImage() { - // Remove loadingImage from Host HTML page - RootPanel rootPanel = RootPanel.get(HOST_LOADING_IMAGE); - if (rootPanel != null) { - RootPanel.getBodyElement().removeChild(rootPanel.getElement()); - } - } - - private void initServices() { - ServicePreparator servicePreparator = injector.getServicePreparator(); - servicePreparator.prepare(); - } - - private void setupHistory() { - History.newItem(HISTORY_MAIN); - - // Add history listener - History.addValueChangeHandler(new ValueChangeHandler() { - @Override - public void onValueChange(ValueChangeEvent event) { - String token = event.getValue(); - if (!token.equals(HISTORY_MAIN)) { - History.newItem(HISTORY_MAIN); - } - } - }); - } - - private void createViews() { - // Views - logger.info("Create Views begins..."); - - MainPanelView mainPanelView = injector.getMainPanelView(); - mainPanelView.setContentAreaVisible(false); - - mainPanelView.addWidget(WidgetName.PERSONLIST, - injector.getPersonPanelView()); - - mainPanelView.setContentAreaVisible(true); - mainPanelView.updatePersonPanelView(); - - RootPanel.get().add(mainPanelView); - - logger.info("Create Views ends..."); - } - - private void setupBootbox() { - if (LocaleInfo.getCurrentLocale().getLocaleName().equals(LOCALE)) { - logger.info( - "Locale: " + LocaleInfo.getCurrentLocale().getLocaleName()); - Bootbox.setLocale(BootboxLocale.DE); - } - } -} + public static native void alert(String msg) /*-{ + $wnd.alert(msg); + }-*/; + // @formatter:on + + private void addMetaElements() { + logger.info("Add viewport"); + MetaElement element = Document.get().createMetaElement(); + element.setName("viewport"); + element.setContent("width=device-width, initial-scale=1.0"); + + NodeList node = Document.get().getElementsByTagName("head"); + Element elementHead = node.getItem(0); + elementHead.appendChild(element); + } + + private void removeLoadingImage() { + // Remove loadingImage from Host HTML page + RootPanel rootPanel = RootPanel.get(HOST_LOADING_IMAGE); + if (rootPanel != null) { + RootPanel.getBodyElement().removeChild(rootPanel.getElement()); + } + } + + private void initServices() { + ServicePreparator servicePreparator = injector.getServicePreparator(); + servicePreparator.prepare(); + } + + private void setupHistory() { + History.newItem(HISTORY_MAIN); + + // Add history listener + History.addValueChangeHandler(new ValueChangeHandler() { + @Override + public void onValueChange(ValueChangeEvent event) { + String token = event.getValue(); + if (!token.equals(HISTORY_MAIN)) { + History.newItem(HISTORY_MAIN); + } + } + }); + } + + private void createViews() { + // Views + logger.info("Create Views begins..."); + + MainPanelView mainPanelView = injector.getMainPanelView(); + mainPanelView.setContentAreaVisible(false); + + mainPanelView.addWidget(WidgetName.PERSONLIST, + injector.getPersonPanelView()); + + mainPanelView.setContentAreaVisible(true); + mainPanelView.updatePersonPanelView(); + + RootPanel.get().add(mainPanelView); + + logger.info("Create Views ends..."); + } + + private void setupBootbox() { + if (LocaleInfo.getCurrentLocale().getLocaleName().equals(LOCALE)) { + logger.info( + "Locale: " + LocaleInfo.getCurrentLocale().getLocaleName()); + Bootbox.setLocale(BootboxLocale.DE); + } + } +} From 393d0cce83e1ac0dffa78b982befb2138a53395b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Du=CC=88ppe?= Date: Fri, 10 Feb 2017 15:41:54 +0100 Subject: [PATCH 3/7] upgrade spring boot version 1.4.4.Release --- pom.xml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 1b29ff9..ed90408 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ org.springframework.boot spring-boot-starter-parent - 1.4.2.RELEASE + 1.4.4.RELEASE @@ -47,10 +47,8 @@ 2.2.0 1.1.6 2.0.0 - 2.0.2 - - 1.0.0 - + 2.0.2 + 1.0.0 From 76024457e6405e91af62b2066793f5250962af52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Du=CC=88ppe?= Date: Fri, 10 Feb 2017 15:42:19 +0100 Subject: [PATCH 4/7] uses lambda instead of inner class --- .../client/ui/person/PersonPanelView.java | 514 +++++++++--------- 1 file changed, 267 insertions(+), 247 deletions(-) diff --git a/src/main/java/com/lofidewanto/demo/client/ui/person/PersonPanelView.java b/src/main/java/com/lofidewanto/demo/client/ui/person/PersonPanelView.java index ec517de..9ca05d0 100644 --- a/src/main/java/com/lofidewanto/demo/client/ui/person/PersonPanelView.java +++ b/src/main/java/com/lofidewanto/demo/client/ui/person/PersonPanelView.java @@ -18,24 +18,6 @@ */ package com.lofidewanto.demo.client.ui.person; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.fusesource.restygwt.client.Method; -import org.fusesource.restygwt.client.MethodCallback; -import org.gwtbootstrap3.client.ui.Button; -import org.gwtbootstrap3.client.ui.Label; -import org.gwtbootstrap3.client.ui.Pagination; -import org.gwtbootstrap3.client.ui.SuggestBox; -import org.gwtbootstrap3.client.ui.TabListItem; -import org.gwtbootstrap3.client.ui.gwt.DataGrid; -import org.gwtbootstrap3.extras.bootbox.client.Bootbox; -import org.gwtbootstrap3.extras.datetimepicker.client.ui.DateTimePicker; - import com.google.gwt.cell.client.CheckboxCell; import com.google.gwt.cell.client.TextCell; import com.google.gwt.core.client.GWT; @@ -61,248 +43,286 @@ import com.lofidewanto.demo.client.ui.event.FilterEvent; import com.lofidewanto.demo.client.ui.event.SearchEvent; import com.lofidewanto.demo.shared.PersonDto; +import org.fusesource.restygwt.client.Method; +import org.fusesource.restygwt.client.MethodCallback; +import org.gwtbootstrap3.client.ui.Button; +import org.gwtbootstrap3.client.ui.Label; +import org.gwtbootstrap3.client.ui.Pagination; +import org.gwtbootstrap3.client.ui.SuggestBox; +import org.gwtbootstrap3.client.ui.TabListItem; +import org.gwtbootstrap3.client.ui.gwt.DataGrid; +import org.gwtbootstrap3.extras.bootbox.client.Bootbox; +import org.gwtbootstrap3.extras.datetimepicker.client.ui.DateTimePicker; + +import javax.inject.Inject; +import javax.inject.Singleton; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; @Singleton public class PersonPanelView extends Composite implements Startable { - private static Logger logger = Logger.getLogger(PersonPanelView.class.getName()); + private static Logger logger = Logger + .getLogger(PersonPanelView.class.getName()); + + interface PersonPanelViewUiBinder + extends UiBinder { + } - interface PersonPanelViewUiBinder extends UiBinder { - } + private static PersonPanelViewUiBinder uiBinder = GWT + .create(PersonPanelViewUiBinder.class); - private static PersonPanelViewUiBinder uiBinder = GWT.create(PersonPanelViewUiBinder.class); + interface PersonPanelEventBinder extends EventBinder { + } - interface PersonPanelEventBinder extends EventBinder { - } + private final PersonPanelEventBinder eventBinder = GWT + .create(PersonPanelEventBinder.class); - private final PersonPanelEventBinder eventBinder = GWT.create(PersonPanelEventBinder.class); + private final EventBus eventBus; - private final EventBus eventBus; + private final PersonClient personClient; - private final PersonClient personClient; + private ListDataProvider dataProviderList; - private ListDataProvider dataProviderList; + private ListDataProvider dataProviderFilter; - private ListDataProvider dataProviderFilter; + @Inject + private PersonUtil personUtil; - @Inject - private PersonUtil personUtil; + @UiField + Button refreshButton; - @UiField - Button refreshButton; + @UiField + Button searchButton; - @UiField - Button searchButton; - - @UiField - Button filterButton; - - @UiField - SuggestBox nameSuggestBox; - - @UiField - DateTimePicker fromDateTimePicker; - - @UiField - DateTimePicker untilDateTimePicker; - - @UiField - TabListItem listTab; - - @UiField - TabListItem searchTab; - - @UiField - DataGrid dataGrid1; - - @UiField - DataGrid dataGrid2; - - @UiField - Pagination dataGridPagination1; - - @UiField - Pagination dataGridPagination2; - - @Inject - public PersonPanelView(EventBus eventbus, ErrorFormatter errorFormatter, - LoadingMessagePopupPanel loadingMessagePopupPanel, PersonClient personClient) { - initWidget(uiBinder.createAndBindUi(this)); - this.eventBus = eventbus; - eventBinder.bindEventHandlers(this, eventBus); - - this.personClient = personClient; - - // Standard event handling - filterButton.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent clickEvent) { - logger.info("Click Detected by Simple Click Event"); - logger.info("Button Filter is clicked!!!" + clickEvent.getNativeEvent().getString()); - eventBus.fireEvent(new SearchEvent()); - filterPerson(); - } - }); - logger.info("PersonPanelView created..."); - - initTableColumns(dataGrid1); - initTableColumns(dataGrid2); - initListDataProvider(dataGrid1); - initFilterDataProvider(dataGrid2); - - getPersons(); - - // Event handling with Lambda - searchButton.addClickHandler(clickHandler -> searchButtonClick("Click Detected by Lambda Listener")); - } - - private void searchButtonClick(String message) { - logger.info(message); - searchButton.state().loading(); - - new Timer() { - @Override - public void run() { - searchButton.state().reset(); - } - }.schedule(5000); - } - - @UiHandler("refreshButton") - public void onButtonClick(final ClickEvent event) { - // Event handling in GWT UiBinder - logger.info("Click Detected by GWT UiBinder"); - refreshButton.state().loading(); - - new Timer() { - @Override - public void run() { - refreshButton.state().reset(); - } - }.schedule(2000); - } - - private void initTableColumns(DataGrid dataGrid) { - dataGrid.setWidth("100%"); - dataGrid.setHeight("300px"); - dataGrid.setAutoHeaderRefreshDisabled(true); - // Nick name. - Column nicknameColumn = new Column(new TextCell()) { - @Override - public String getValue(PersonDto object) { - return object.getNickname(); - } - }; - dataGrid.addColumn(nicknameColumn, "Nickname"); - dataGrid.setColumnWidth(nicknameColumn, 40, Style.Unit.PCT); - - // Nick name. - Column nameColumn = new Column(new TextCell()) { - @Override - public String getValue(PersonDto object) { - return object.getName(); - } - }; - dataGrid.addColumn(nameColumn, "Name"); - dataGrid.setColumnWidth(nameColumn, 40, Style.Unit.PCT); - - // Retired - Column isRetiredColumn = new Column(new CheckboxCell(true, false)) { - @Override - public Boolean getValue(PersonDto object) { - if (object.isInRetirement() == null) { - return false; - } else { - return object.isInRetirement(); - } - }; - }; - dataGrid.addColumn(isRetiredColumn, "Retired"); - dataGrid.setColumnWidth(isRetiredColumn, 20, Style.Unit.PCT); - - } - - private void initListDataProvider(DataGrid dataGrid) { - dataProviderList = new ListDataProvider<>(new ArrayList(0)); - dataProviderList.addDataDisplay(dataGrid); - - // Set the message to display when the table is empty. - dataGrid.setEmptyTableWidget(new Label("No Data")); - - } - - private void initFilterDataProvider(DataGrid dataGrid) { - dataProviderFilter = new ListDataProvider<>(new ArrayList(0)); - dataProviderFilter.addDataDisplay(dataGrid); - - // Set the message to display when the table is empty. - dataGrid.setEmptyTableWidget(new Label("No Data")); - - } - - private void filterPerson() { - MethodCallback> filterCallBack = new MethodCallback>() { - @Override - public void onFailure(Method method, Throwable throwable) { - Bootbox.alert("Method call back has ERROR:" + throwable.getLocalizedMessage()); - throwable.printStackTrace(); - } - - @Override - public void onSuccess(Method method, List persons) { - Bootbox.alert("Method call back is OK .:" + persons.get(0)); - listTab.setActive(false); - searchTab.setActive(true); - refreshGrid(persons, dataProviderFilter); - } - }; - - personClient.filterPerson(nameSuggestBox.getValue(), fromDateTimePicker.getValue(), - untilDateTimePicker.getValue(), filterCallBack); - } - - private void getPersons() { - MethodCallback> callback = new MethodCallback>() { - @Override - public void onFailure(Method method, Throwable exception) { - logger.info("Error: " + exception); - Bootbox.alert("Error: " + exception); - } - - @Override - public void onSuccess(Method method, List persons) { - logger.info("The result is ok"); - Bootbox.alert("The result is ok"); - searchTab.setActive(false); - listTab.setActive(true); - - refreshGrid(persons, dataProviderList); - } - }; - - logger.info("Get persons begins..."); - - personClient.getPersons(0, 100, callback); - - logger.info("Get persons ends..."); - } - - private void refreshGrid(List personDtos, ListDataProvider dataProvider) { - for (PersonDto p : personDtos) { - logger.info(p.getNickname() + " " + p.isInRetirement()); - } - - dataProvider.setList(personDtos); - } - - @Override - public void start() { - personUtil.sayHello(); - } - - @EventHandler - public void onEvent(FilterEvent event) { - logger.info("Get Event:" + event); - Bootbox.alert("FilterEvent is received in PersonPanelView..."); - } + @UiField + Button filterButton; + + @UiField + SuggestBox nameSuggestBox; + + @UiField + DateTimePicker fromDateTimePicker; + + @UiField + DateTimePicker untilDateTimePicker; + + @UiField + TabListItem listTab; + + @UiField + TabListItem searchTab; + + @UiField + DataGrid dataGrid1; + + @UiField + DataGrid dataGrid2; + + @UiField + Pagination dataGridPagination1; + + @UiField + Pagination dataGridPagination2; + + @Inject + public PersonPanelView(EventBus eventbus, ErrorFormatter errorFormatter, + LoadingMessagePopupPanel loadingMessagePopupPanel, + PersonClient personClient) { + initWidget(uiBinder.createAndBindUi(this)); + this.eventBus = eventbus; + eventBinder.bindEventHandlers(this, eventBus); + + this.personClient = personClient; + + // Standard event handling + filterButton.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent clickEvent) { + logger.info("Click Detected by Simple Click Event"); + logger.info("Button Filter is clicked!!!" + clickEvent + .getNativeEvent().getString()); + eventBus.fireEvent(new SearchEvent()); + filterPerson(); + } + }); + filterButton.addClickHandler(clickEvent -> { + Bootbox.alert( + "Button Filter is clicked!!!" + clickEvent.getNativeEvent() + .getString()); + filterPerson(); + }); + logger.info("PersonPanelView created..."); + + initTableColumns(dataGrid1); + initTableColumns(dataGrid2); + initListDataProvider(dataGrid1); + initFilterDataProvider(dataGrid2); + + getPersons(); + + // Event handling with Lambda + searchButton.addClickHandler(clickHandler -> searchButtonClick( + "Click Detected by Lambda Listener")); + } + + private void searchButtonClick(String message) { + logger.info(message); + searchButton.state().loading(); + + new Timer() { + @Override + public void run() { + searchButton.state().reset(); + } + }.schedule(5000); + } + + @UiHandler("refreshButton") + public void onButtonClick(final ClickEvent event) { + // Event handling in GWT UiBinder + logger.info("Click Detected by GWT UiBinder"); + refreshButton.state().loading(); + + new Timer() { + @Override + public void run() { + refreshButton.state().reset(); + } + }.schedule(2000); + } + + private void initTableColumns(DataGrid dataGrid) { + dataGrid.setWidth("100%"); + dataGrid.setHeight("300px"); + dataGrid.setAutoHeaderRefreshDisabled(true); + // Nick name. + Column nicknameColumn = new Column( + new TextCell()) { + @Override + public String getValue(PersonDto object) { + return object.getNickname(); + } + }; + dataGrid.addColumn(nicknameColumn, "Nickname"); + dataGrid.setColumnWidth(nicknameColumn, 40, Style.Unit.PCT); + + // Nick name. + Column nameColumn = new Column( + new TextCell()) { + @Override + public String getValue(PersonDto object) { + return object.getName(); + } + }; + dataGrid.addColumn(nameColumn, "Name"); + dataGrid.setColumnWidth(nameColumn, 40, Style.Unit.PCT); + + // Retired + Column isRetiredColumn = new Column( + new CheckboxCell(true, false)) { + @Override + public Boolean getValue(PersonDto object) { + if (object.isInRetirement() == null) { + return false; + } else { + return object.isInRetirement(); + } + } + + ; + }; + dataGrid.addColumn(isRetiredColumn, "Retired"); + dataGrid.setColumnWidth(isRetiredColumn, 20, Style.Unit.PCT); + + } + + private void initListDataProvider(DataGrid dataGrid) { + dataProviderList = new ListDataProvider<>(new ArrayList(0)); + dataProviderList.addDataDisplay(dataGrid); + + // Set the message to display when the table is empty. + dataGrid.setEmptyTableWidget(new Label("No Data")); + + } + + private void initFilterDataProvider(DataGrid dataGrid) { + dataProviderFilter = new ListDataProvider<>( + new ArrayList(0)); + dataProviderFilter.addDataDisplay(dataGrid); + + // Set the message to display when the table is empty. + dataGrid.setEmptyTableWidget(new Label("No Data")); + + } + + private void filterPerson() { + MethodCallback> filterCallBack = new MethodCallback>() { + @Override + public void onFailure(Method method, Throwable throwable) { + Bootbox.alert("Method call back has ERROR:" + throwable + .getLocalizedMessage()); + throwable.printStackTrace(); + } + + @Override + public void onSuccess(Method method, List persons) { + Bootbox.alert("Method call back is OK .:" + persons.get(0)); + listTab.setActive(false); + searchTab.setActive(true); + refreshGrid(persons, dataProviderFilter); + } + }; + + personClient.filterPerson(nameSuggestBox.getValue(), + fromDateTimePicker.getValue(), untilDateTimePicker.getValue(), + filterCallBack); + } + + private void getPersons() { + MethodCallback> callback = new MethodCallback>() { + @Override + public void onFailure(Method method, Throwable exception) { + logger.info("Error: " + exception); + Bootbox.alert("Error: " + exception); + } + + @Override + public void onSuccess(Method method, List persons) { + logger.info("The result is ok"); + Bootbox.alert("The result is ok"); + searchTab.setActive(false); + listTab.setActive(true); + + refreshGrid(persons, dataProviderList); + } + }; + + logger.info("Get persons begins..."); + + personClient.getPersons(0, 100, callback); + + logger.info("Get persons ends..."); + } + + private void refreshGrid(List personDtos, + ListDataProvider dataProvider) { + for (PersonDto p : personDtos) { + logger.info(p.getNickname() + " " + p.isInRetirement()); + } + + dataProvider.setList(personDtos); + } + + @Override + public void start() { + personUtil.sayHello(); + } + + @EventHandler + public void onEvent(FilterEvent event) { + logger.info("Get Event:" + event); + Bootbox.alert("FilterEvent is received in PersonPanelView..."); + } } From e3a30b5debce7c2db22f4502c1b2a937952c10ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Du=CC=88ppe?= Date: Mon, 13 Feb 2017 10:26:09 +0100 Subject: [PATCH 5/7] comment out duplicated event handler --- .../client/ui/person/PersonPanelView.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/lofidewanto/demo/client/ui/person/PersonPanelView.java b/src/main/java/com/lofidewanto/demo/client/ui/person/PersonPanelView.java index 9ca05d0..c0ad4c4 100644 --- a/src/main/java/com/lofidewanto/demo/client/ui/person/PersonPanelView.java +++ b/src/main/java/com/lofidewanto/demo/client/ui/person/PersonPanelView.java @@ -23,7 +23,6 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style; import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.EventBus; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; @@ -41,7 +40,6 @@ import com.lofidewanto.demo.client.domain.PersonClient; import com.lofidewanto.demo.client.extra.PersonUtil; import com.lofidewanto.demo.client.ui.event.FilterEvent; -import com.lofidewanto.demo.client.ui.event.SearchEvent; import com.lofidewanto.demo.shared.PersonDto; import org.fusesource.restygwt.client.Method; import org.fusesource.restygwt.client.MethodCallback; @@ -137,16 +135,16 @@ public PersonPanelView(EventBus eventbus, ErrorFormatter errorFormatter, this.personClient = personClient; // Standard event handling - filterButton.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent clickEvent) { - logger.info("Click Detected by Simple Click Event"); - logger.info("Button Filter is clicked!!!" + clickEvent - .getNativeEvent().getString()); - eventBus.fireEvent(new SearchEvent()); - filterPerson(); - } - }); +// filterButton.addClickHandler(new ClickHandler() { +// @Override +// public void onClick(ClickEvent clickEvent) { +// logger.info("Click Detected by Simple Click Event"); +// logger.info("Button Filter is clicked!!!" + clickEvent +// .getNativeEvent().getString()); +// eventBus.fireEvent(new SearchEvent()); +// filterPerson(); +// } +// }); filterButton.addClickHandler(clickEvent -> { Bootbox.alert( "Button Filter is clicked!!!" + clickEvent.getNativeEvent() From aa4514b8b4f590c33be4f9e162a60aa005ba5d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Du=CC=88ppe?= Date: Mon, 13 Feb 2017 12:12:47 +0100 Subject: [PATCH 6/7] WIP: describe how to debug with intellij --- README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 47a0361..d208024 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,80 @@ There are two GWT configuration files: [_DemoGwtDevelopment.gwt.xml_](https://gi - _DemoGwtDevelopment.gwt.xml_: this config will be used to make the GWT compiling process faster. This only compiles for one web browser and use INFO as logging output. - _DemoGwt.gwt.xml_: this config will be used for production transpilling. This is optimized for many many production purposes. -## Unit and Integration Testing +## Unit and Integration Testing + +## Debugging with IntelliJ IDEA + +For debugging gwt with IntelliJ IDEA proceed the following stets. + +### Prequesites + +- JetBrains IntelliJ 2016 Ultimate (Community doesn't support it) +- Chrome browser +- [JetBrains IDE Support Chrome Browser Plugin](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) +- Enabled GWT Plugin in IntelliJ + +### Overview +The following diagram shows the different parts of the setup: + +![GWT Client Logging](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-debugging-setup-diagram.png) + +### Step by step + +#### Open Project in IntelliJ + +![Open Project in IntelliJ](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-import-project.png) + +After this the project is loaded and the `DemoGwtSpringbootApplication` will be added to the `RunConfigurations` automatically. + +![Open Project in IntelliJ](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-import-project.png) + +#### Configure Web Facet + +Open in the `FileMenu` the `Project Structure` + +![Open Project in IntelliJ](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-open-project-structure.png) + +Und add under `Facets` a `Web Facet` + +![Open Project in IntelliJ](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-add-web-facet.png) + +Add the facet into the `demo-gwt-springboot` module: + +![Open Project in IntelliJ](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-choose-modul.png) + +The path must be set to `src/main/resources/public` and the context must be `/demogwt`. + +**Important** + +Do not add the web.xml to git. Just ignore it. + +![Open Project in IntelliJ](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-add-file-to-git.png) + +#### Do not generate Artifacts + +![Open Project in IntelliJ](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-add-file-to-git.png) + + +#### Running the debugger with the IDE Support Plugin + +You should see the alert that the »JetBrains IDE Support« is running in debug mode. + +If you have any trouble connecting the browser with the idea, please check the ports of the browser plugin and Intellij. + +Right click on the Life Edit extension and choose Options: + +![GWT Client Logging](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-debugging-session-is-running.png) + +The default port is `63342`. + +![GWT Client Logging](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-ide-support-options.png) + +And check if the port in the Intellij IDEA debugger is configured on the same port. + +![GWT Client Logging](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-ide-support-preferences-configure-port.png) + + ### Server: Spring Test From 065ad012b19a55e12c66738173e90ffb64fdcba1 Mon Sep 17 00:00:00 2001 From: "M. Noerder-Tuitje" Date: Wed, 1 Mar 2017 11:29:50 +0100 Subject: [PATCH 7/7] added missing URL --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ac9ed7d..5d59fb5 100644 --- a/README.md +++ b/README.md @@ -288,12 +288,9 @@ And a GWT Configuration: ![Open Project in IntelliJ](https://raw.github.com/lofidewanto/demo-gwt-springboot/master/src/main/docs/idea-add-gwt-run-configuration.png) -After this you start the "Spring Boot Project" first and after this the "GWT-Project" in Debug mode. - -#### Codeserver - -Now you have to repeat the steps to configure the code server (see above). +Important : set URL to http://localhost:9014/demogwt/demogwt.html +After this you start the "Spring Boot Project" first and after this the "GWT-Project" in Debug mode. #### Running the debugger with the IDE Support Plugin