Skip to content

Commit f91df01

Browse files
authored
Merge pull request #421 from GwtMaterialDesign/release_2.5.0
Release 2.5.0
2 parents bf25eec + 24a4306 commit f91df01

34 files changed

+1573
-56
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66

77
Gwt Material Design Extra Components for https://github.com/GwtMaterialDesign/gwt-material <br>
88

9-
## Current Version 2.5.0-rc1
9+
## Current Version 2.5.0
1010
```xml
1111
<dependency>
1212
<groupId>com.github.gwtmaterialdesign</groupId>
1313
<artifactId>gwt-material-addins</artifactId>
14-
<version>2.5.0-rc1</version>
14+
<version>2.5.0</version>
1515
</dependency>
1616
```
1717

18-
## Snapshot Version 2.5.0-SNAPSHOT
18+
## Snapshot Version 2.5.0
1919
```xml
2020
<dependency>
2121
<groupId>com.github.gwtmaterialdesign</groupId>
2222
<artifactId>gwt-material-addins</artifactId>
23-
<version>2.5.0-SNAPSHOT</version>
23+
<version>2.5.0</version>
2424
</dependency>
2525
```
2626

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>gwt-material-parent</artifactId>
77
<groupId>com.github.gwtmaterialdesign</groupId>
8-
<version>2.5.0-rc1</version>
8+
<version>2.5.0</version>
99
</parent>
1010

1111
<artifactId>gwt-material-addins</artifactId>
@@ -24,7 +24,7 @@
2424
<connection>scm:git:[email protected]:GwtMaterialDesign/gwt-material-addins.git</connection>
2525
<developerConnection>scm:git:[email protected]:GwtMaterialDesign/gwt-material-addins.git</developerConnection>
2626
<url>http://github.com/GwtMaterialDesign/gwt-material-addins</url>
27-
<tag>v2.5.0-rc1</tag>
27+
<tag>v2.5.0</tag>
2828
</scm>
2929

3030
<licenses>

src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatar.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import gwt.material.design.addins.client.MaterialAddins;
2424
import gwt.material.design.addins.client.avatar.js.AvatarOptions;
2525
import gwt.material.design.addins.client.avatar.js.JsAvatar;
26+
import gwt.material.design.addins.client.md5.Md5ClientBundle;
27+
import gwt.material.design.addins.client.md5.Md5DebugClientBundle;
2628
import gwt.material.design.client.MaterialDesignBase;
2729
import gwt.material.design.client.base.AbstractValueWidget;
2830
import gwt.material.design.client.base.JsLoader;
@@ -59,10 +61,10 @@ public class MaterialAvatar extends AbstractValueWidget<String> implements JsLoa
5961
static {
6062
if (MaterialAddins.isDebug()) {
6163
MaterialDesignBase.injectDebugJs(MaterialAvatarDebugClientBundle.INSTANCE.jdenticonDebugJs());
62-
MaterialDesignBase.injectDebugJs(MaterialAvatarDebugClientBundle.INSTANCE.md5DebugJs());
64+
MaterialDesignBase.injectDebugJs(Md5DebugClientBundle.INSTANCE.md5DebugJs());
6365
} else {
6466
MaterialDesignBase.injectJs(MaterialAvatarClientBundle.INSTANCE.jdenticonJs());
65-
MaterialDesignBase.injectJs(MaterialAvatarClientBundle.INSTANCE.md5Js());
67+
MaterialDesignBase.injectJs(Md5ClientBundle.INSTANCE.md5Js());
6668
}
6769
}
6870

src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarClientBundle.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,4 @@ public interface MaterialAvatarClientBundle extends ClientBundle {
3434

3535
@Source("resources/js/jdenticon-2.2.0.min.js")
3636
TextResource jdenticonJs();
37-
38-
@Source("resources/js/md5.min.js")
39-
TextResource md5Js();
40-
4137
}

src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarDebugClientBundle.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,4 @@ public interface MaterialAvatarDebugClientBundle extends ClientBundle {
3434

3535
@Source("resources/js/jdenticon-2.2.0.js")
3636
TextResource jdenticonDebugJs();
37-
38-
@Source("resources/js/md5.js")
39-
TextResource md5DebugJs();
4037
}
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2021 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.addins.client.banner;
21+
22+
import com.google.gwt.dom.client.Document;
23+
import com.google.gwt.dom.client.Element;
24+
import com.google.gwt.event.logical.shared.CloseEvent;
25+
import com.google.gwt.event.logical.shared.CloseHandler;
26+
import com.google.gwt.event.logical.shared.OpenEvent;
27+
import com.google.gwt.event.logical.shared.OpenHandler;
28+
import com.google.gwt.event.shared.HandlerRegistration;
29+
import com.google.gwt.user.client.ui.RootPanel;
30+
import com.google.gwt.user.client.ui.Widget;
31+
import gwt.material.design.addins.client.MaterialAddins;
32+
import gwt.material.design.addins.client.banner.event.HasBannerHandlers;
33+
import gwt.material.design.addins.client.dark.AddinsDarkThemeReloader;
34+
import gwt.material.design.client.MaterialDesignBase;
35+
import gwt.material.design.client.base.HasOpenClose;
36+
import gwt.material.design.client.base.MaterialWidget;
37+
import gwt.material.design.client.base.mixin.ToggleStyleMixin;
38+
import gwt.material.design.client.constants.IconType;
39+
import gwt.material.design.client.ui.MaterialIcon;
40+
import gwt.material.design.client.ui.MaterialLabel;
41+
import gwt.material.design.client.ui.MaterialPanel;
42+
43+
import java.util.ArrayList;
44+
import java.util.Arrays;
45+
import java.util.List;
46+
47+
import static gwt.material.design.jquery.client.api.JQuery.$;
48+
49+
public class MaterialBanner extends MaterialWidget implements HasOpenClose, HasBannerHandlers {
50+
51+
private final MaterialIcon icon;
52+
private final MaterialLabel messageLabel;
53+
private final MaterialPanel actions;
54+
private int offsetTop = 0;
55+
private int durationInMillis = 300;
56+
private List<Element> targetPushElements;
57+
58+
private ToggleStyleMixin<Widget> openMixin;
59+
60+
static {
61+
if (MaterialAddins.isDebug()) {
62+
MaterialDesignBase.injectCss(MaterialBannerDebugClientBundle.INSTANCE.bannerDebugCss());
63+
} else {
64+
MaterialDesignBase.injectCss(MaterialBannerClientBundle.INSTANCE.bannerCss());
65+
}
66+
}
67+
68+
public MaterialBanner() {
69+
super(Document.get().createDivElement(), "banner");
70+
71+
icon = new MaterialIcon();
72+
icon.setVisible(false);
73+
icon.addStyleName("banner-icon");
74+
75+
messageLabel = new MaterialLabel();
76+
messageLabel.addStyleName("message");
77+
78+
actions = new MaterialPanel();
79+
actions.addStyleName("actions");
80+
81+
targetPushElements = new ArrayList<>();
82+
}
83+
84+
@Override
85+
protected void onLoad() {
86+
super.onLoad();
87+
88+
add(icon);
89+
add(messageLabel);
90+
add(actions);
91+
92+
close();
93+
94+
AddinsDarkThemeReloader.get().reload(MaterialBannerDarkTheme.class);
95+
}
96+
97+
@Override
98+
public void add(Widget child) {
99+
if (child instanceof MaterialBannerActions) {
100+
actions.add(child);
101+
} else {
102+
super.add(child);
103+
}
104+
}
105+
106+
@Override
107+
public boolean isOpen() {
108+
return false;
109+
}
110+
111+
@Override
112+
public void open() {
113+
getOpenMixin().setOn(true);
114+
setTop(offsetTop);
115+
pushTargetElements(getOuterHeight());
116+
OpenEvent.fire(this, getMessage());
117+
}
118+
119+
public void open(Element... targetElements) {
120+
setTargetPushElements(Arrays.asList(targetElements));
121+
open();
122+
}
123+
124+
@Override
125+
public void close() {
126+
getOpenMixin().setOn(false);
127+
setTop(-getOuterHeight());
128+
pushTargetElements(0);
129+
CloseEvent.fire(this, getMessage());
130+
}
131+
132+
protected void pushTargetElements(int translateY) {
133+
$(getElement()).css("transition", "all " + durationInMillis + "ms ease");
134+
for (Element element : targetPushElements) {
135+
$(element).css("transition", "all " + durationInMillis + "ms ease");
136+
$(element).css("transform", "translateY(" + translateY + "px)");
137+
}
138+
}
139+
140+
public int getDurationInMillis() {
141+
return durationInMillis;
142+
}
143+
144+
public void setDurationInMillis(int durationInMillis) {
145+
this.durationInMillis = durationInMillis;
146+
}
147+
148+
public String getMessage() {
149+
return messageLabel.getText();
150+
}
151+
152+
public void setMessage(String message) {
153+
if (message != null && !message.isEmpty()) {
154+
messageLabel.setText(message);
155+
} else {
156+
messageLabel.setText("");
157+
}
158+
}
159+
160+
public IconType getIconType() {
161+
return icon.getIconType();
162+
}
163+
164+
public void setIconType(IconType iconType) {
165+
if (iconType != null) {
166+
icon.setIconType(iconType);
167+
icon.setVisible(true);
168+
} else {
169+
icon.setVisible(false);
170+
}
171+
}
172+
173+
public MaterialIcon getIcon() {
174+
return icon;
175+
}
176+
177+
public MaterialLabel getMessageLabel() {
178+
return messageLabel;
179+
}
180+
181+
public List<Element> getTargetPushElements() {
182+
return targetPushElements;
183+
}
184+
185+
public void setTargetPushElements(List<Element> targetPushElements) {
186+
this.targetPushElements = targetPushElements;
187+
}
188+
189+
public int getOffsetTop() {
190+
return offsetTop;
191+
}
192+
193+
public void setOffsetTop(int offsetTop) {
194+
this.offsetTop = offsetTop;
195+
}
196+
197+
public int getOuterHeight() {
198+
return $(getElement()).outerHeight(true);
199+
}
200+
201+
public ToggleStyleMixin<Widget> getOpenMixin() {
202+
if (openMixin == null) {
203+
openMixin = new ToggleStyleMixin<>(RootPanel.get(), "banner-open");
204+
}
205+
return openMixin;
206+
}
207+
208+
@Override
209+
public HandlerRegistration addCloseHandler(CloseHandler handler) {
210+
return addHandler(handler, CloseEvent.getType());
211+
}
212+
213+
@Override
214+
public HandlerRegistration addOpenHandler(OpenHandler handler) {
215+
return addHandler(handler, OpenEvent.getType());
216+
}
217+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2021 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.addins.client.banner;
21+
22+
import gwt.material.design.client.ui.MaterialPanel;
23+
24+
public class MaterialBannerActions extends MaterialPanel {
25+
26+
public MaterialBannerActions() {
27+
super();
28+
}
29+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2017 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.addins.client.banner;
21+
22+
import com.google.gwt.core.client.GWT;
23+
import com.google.gwt.resources.client.ClientBundle;
24+
import com.google.gwt.resources.client.TextResource;
25+
26+
/**
27+
* Client Bundle for Avatar component
28+
*
29+
* @author kevzlou7979
30+
*/
31+
public interface MaterialBannerClientBundle extends ClientBundle {
32+
33+
MaterialBannerClientBundle INSTANCE = GWT.create(MaterialBannerClientBundle.class);
34+
35+
@Source("resources/css/banner.min.css")
36+
TextResource bannerCss();
37+
38+
@Source("resources/css/banner-dark.min.css")
39+
TextResource bannerDarkCss();
40+
}

0 commit comments

Comments
 (0)