Skip to content

Commit d96b971

Browse files
authored
Merge pull request #1035 from GwtMaterialDesign/release_2.7.0
Release 2.7.0
2 parents aef7a8a + 21384c4 commit d96b971

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2241
-48
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cache:
88
- $HOME/.m2
99
before_install:
1010
# install the gwt-material-jquery because it will depends on built in jquery
11-
- git clone -b release_2.6.1 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
11+
- git clone -b release_2.7.0 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
1212
- cd gwt-material-jquery
1313
- mvn install -DskipTests=true -DdryRun=true
1414
- cd ..

.utility/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -ev
3-
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.6.1" ]; then
3+
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.7.0" ]; then
44
echo "<settings><servers><server><id>ossrh</id><username>\${env.OSSRH_USER}</username><password>\${env.OSSRH_PASS}</password></server></servers></settings>" > ~/settings.xml
55
mvn deploy -DskipTests --settings ~/settings.xml
66
fi

README.md

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

77
<br/>
88

9+
910
## Migration 2.0 -> 2.1
1011
- [Mojo to TBroyer](https://github.com/GwtMaterialDesign/gwt-material/wiki/Migrating-from-Mojo-GWT-Maven-Plugin-to-TBroyer)
1112
- [PWA Support](https://github.com/GwtMaterialDesign/gwt-material/wiki/PWA-:-Service-Worker-Automation)
@@ -18,22 +19,21 @@
1819
Support documentation can be found [here](https://github.com/GwtMaterialDesign/gwt-material/wiki) <br/>
1920
We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs" > Java Docs </a> for developers
2021

21-
2222
## Maven
23-
### Current Version 2.6.1
23+
### Current Version 2.7.0
2424
```xml
2525
<dependency>
2626
<groupId>com.github.gwtmaterialdesign</groupId>
2727
<artifactId>gwt-material</artifactId>
28-
<version>2.6.1</version>
28+
<version>2.7.0</version>
2929
</dependency>
3030
```
31-
### Snapshot Version 2.6.1-SNAPSHOT
31+
### Snapshot Version 2.8.0-SNAPSHOT
3232
```xml
3333
<dependency>
3434
<groupId>com.github.gwtmaterialdesign</groupId>
3535
<artifactId>gwt-material</artifactId>
36-
<version>2.6.1-SNAPSHOT</version>
36+
<version>2.8.0-SNAPSHOT</version>
3737
</dependency>
3838
```
3939

gwt-material/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>gwt-material-parent</artifactId>
66
<groupId>com.github.gwtmaterialdesign</groupId>
7-
<version>2.6.1</version>
7+
<version>2.7.0</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010

gwt-material/src/main/java/gwt/material/design/client/base/AbstractValueWidget.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.gwt.event.shared.HandlerRegistration;
2929
import com.google.gwt.user.client.ui.HasValue;
3030
import com.google.gwt.user.client.ui.UIObject;
31+
import com.google.gwt.user.client.ui.Widget;
3132
import gwt.material.design.client.base.error.ErrorHandler;
3233
import gwt.material.design.client.base.error.ErrorHandlerType;
3334
import gwt.material.design.client.base.error.HasErrorHandler;
@@ -44,7 +45,7 @@
4445

4546
import java.util.List;
4647

47-
public abstract class AbstractValueWidget<V> extends MaterialWidget implements HasValue<V>, LeafValueEditor<V>,
48+
public abstract class AbstractValueWidget<V> extends MaterialWidget implements HasResetField, HasValue<V>, LeafValueEditor<V>,
4849
HasEditorErrors<V>, HasErrorHandler, HasStatusText, HasValidators<V>, HasRequiredField, HasClearOnKeyUp, HasCopyCommand {
4950

5051
private V initialValue;
@@ -55,6 +56,7 @@ public abstract class AbstractValueWidget<V> extends MaterialWidget implements H
5556
private StatusTextMixin<AbstractValueWidget, ?> statusTextMixin;
5657
private ErrorHandlerMixin<V> errorHandlerMixin;
5758
private RequiredFieldMixin<AbstractValueWidget, UIObject> requiredFieldMixin;
59+
private ResetFieldMixin<Widget> resetFieldMixin;
5860
private ClearOnKeyUpMixin<AbstractValueWidget, MaterialLabel> clearOnKeyUpMixin;
5961
private HandlerRegistration attachHandler, blurHandler;
6062
protected CopyCommandMixin<AbstractValueWidget> copyCommandMixin;
@@ -151,6 +153,22 @@ public boolean isSuccessTextVisible() {
151153
return getStatusTextMixin().isSuccessTextVisible();
152154
}
153155

156+
@Override
157+
public void resetFields() {
158+
getResetFieldMixin().resetFields();
159+
getValidatorMixin().reset();
160+
}
161+
162+
@Override
163+
public void setAllowResettingFields(boolean allowResettingFields) {
164+
getResetFieldMixin().setAllowResettingFields(allowResettingFields);
165+
}
166+
167+
@Override
168+
public boolean isAllowResettingFields() {
169+
return getResetFieldMixin().isAllowResettingFields();
170+
}
171+
154172
@Override
155173
public void setStatusDisplayType(StatusDisplayType displayType) {
156174
getStatusTextMixin().setStatusDisplayType(displayType);
@@ -432,4 +450,11 @@ protected CopyCommandMixin<AbstractValueWidget> getCopyCommandMixin() {
432450
}
433451
return copyCommandMixin;
434452
}
453+
454+
public ResetFieldMixin<Widget> getResetFieldMixin() {
455+
if (resetFieldMixin == null) {
456+
resetFieldMixin = new ResetFieldMixin<>(this);
457+
}
458+
return resetFieldMixin;
459+
}
435460
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2022 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.client.base;
21+
22+
import com.google.gwt.dom.client.Style;
23+
import com.google.gwt.event.dom.client.ClickEvent;
24+
import com.google.gwt.event.shared.HandlerRegistration;
25+
import com.google.gwt.user.client.ui.Widget;
26+
import gwt.material.design.client.base.mixin.ToggleStyleMixin;
27+
import gwt.material.design.client.constants.Display;
28+
import gwt.material.design.client.constants.IconType;
29+
import gwt.material.design.client.ui.*;
30+
31+
import java.util.List;
32+
33+
import static gwt.material.design.client.js.JsMaterialElement.$;
34+
35+
public class DefaultMoreChipHandler implements MoreChipHandler {
36+
37+
protected int visibleChipsSize = 0;
38+
protected MaterialLink more = new MaterialLink();
39+
protected String localizedMoreText = "Show {0} more items";
40+
protected MaterialChipContainer container;
41+
protected ToggleStyleMixin<MaterialChipContainer> toggleStyleMixin;
42+
protected HandlerRegistration handlerRegistration;
43+
protected MaterialLabel collapseLabel = new MaterialLabel();
44+
protected MaterialIcon collapseIcon = new MaterialIcon(IconType.KEYBOARD_ARROW_UP);
45+
protected ToggleStyleMixin<Widget> collapsibleMixin;
46+
protected ToggleStyleMixin<Widget> collapseMixin;
47+
48+
public DefaultMoreChipHandler(MaterialChipContainer container) {
49+
this.container = container;
50+
more.setDisplay(Display.BLOCK);
51+
more.setMarginLeft(4);
52+
more.setMarginTop(12);
53+
}
54+
55+
@Override
56+
public void setVisibleChipsSize(int visibleChipsSize) {
57+
this.visibleChipsSize = visibleChipsSize;
58+
}
59+
60+
@Override
61+
public void load() {
62+
showHiddenChips(false);
63+
collapseIcon.addStyleName("collapse");
64+
collapseLabel.addStyleName("collapse-label");
65+
collapseIcon.addClickHandler(this::toggle);
66+
collapseLabel.addClickHandler(this::toggle);
67+
if (!collapseIcon.isAttached()) {
68+
collapseIcon.setVisible(false);
69+
collapseLabel.setVisible(false);
70+
container.add(collapseIcon);
71+
container.add(collapseLabel);
72+
}
73+
}
74+
75+
public void collapse() {
76+
getCollapseMixin().setOn(true);
77+
}
78+
79+
public void expand() {
80+
getCollapseMixin().setOn(false);
81+
}
82+
83+
public void setCollapsible(boolean enableCollapsible) {
84+
getCollapsibleMixin().setOn(enableCollapsible);
85+
}
86+
87+
protected void toggle(ClickEvent event) {
88+
if (!getCollapseMixin().isOn()) {
89+
collapse();
90+
} else {
91+
expand();
92+
}
93+
event.stopPropagation();
94+
event.preventDefault();
95+
}
96+
97+
@Override
98+
public void reload() {
99+
showHiddenChips(false);
100+
}
101+
102+
@Override
103+
public void update(MaterialChip chip) {
104+
if (getCollapseMixin().isOn()) {
105+
MaterialIcon icon = chip.getIcon();
106+
icon.registerHandler(icon.addClickHandler(clickEvent -> updateCollapseLabel(chip)));
107+
updateCollapseLabel(chip);
108+
}
109+
}
110+
111+
protected void updateCollapseLabel(MaterialChip chip) {
112+
int length = $(container.getElement()).find(".chip").length();
113+
collapseIcon.setVisible(length > 0);
114+
collapseLabel.setVisible(length > 0);
115+
collapseLabel.setText(length + "");
116+
}
117+
118+
public void showHiddenChips(boolean showHiddenChips) {
119+
if (visibleChipsSize > 0) {
120+
if (handlerRegistration == null) {
121+
handlerRegistration = more.addClickHandler(clickEvent -> showHiddenChips(!getToggleStyleMixin().isOn()));
122+
}
123+
if (!more.isAttached()) {
124+
container.add(more);
125+
}
126+
List<MaterialChip> chipList = container.getChipList();
127+
int hiddenChipsSize = chipList.size() - visibleChipsSize;
128+
for (MaterialChip widgets : chipList) {
129+
if (showHiddenChips) {
130+
$(widgets.getElement()).css("display", "block");
131+
} else {
132+
if (chipList.indexOf(widgets) > visibleChipsSize) {
133+
$(widgets.getElement()).css("display", "none");
134+
}
135+
}
136+
}
137+
138+
if (showHiddenChips) {
139+
more.setVisibility(Style.Visibility.HIDDEN);
140+
} else {
141+
more.setVisibility(Style.Visibility.VISIBLE);
142+
more.setText(localizedMoreText.replace("{0}", hiddenChipsSize + ""));
143+
}
144+
}
145+
}
146+
147+
public ToggleStyleMixin<Widget> getCollapseMixin() {
148+
if (collapseMixin == null) {
149+
collapseMixin = new ToggleStyleMixin<>(container, "collapse");
150+
}
151+
return collapseMixin;
152+
}
153+
154+
public ToggleStyleMixin<Widget> getCollapsibleMixin() {
155+
if (collapsibleMixin == null) {
156+
collapsibleMixin = new ToggleStyleMixin<>(container, "enable-collapsible");
157+
}
158+
return collapsibleMixin;
159+
}
160+
161+
public ToggleStyleMixin<MaterialChipContainer> getToggleStyleMixin() {
162+
if (toggleStyleMixin == null) {
163+
toggleStyleMixin = new ToggleStyleMixin<>(container, "expanded");
164+
}
165+
return toggleStyleMixin;
166+
}
167+
}

gwt-material/src/main/java/gwt/material/design/client/base/MaterialWidget.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import gwt.material.design.client.events.DropEvent;
4040
import gwt.material.design.client.events.*;
4141
import gwt.material.design.client.events.OrientationChangeEvent.OrientationChangeHandler;
42+
import gwt.material.design.client.theme.GlobalThemeConfig;
4243
import gwt.material.design.client.theme.ThemeManager;
4344
import gwt.material.design.jquery.client.api.JQuery;
4445
import gwt.material.design.jquery.client.api.JQueryElement;
@@ -58,6 +59,7 @@ public class MaterialWidget extends ComplexPanel implements HasId, HasEnabled, H
5859

5960
private static JQueryElement window = null;
6061
private static JQueryElement body = null;
62+
private static GlobalThemeConfig themeConfig;
6163

6264
public static JQueryElement window() {
6365
if (window == null) {
@@ -1960,4 +1962,11 @@ public void setTranslationKey(String key) {
19601962
public String getTranslationKey() {
19611963
return translationKey;
19621964
}
1965+
1966+
public static GlobalThemeConfig getGlobalTheme() {
1967+
if (themeConfig == null) {
1968+
themeConfig = new GlobalThemeConfig();
1969+
}
1970+
return themeConfig;
1971+
}
19631972
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2022 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.client.base;
21+
22+
import gwt.material.design.client.ui.MaterialChip;
23+
24+
public interface MoreChipHandler {
25+
26+
void setVisibleChipsSize(int visibleChipsSize);
27+
28+
void load();
29+
30+
void collapse();
31+
32+
void expand();
33+
34+
void setCollapsible(boolean enableCollapsible);
35+
36+
void reload();
37+
38+
void update(MaterialChip chip);
39+
}

gwt-material/src/main/java/gwt/material/design/client/base/mixin/ResetFieldMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public void resetFields() {
5757
protected void reset(Widget parent) {
5858
if (parent instanceof HasWidgets) {
5959
for (Widget child : (HasWidgets) parent) {
60-
if (child instanceof AbstractValueWidget) {
61-
((AbstractValueWidget) child).reset();
60+
if (child instanceof HasResetField) {
61+
((HasResetField) child).resetFields();
6262
}
6363
else if (propagateToChildren) {
6464
reset(child);

0 commit comments

Comments
 (0)