Skip to content

Commit bf25eec

Browse files
authored
Merge pull request #431 from GwtMaterialDesign/release_2.5.0_rc1
Release 2.5.0 rc1
2 parents 807ef52 + 86954bb commit bf25eec

File tree

36 files changed

+810
-163
lines changed

36 files changed

+810
-163
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ cache:
88
- $HOME/.m2
99
before_install:
1010
# install the gwt-material-jquery library before we build the demo
11-
- git clone -b release_2.4.2 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
11+
- git clone -b release_2.5.0_rc1 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
1212
- cd gwt-material-jquery
1313
- mvn install -DskipTests=true -DdryRun=true
1414
- cd ..
1515
# install the gwt-material library before we build the demo
16-
- git clone -b release_2.4.2 https://github.com/GwtMaterialDesign/gwt-material.git
16+
- git clone -b release_2.5.0_rc1 https://github.com/GwtMaterialDesign/gwt-material.git
1717
- cd gwt-material
1818
- mvn install -DskipTests=true -DdryRun=true
1919
- cd ..
2020
# install the gwt-material-table library before we build the demo
21-
- git clone -b release_2.4.2 https://github.com/GwtMaterialDesign/gwt-material-table.git
21+
- git clone -b release_2.5.0_rc1 https://github.com/GwtMaterialDesign/gwt-material-table.git
2222
- cd gwt-material-table
2323
- mvn install -DskipTests=true -DdryRun=true
2424
- 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.4.2" ]; then
3+
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.5.0_rc1" ]; 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

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

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

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.4.2</version>
8+
<version>2.5.0-rc1</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.4.2</tag>
27+
<tag>v2.5.0-rc1</tag>
2828
</scm>
2929

3030
<licenses>

src/main/java/gwt/material/design/addins/client/combobox/MaterialComboBox.java

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
*/
100100
//@formatter:on
101101
public class MaterialComboBox<T> extends AbstractValueWidget<List<T>> implements JsLoader, HasPlaceholder,
102-
HasComboBoxHandlers<T>, HasReadOnly, HasFieldTypes, IsAsyncWidget<MaterialComboBox, List<T>>, HasLabel, HasOpenClose {
102+
HasComboBoxHandlers<T>, HasReadOnly, HasFieldTypes, IsAsyncWidget<MaterialComboBox, List<T>>, HasLabel, HasOpenClose, HasSingleValue<T> {
103103

104104
static {
105105
if (MaterialAddins.isDebug()) {
@@ -583,17 +583,6 @@ public List<T> getSelectedValue() {
583583
return getValue();
584584
}
585585

586-
/**
587-
* Only return a single value even if multi support is activate.
588-
*/
589-
public T getSingleValue() {
590-
List<T> values = getSelectedValue();
591-
if (values != null && !values.isEmpty()) {
592-
return values.get(0);
593-
}
594-
return null;
595-
}
596-
597586
@Override
598587
public void setValue(List<T> value) {
599588
setValue(value, false);
@@ -603,31 +592,16 @@ public void setValue(List<T> value) {
603592
* Set the selected value using a single item, generally used
604593
* in single selection mode.
605594
*/
595+
@Override
606596
public void setSingleValue(T value) {
607597
setValue(Collections.singletonList(value));
608598
}
609599

610-
@Override
611-
public void setValue(List<T> values, boolean fireEvents) {
612-
if (values == null) {
613-
reset();
614-
615-
if (fireEvents) {
616-
ValueChangeEvent.fire(this, null);
617-
}
618-
} else if (!isMultiple()) {
619-
if (!values.isEmpty()) {
620-
setSingleValue(values.get(0), fireEvents);
621-
}
622-
} else {
623-
setValues(values, fireEvents);
624-
}
625-
}
626-
627600
/**
628601
* Set the selected value using a single item, generally used
629602
* in single selection mode.
630603
*/
604+
@Override
631605
public void setSingleValue(T value, boolean fireEvents) {
632606
int index = this.values.indexOf(value);
633607
if (index < 0 && value instanceof String) {
@@ -644,6 +618,35 @@ public void setSingleValue(T value, boolean fireEvents) {
644618
}
645619
}
646620

621+
/**
622+
* Only return a single value even if multi support is activate.
623+
*/
624+
@Override
625+
public T getSingleValue() {
626+
List<T> values = getSelectedValue();
627+
if (values != null && !values.isEmpty()) {
628+
return values.get(0);
629+
}
630+
return null;
631+
}
632+
633+
@Override
634+
public void setValue(List<T> values, boolean fireEvents) {
635+
if (values == null) {
636+
reset();
637+
638+
if (fireEvents) {
639+
ValueChangeEvent.fire(this, null);
640+
}
641+
} else if (!isMultiple()) {
642+
if (!values.isEmpty()) {
643+
setSingleValue(values.get(0), fireEvents);
644+
}
645+
} else {
646+
setValues(values, fireEvents);
647+
}
648+
}
649+
647650
// TODO: Optimize performance (maybe use a map)
648651
public T getValueByString(String key) {
649652
for (T value : values) {
@@ -1222,6 +1225,10 @@ public AsyncWidgetCallback<MaterialComboBox, List<T>> getAsyncCallback() {
12221225
return getAsyncWidgetMixin().getAsyncCallback();
12231226
}
12241227

1228+
public List<T> getOptions() {
1229+
return values;
1230+
}
1231+
12251232
@Override
12261233
public void setAsyncDisplayLoader(AsyncDisplayLoader displayLoader) {
12271234
getAsyncWidgetMixin().setAsyncDisplayLoader(displayLoader);
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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.iconmorph;
21+
22+
import com.google.gwt.event.shared.EventHandler;
23+
import com.google.gwt.event.shared.GwtEvent;
24+
import com.google.gwt.event.shared.HasHandlers;
25+
26+
public class IconMorphedEvent extends GwtEvent<IconMorphedEvent.IconMorphedHandler> {
27+
28+
protected boolean morphed;
29+
30+
public IconMorphedEvent(boolean morphed) {
31+
this.morphed = morphed;
32+
}
33+
34+
public interface IconMorphedHandler extends EventHandler {
35+
void onIconMorphed(IconMorphedEvent event);
36+
}
37+
38+
public static final Type<IconMorphedHandler> TYPE = new Type<>();
39+
40+
public static void fire(HasHandlers source, boolean morphed) {
41+
source.fireEvent(new IconMorphedEvent(morphed));
42+
}
43+
44+
@Override
45+
public Type<IconMorphedHandler> getAssociatedType() {
46+
return TYPE;
47+
}
48+
49+
@Override
50+
protected void dispatch(IconMorphedHandler handler) {
51+
handler.onIconMorphed(this);
52+
}
53+
54+
public boolean isMorphed() {
55+
return morphed;
56+
}
57+
58+
public void setMorphed(boolean morphed) {
59+
this.morphed = morphed;
60+
}
61+
}

src/main/java/gwt/material/design/addins/client/iconmorph/MaterialIconMorph.java

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package gwt.material.design.addins.client.iconmorph;
2121

2222
import com.google.gwt.dom.client.Document;
23+
import com.google.gwt.event.shared.HandlerRegistration;
2324
import gwt.material.design.addins.client.MaterialAddins;
2425
import gwt.material.design.addins.client.base.constants.AddinsCssName;
2526
import gwt.material.design.client.MaterialDesignBase;
@@ -30,6 +31,8 @@
3031
import gwt.material.design.client.constants.IconSize;
3132
import gwt.material.design.client.ui.MaterialIcon;
3233

34+
import static gwt.material.design.jquery.client.api.JQuery.$;
35+
3336
//@formatter:off
3437

3538
/**
@@ -67,30 +70,76 @@ public class MaterialIconMorph extends MaterialWidget implements HasDurationTran
6770
}
6871
}
6972

70-
private CssNameMixin<MaterialIconMorph, IconSize> sizeMixin;
71-
private MaterialIcon source, target;
73+
protected static final String ICON_MORPH = "icon-morph";
74+
protected static final String MORPHED = "morphed";
75+
protected CssNameMixin<MaterialIconMorph, IconSize> sizeMixin;
76+
protected String customSize;
77+
protected MaterialIcon source, target;
7278

7379
public MaterialIconMorph() {
74-
super(Document.get().createDivElement(), AddinsCssName.ANIM_CONTAINER);
75-
getElement().setAttribute("onclick", "this.classList.toggle('morphed')");
80+
super(Document.get().createDivElement(), AddinsCssName.ANIM_CONTAINER, ICON_MORPH);
7681
}
7782

7883
@Override
7984
protected void onLoad() {
8085
super.onLoad();
8186

82-
if (getWidgetCount() >= 2) {
83-
source = (MaterialIcon) getWidget(0);
87+
registerHandler(addClickHandler(event -> {
88+
$(getElement()).toggleClass(MORPHED);
89+
IconMorphedEvent.fire(this, getElement().hasClassName(MORPHED));
90+
}));
91+
92+
// Check if we add the source and target icons thru ui binder
93+
if (source == null && target == null) {
94+
if (getWidgetCount() == 2) {
95+
source = (MaterialIcon) getWidget(0);
96+
target = (MaterialIcon) getWidget(1);
97+
}
98+
}
99+
100+
if (source != null) {
84101
source.addStyleName(AddinsCssName.ICONS + " " + AddinsCssName.SOURCE);
85-
target = (MaterialIcon) getWidget(1);
102+
if (!source.isAttached()) add(source);
103+
}
104+
if (target != null) {
86105
target.addStyleName(AddinsCssName.ICONS + " " + AddinsCssName.TARGET);
106+
if (!target.isAttached()) add(target);
107+
}
108+
109+
applyCustomSize(customSize);
110+
}
111+
112+
protected void applyCustomSize(String customSize) {
113+
if (customSize != null) {
114+
setWidth(customSize);
115+
setHeight(customSize);
116+
117+
if (source != null) {
118+
source.setWidth(customSize);
119+
source.setHeight(customSize);
120+
source.setFontSize(customSize);
121+
}
122+
123+
if (target != null) {
124+
target.setWidth(customSize);
125+
target.setHeight(customSize);
126+
target.setFontSize(customSize);
127+
}
87128
}
88129
}
89130

131+
public void reset() {
132+
getElement().removeClassName(MORPHED);
133+
}
134+
90135
public void setIconSize(IconSize size) {
91136
getSizeMixin().setCssName(size);
92137
}
93138

139+
public void setCustomSize(String customSize) {
140+
this.customSize = customSize;
141+
}
142+
94143
@Override
95144
public void setDuration(int duration) {
96145
setTransition(new TransitionConfig(duration, "all"));
@@ -101,6 +150,14 @@ public int getDuration() {
101150
return 0;
102151
}
103152

153+
public void setSource(MaterialIcon source) {
154+
this.source = source;
155+
}
156+
157+
public void setTarget(MaterialIcon target) {
158+
this.target = target;
159+
}
160+
104161
public MaterialIcon getSource() {
105162
return source;
106163
}
@@ -115,4 +172,8 @@ public CssNameMixin<MaterialIconMorph, IconSize> getSizeMixin() {
115172
}
116173
return sizeMixin;
117174
}
175+
176+
public HandlerRegistration addIconMorphedHandler(IconMorphedEvent.IconMorphedHandler handler) {
177+
return addHandler(handler, IconMorphedEvent.TYPE);
178+
}
118179
}

0 commit comments

Comments
 (0)