Skip to content

Commit e175420

Browse files
javier-godoyngonzalezpazFC
authored andcommitted
style: apply code formatting
1 parent 17eb26b commit e175420

29 files changed

+1239
-1261
lines changed

src/main/java/com/flowingcode/addons/applayout/AbstractFcAppRouterLayout.java

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,68 +19,66 @@
1919
*/
2020
package com.flowingcode.addons.applayout;
2121

22-
import java.util.Optional;
23-
2422
import com.vaadin.flow.component.AttachEvent;
2523
import com.vaadin.flow.component.HasElement;
2624
import com.vaadin.flow.component.html.Div;
2725
import com.vaadin.flow.router.HasDynamicTitle;
2826
import com.vaadin.flow.router.PageTitle;
2927
import com.vaadin.flow.router.RouterLayout;
28+
import java.util.Optional;
3029

3130
/**
32-
* Convenience class for using an AppLayout as a parent layout in a Flow application.
33-
* Basic usage involves extending this class and implementing
34-
* the {@code configure} method.
31+
* Convenience class for using an AppLayout as a parent layout in a Flow application. Basic usage
32+
* involves extending this class and implementing the {@code configure} method.
3533
*/
3634
public abstract class AbstractFcAppRouterLayout extends Div implements RouterLayout {
3735

38-
private static final long serialVersionUID = 1L;
39-
40-
private AppLayout app;
36+
private static final long serialVersionUID = 1L;
37+
38+
private AppLayout app;
4139

42-
protected AbstractFcAppRouterLayout() {
43-
getElement().getStyle().set("width", "100%");
44-
getElement().getStyle().set("height", "100vh");
45-
getElement().getStyle().set("display", "flex");
46-
getElement().getStyle().set("flex-direction", "column");
47-
app = new AppLayout("");
48-
app.setHeight("32px");
49-
app.getElement().getStyle().set("flex-shrink", "0");
50-
app.addClassName("compact");
51-
app.setFixed(true);
52-
app.setSwipeOpen(false);
53-
add(app);
54-
}
40+
protected AbstractFcAppRouterLayout() {
41+
getElement().getStyle().set("width", "100%");
42+
getElement().getStyle().set("height", "100vh");
43+
getElement().getStyle().set("display", "flex");
44+
getElement().getStyle().set("flex-direction", "column");
45+
app = new AppLayout("");
46+
app.setHeight("32px");
47+
app.getElement().getStyle().set("flex-shrink", "0");
48+
app.addClassName("compact");
49+
app.setFixed(true);
50+
app.setSwipeOpen(false);
51+
add(app);
52+
}
5553

56-
@Override
57-
protected void onAttach(AttachEvent attachEvent) {
58-
super.onAttach(attachEvent);
59-
configure(app);
60-
}
54+
@Override
55+
protected void onAttach(AttachEvent attachEvent) {
56+
super.onAttach(attachEvent);
57+
configure(app);
58+
}
6159

62-
protected abstract void configure(AppLayout app);
60+
protected abstract void configure(AppLayout app);
6361

64-
@Override
65-
public final void showRouterLayoutContent(HasElement content) {
66-
showRouterLayoutContent(app,content);
67-
}
68-
69-
protected void showRouterLayoutContent(AppLayout app, HasElement content) {
70-
content.getElement().getStyle().set("flex-grow", "1");
71-
content.getElement().getStyle().set("display", "flex");
72-
content.getElement().getStyle().set("flex-direction", "column");
73-
app.setCaption(getCaption(content));
74-
RouterLayout.super.showRouterLayoutContent(content);
75-
}
62+
@Override
63+
public final void showRouterLayoutContent(HasElement content) {
64+
showRouterLayoutContent(app, content);
65+
}
7666

77-
private static String getCaption(HasElement content) {
78-
if (content instanceof HasDynamicTitle) {
79-
return ((HasDynamicTitle)content).getPageTitle();
80-
} else {
81-
return Optional.ofNullable(content.getClass().getAnnotation(PageTitle.class))
82-
.map(PageTitle::value).orElse("");
83-
}
84-
}
67+
protected void showRouterLayoutContent(AppLayout app, HasElement content) {
68+
content.getElement().getStyle().set("flex-grow", "1");
69+
content.getElement().getStyle().set("display", "flex");
70+
content.getElement().getStyle().set("flex-direction", "column");
71+
app.setCaption(getCaption(content));
72+
RouterLayout.super.showRouterLayoutContent(content);
73+
}
8574

86-
}
75+
private static String getCaption(HasElement content) {
76+
if (content instanceof HasDynamicTitle) {
77+
return ((HasDynamicTitle) content).getPageTitle();
78+
} else {
79+
return Optional.ofNullable(content.getClass().getAnnotation(PageTitle.class))
80+
.map(PageTitle::value)
81+
.orElse("");
82+
}
83+
}
84+
}

src/main/java/com/flowingcode/addons/applayout/AppDrawer.java

Lines changed: 84 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,12 +19,6 @@
1919
*/
2020
package com.flowingcode.addons.applayout;
2121

22-
23-
24-
import java.util.Collection;
25-
import java.util.Collections;
26-
import java.util.Optional;
27-
2822
import com.vaadin.flow.component.Component;
2923
import com.vaadin.flow.component.HasComponents;
3024
import com.vaadin.flow.component.Tag;
@@ -33,95 +27,103 @@
3327
import com.vaadin.flow.component.dependency.NpmPackage;
3428
import com.vaadin.flow.component.html.H4;
3529
import com.vaadin.flow.shared.Registration;
30+
import java.util.Collection;
31+
import java.util.Collections;
32+
import java.util.Optional;
3633

3734
/**
3835
* Component that renders the app drawer
39-
*
40-
* @author mlopez
4136
*
37+
* @author mlopez
4238
*/
4339
@SuppressWarnings("serial")
4440
@Tag("app-drawer")
4541
@HtmlImport("bower_components/app-layout/app-drawer/app-drawer.html")
4642
@HtmlImport("bower_components/iron-scroll-target-behavior/iron-scroll-target-behavior.html")
47-
@NpmPackage(value = "@polymer/app-layout", version= AppLayout.NPM_VERSION)
43+
@NpmPackage(value = "@polymer/app-layout", version = AppLayout.NPM_VERSION)
4844
@JsModule("@polymer/app-layout/app-drawer/app-drawer.js")
4945
public class AppDrawer extends Component implements HasComponents {
50-
51-
private final PaperListbox pm = new PaperListbox(Collections.emptyList());
52-
private final Component header;
5346

54-
public AppDrawer(String title) {
55-
this(new H4(title));
56-
header.getElement().setAttribute("style", "text-align:center");
57-
}
58-
59-
public AppDrawer(Component headerComponent) {
60-
this.header = headerComponent;
61-
getElement().setAttribute("id", "drawer");
62-
setSwipeOpen(true);
63-
64-
Registration[] r = new Registration[1];
65-
r[0] = getElement().addEventListener("app-drawer-transitioned", ev->{
66-
//need to adjust the height after the drawer has been rendered
67-
pm.getElement().executeJs("this.style.height='calc(100% - '+($0.scrollHeight+16)+'px)'", header);
68-
r[0].remove();
69-
});
70-
71-
removeAll();
72-
}
73-
74-
public void setSwipeOpen(boolean swipeOpen) {
75-
getElement().setAttribute("swipe-open", swipeOpen);
76-
}
47+
private final PaperListbox pm = new PaperListbox(Collections.emptyList());
48+
private final Component header;
7749

78-
@Override
79-
public void add(Component... components) {
80-
for (Component c : components) {
81-
if (c instanceof MenuItem) {
82-
pm.add(c);
83-
} else {
84-
HasComponents.super.add(components);
85-
}
86-
}
87-
}
88-
89-
@Override
90-
public void remove(Component... components) {
91-
for (Component c : components) {
92-
if (c instanceof MenuItem) {
93-
pm.removeAll();
94-
} else {
95-
HasComponents.super.remove(components);
96-
}
97-
}
98-
}
99-
100-
@Override
101-
public void removeAll() {
102-
HasComponents.super.removeAll();
103-
this.add(header);
104-
this.add(pm);
50+
public AppDrawer(String title) {
51+
this(new H4(title));
52+
header.getElement().setAttribute("style", "text-align:center");
53+
}
54+
55+
public AppDrawer(Component headerComponent) {
56+
this.header = headerComponent;
57+
getElement().setAttribute("id", "drawer");
58+
setSwipeOpen(true);
59+
60+
Registration[] r = new Registration[1];
61+
r[0] =
62+
getElement()
63+
.addEventListener(
64+
"app-drawer-transitioned",
65+
ev -> {
66+
// need to adjust the height after the drawer has been rendered
67+
pm.getElement()
68+
.executeJs(
69+
"this.style.height='calc(100% - '+($0.scrollHeight+16)+'px)'", header);
70+
r[0].remove();
71+
});
72+
73+
removeAll();
74+
}
75+
76+
public void setSwipeOpen(boolean swipeOpen) {
77+
getElement().setAttribute("swipe-open", swipeOpen);
78+
}
79+
80+
@Override
81+
public void add(Component... components) {
82+
for (Component c : components) {
83+
if (c instanceof MenuItem) {
84+
pm.add(c);
85+
} else {
86+
HasComponents.super.add(components);
87+
}
10588
}
106-
107-
public void setMenuItems(Collection<? extends Component> menuItems) {
108-
pm.removeAll();
109-
menuItems.stream().forEach(pm::add);
89+
}
90+
91+
@Override
92+
public void remove(Component... components) {
93+
for (Component c : components) {
94+
if (c instanceof MenuItem) {
95+
pm.removeAll();
96+
} else {
97+
HasComponents.super.remove(components);
98+
}
11099
}
100+
}
111101

112-
/**Close the app-drawer.*/
113-
public void close() {
114-
getUI().ifPresent(ui->ui.getPage().executeJs("$0.close()", this));
115-
}
102+
@Override
103+
public void removeAll() {
104+
HasComponents.super.removeAll();
105+
this.add(header);
106+
this.add(pm);
107+
}
116108

117-
static Optional<AppDrawer> findAppDrawer(Component component) {
118-
while (component!=null) {
119-
if (component instanceof AppDrawer) {
120-
return Optional.of((AppDrawer)component);
121-
} else {
122-
component = component.getParent().orElse(null);
123-
}
124-
}
125-
return Optional.empty();
126-
}
109+
public void setMenuItems(Collection<? extends Component> menuItems) {
110+
pm.removeAll();
111+
menuItems.stream().forEach(pm::add);
112+
}
113+
114+
/** Close the app-drawer. */
115+
public void close() {
116+
getUI().ifPresent(ui -> ui.getPage().executeJs("$0.close()", this));
117+
}
118+
119+
static Optional<AppDrawer> findAppDrawer(Component component) {
120+
while (component != null) {
121+
if (component instanceof AppDrawer) {
122+
return Optional.of((AppDrawer) component);
123+
} else {
124+
component = component.getParent().orElse(null);
125+
}
126+
}
127+
return Optional.empty();
128+
}
127129
}

0 commit comments

Comments
 (0)