This repository has been archived by the owner on Dec 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor main view and UI event bus components
- Loading branch information
1 parent
c4f618b
commit 217109d
Showing
19 changed files
with
213 additions
and
136 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
src/main/java/com/kiroule/jpetstore/vaadinspring/ui/AppUI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.kiroule.jpetstore.vaadinspring.ui; | ||
|
||
import com.kiroule.jpetstore.vaadinspring.ui.event.UIEventBus; | ||
import com.kiroule.jpetstore.vaadinspring.ui.util.HasLogger; | ||
import com.kiroule.jpetstore.vaadinspring.ui.util.NavBarButtonUpdater; | ||
import com.kiroule.jpetstore.vaadinspring.ui.util.PageTitleUpdater; | ||
import com.vaadin.annotations.Theme; | ||
import com.vaadin.annotations.Title; | ||
import com.vaadin.annotations.Widgetset; | ||
import com.vaadin.navigator.Navigator; | ||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.spring.annotation.SpringUI; | ||
import com.vaadin.spring.navigator.SpringViewProvider; | ||
import com.vaadin.ui.UI; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
/** | ||
* @author Igor Baiborodine | ||
*/ | ||
@Title("JPetStore Vaadin 8 Spring Demo") | ||
@Theme("jpetstoretheme") | ||
@Widgetset("com.vaadin.v7.Vaadin7WidgetSet") | ||
@SpringUI | ||
public class AppUI extends UI implements HasLogger { | ||
|
||
private static final long serialVersionUID = 4670701701584923650L; | ||
|
||
private final SpringViewProvider viewProvider; | ||
private final MainView mainView; | ||
private final UIEventBus uiEventBus; | ||
private final PageTitleUpdater pageTitleUpdater; | ||
private final NavBarButtonUpdater navBarButtonUpdater; | ||
|
||
@Autowired | ||
public AppUI(SpringViewProvider viewProvider, MainView mainView, UIEventBus uiEventBus, | ||
PageTitleUpdater pageTitleUpdater, NavBarButtonUpdater navBarButtonUpdater) { | ||
this.viewProvider = viewProvider; | ||
this.mainView = mainView; | ||
this.uiEventBus = uiEventBus; | ||
this.pageTitleUpdater = pageTitleUpdater; | ||
this.navBarButtonUpdater = navBarButtonUpdater; | ||
} | ||
|
||
public static AppUI getCurrent() { | ||
return (AppUI) UI.getCurrent(); | ||
} | ||
|
||
public static UIEventBus getUiEventBus() { | ||
return getCurrent().uiEventBus; | ||
} | ||
|
||
@Override | ||
protected void init(VaadinRequest request) { | ||
setContent(mainView); | ||
|
||
Navigator navigator = new Navigator(this, mainView.getViewContainer()); | ||
navigator.addProvider(viewProvider); | ||
navigator.addViewChangeListener(navBarButtonUpdater); | ||
navigator.addViewChangeListener(pageTitleUpdater); | ||
|
||
uiEventBus.register(mainView); | ||
getLogger().info("App UI initialized"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.