Skip to content

Commit

Permalink
Merge pull request #431 from GwtMaterialDesign/release_2.5.0_rc1
Browse files Browse the repository at this point in the history
Release 2.5.0 rc1
  • Loading branch information
kevzlou7979 authored Feb 24, 2021
2 parents 807ef52 + 86954bb commit bf25eec
Show file tree
Hide file tree
Showing 36 changed files with 810 additions and 163 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ cache:
- $HOME/.m2
before_install:
# install the gwt-material-jquery library before we build the demo
- git clone -b release_2.4.2 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
- git clone -b release_2.5.0_rc1 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
- cd gwt-material-jquery
- mvn install -DskipTests=true -DdryRun=true
- cd ..
# install the gwt-material library before we build the demo
- git clone -b release_2.4.2 https://github.com/GwtMaterialDesign/gwt-material.git
- git clone -b release_2.5.0_rc1 https://github.com/GwtMaterialDesign/gwt-material.git
- cd gwt-material
- mvn install -DskipTests=true -DdryRun=true
- cd ..
# install the gwt-material-table library before we build the demo
- git clone -b release_2.4.2 https://github.com/GwtMaterialDesign/gwt-material-table.git
- git clone -b release_2.5.0_rc1 https://github.com/GwtMaterialDesign/gwt-material-table.git
- cd gwt-material-table
- mvn install -DskipTests=true -DdryRun=true
- cd ..
Expand Down
2 changes: 1 addition & 1 deletion .utility/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -ev
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.4.2" ]; then
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.5.0_rc1" ]; then
echo "<settings><servers><server><id>ossrh</id><username>\${env.OSSRH_USER}</username><password>\${env.OSSRH_PASS}</password></server></servers></settings>" > ~/settings.xml
mvn deploy -DskipTests --settings ~/settings.xml
fi
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

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

## Current Version 2.4.2
## Current Version 2.5.0-rc1
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-addins</artifactId>
<version>2.4.2</version>
<version>2.5.0-rc1</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.4.2</version>
<version>2.5.0-rc1</version>
</parent>

<artifactId>gwt-material-addins</artifactId>
Expand All @@ -24,7 +24,7 @@
<connection>scm:git:git@github.com:GwtMaterialDesign/gwt-material-addins.git</connection>
<developerConnection>scm:git:git@github.com:GwtMaterialDesign/gwt-material-addins.git</developerConnection>
<url>http://github.com/GwtMaterialDesign/gwt-material-addins</url>
<tag>v2.4.2</tag>
<tag>v2.5.0-rc1</tag>
</scm>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
*/
//@formatter:on
public class MaterialComboBox<T> extends AbstractValueWidget<List<T>> implements JsLoader, HasPlaceholder,
HasComboBoxHandlers<T>, HasReadOnly, HasFieldTypes, IsAsyncWidget<MaterialComboBox, List<T>>, HasLabel, HasOpenClose {
HasComboBoxHandlers<T>, HasReadOnly, HasFieldTypes, IsAsyncWidget<MaterialComboBox, List<T>>, HasLabel, HasOpenClose, HasSingleValue<T> {

static {
if (MaterialAddins.isDebug()) {
Expand Down Expand Up @@ -583,17 +583,6 @@ public List<T> getSelectedValue() {
return getValue();
}

/**
* Only return a single value even if multi support is activate.
*/
public T getSingleValue() {
List<T> values = getSelectedValue();
if (values != null && !values.isEmpty()) {
return values.get(0);
}
return null;
}

@Override
public void setValue(List<T> value) {
setValue(value, false);
Expand All @@ -603,31 +592,16 @@ public void setValue(List<T> value) {
* Set the selected value using a single item, generally used
* in single selection mode.
*/
@Override
public void setSingleValue(T value) {
setValue(Collections.singletonList(value));
}

@Override
public void setValue(List<T> values, boolean fireEvents) {
if (values == null) {
reset();

if (fireEvents) {
ValueChangeEvent.fire(this, null);
}
} else if (!isMultiple()) {
if (!values.isEmpty()) {
setSingleValue(values.get(0), fireEvents);
}
} else {
setValues(values, fireEvents);
}
}

/**
* Set the selected value using a single item, generally used
* in single selection mode.
*/
@Override
public void setSingleValue(T value, boolean fireEvents) {
int index = this.values.indexOf(value);
if (index < 0 && value instanceof String) {
Expand All @@ -644,6 +618,35 @@ public void setSingleValue(T value, boolean fireEvents) {
}
}

/**
* Only return a single value even if multi support is activate.
*/
@Override
public T getSingleValue() {
List<T> values = getSelectedValue();
if (values != null && !values.isEmpty()) {
return values.get(0);
}
return null;
}

@Override
public void setValue(List<T> values, boolean fireEvents) {
if (values == null) {
reset();

if (fireEvents) {
ValueChangeEvent.fire(this, null);
}
} else if (!isMultiple()) {
if (!values.isEmpty()) {
setSingleValue(values.get(0), fireEvents);
}
} else {
setValues(values, fireEvents);
}
}

// TODO: Optimize performance (maybe use a map)
public T getValueByString(String key) {
for (T value : values) {
Expand Down Expand Up @@ -1222,6 +1225,10 @@ public AsyncWidgetCallback<MaterialComboBox, List<T>> getAsyncCallback() {
return getAsyncWidgetMixin().getAsyncCallback();
}

public List<T> getOptions() {
return values;
}

@Override
public void setAsyncDisplayLoader(AsyncDisplayLoader displayLoader) {
getAsyncWidgetMixin().setAsyncDisplayLoader(displayLoader);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2017 GwtMaterialDesign
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package gwt.material.design.addins.client.iconmorph;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HasHandlers;

public class IconMorphedEvent extends GwtEvent<IconMorphedEvent.IconMorphedHandler> {

protected boolean morphed;

public IconMorphedEvent(boolean morphed) {
this.morphed = morphed;
}

public interface IconMorphedHandler extends EventHandler {
void onIconMorphed(IconMorphedEvent event);
}

public static final Type<IconMorphedHandler> TYPE = new Type<>();

public static void fire(HasHandlers source, boolean morphed) {
source.fireEvent(new IconMorphedEvent(morphed));
}

@Override
public Type<IconMorphedHandler> getAssociatedType() {
return TYPE;
}

@Override
protected void dispatch(IconMorphedHandler handler) {
handler.onIconMorphed(this);
}

public boolean isMorphed() {
return morphed;
}

public void setMorphed(boolean morphed) {
this.morphed = morphed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package gwt.material.design.addins.client.iconmorph;

import com.google.gwt.dom.client.Document;
import com.google.gwt.event.shared.HandlerRegistration;
import gwt.material.design.addins.client.MaterialAddins;
import gwt.material.design.addins.client.base.constants.AddinsCssName;
import gwt.material.design.client.MaterialDesignBase;
Expand All @@ -30,6 +31,8 @@
import gwt.material.design.client.constants.IconSize;
import gwt.material.design.client.ui.MaterialIcon;

import static gwt.material.design.jquery.client.api.JQuery.$;

//@formatter:off

/**
Expand Down Expand Up @@ -67,30 +70,76 @@ public class MaterialIconMorph extends MaterialWidget implements HasDurationTran
}
}

private CssNameMixin<MaterialIconMorph, IconSize> sizeMixin;
private MaterialIcon source, target;
protected static final String ICON_MORPH = "icon-morph";
protected static final String MORPHED = "morphed";
protected CssNameMixin<MaterialIconMorph, IconSize> sizeMixin;
protected String customSize;
protected MaterialIcon source, target;

public MaterialIconMorph() {
super(Document.get().createDivElement(), AddinsCssName.ANIM_CONTAINER);
getElement().setAttribute("onclick", "this.classList.toggle('morphed')");
super(Document.get().createDivElement(), AddinsCssName.ANIM_CONTAINER, ICON_MORPH);
}

@Override
protected void onLoad() {
super.onLoad();

if (getWidgetCount() >= 2) {
source = (MaterialIcon) getWidget(0);
registerHandler(addClickHandler(event -> {
$(getElement()).toggleClass(MORPHED);
IconMorphedEvent.fire(this, getElement().hasClassName(MORPHED));
}));

// Check if we add the source and target icons thru ui binder
if (source == null && target == null) {
if (getWidgetCount() == 2) {
source = (MaterialIcon) getWidget(0);
target = (MaterialIcon) getWidget(1);
}
}

if (source != null) {
source.addStyleName(AddinsCssName.ICONS + " " + AddinsCssName.SOURCE);
target = (MaterialIcon) getWidget(1);
if (!source.isAttached()) add(source);
}
if (target != null) {
target.addStyleName(AddinsCssName.ICONS + " " + AddinsCssName.TARGET);
if (!target.isAttached()) add(target);
}

applyCustomSize(customSize);
}

protected void applyCustomSize(String customSize) {
if (customSize != null) {
setWidth(customSize);
setHeight(customSize);

if (source != null) {
source.setWidth(customSize);
source.setHeight(customSize);
source.setFontSize(customSize);
}

if (target != null) {
target.setWidth(customSize);
target.setHeight(customSize);
target.setFontSize(customSize);
}
}
}

public void reset() {
getElement().removeClassName(MORPHED);
}

public void setIconSize(IconSize size) {
getSizeMixin().setCssName(size);
}

public void setCustomSize(String customSize) {
this.customSize = customSize;
}

@Override
public void setDuration(int duration) {
setTransition(new TransitionConfig(duration, "all"));
Expand All @@ -101,6 +150,14 @@ public int getDuration() {
return 0;
}

public void setSource(MaterialIcon source) {
this.source = source;
}

public void setTarget(MaterialIcon target) {
this.target = target;
}

public MaterialIcon getSource() {
return source;
}
Expand All @@ -115,4 +172,8 @@ public CssNameMixin<MaterialIconMorph, IconSize> getSizeMixin() {
}
return sizeMixin;
}

public HandlerRegistration addIconMorphedHandler(IconMorphedEvent.IconMorphedHandler handler) {
return addHandler(handler, IconMorphedEvent.TYPE);
}
}
Loading

0 comments on commit bf25eec

Please sign in to comment.