2222
2323import com .flowingcode .addons .applayout .menu .MenuItem ;
2424import com .vaadin .flow .component .html .H3 ;
25+ import com .vaadin .flow .component .icon .VaadinIcon ;
2526import com .vaadin .flow .component .notification .Notification ;
2627import com .vaadin .flow .component .orderedlayout .VerticalLayout ;
2728import com .vaadin .flow .router .Route ;
3132public class DemoView extends VerticalLayout {
3233
3334 private VerticalLayout container = new VerticalLayout ();
35+ private final AppLayout app = new AppLayout ("AppLayout Addon for Vaadin 10 Demo" );
3436
3537 public DemoView () {
3638 container .setDefaultHorizontalComponentAlignment (Alignment .CENTER );
@@ -40,10 +42,20 @@ public DemoView() {
4042 this .setSpacing (false );
4143 this .setMargin (false );
4244
43- AppLayout app = new AppLayout ("AppLayout Addon for Vaadin 10 Demo" );
45+ app .setMenuItems (createMenuItems ());
46+
47+ app .setToolbarIconButtons (new MenuItem ("Delete" , "delete" , () -> Notification .show ("Delete action" )),
48+ new MenuItem ("Search" , "search" , () -> Notification .show ("Search action" )),
49+ new MenuItem ("Close" , "close" , () -> Notification .show ("Close action" )));
50+
51+ this .add (app , container );
52+ }
53+
54+ private MenuItem [] createMenuItems () {
4455 MenuItem mi = new MenuItem ("Say hello" , "star" , () -> showContent ("Hello!" ));
45- app . setMenuItems ( mi ,
56+ return new MenuItem [] { mi ,
4657 new MenuItem ("About" , "cloud" , () -> showContent ("About" )),
58+ new MenuItem ("Clear Items" , "star" , () -> app .clearMenuItems ()),
4759 new MenuItem ("Change Text & Icon" , "cloud" , () -> {
4860 if (mi .getIcon ().equals ("star" )) {
4961 mi .setIcon ("cloud" );
@@ -59,14 +71,7 @@ public DemoView() {
5971 new MenuItem ("SubMenu" ,
6072 new MenuItem ("Hello Again" ,()->showContent ("Hello Again!" )),
6173 new MenuItem ("And Again" ,()->showContent ("And Again!" )))
62- ));
63-
64-
65- app .setToolbarIconButtons (new MenuItem ("Delete" , "delete" , () -> Notification .show ("Delete action" )),
66- new MenuItem ("Search" , "search" , () -> Notification .show ("Search action" )),
67- new MenuItem ("Close" , "close" , () -> Notification .show ("Close action" )));
68-
69- this .add (app , container );
74+ )};
7075 }
7176
7277 private void showContent (String content ) {
0 commit comments