Skip to content

Commit

Permalink
Merge pull request #1035 from GwtMaterialDesign/release_2.7.0
Browse files Browse the repository at this point in the history
Release 2.7.0
  • Loading branch information
kevzlou7979 committed May 8, 2023
2 parents aef7a8a + 21384c4 commit d96b971
Show file tree
Hide file tree
Showing 49 changed files with 2,241 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -8,7 +8,7 @@ cache:
- $HOME/.m2
before_install:
# install the gwt-material-jquery because it will depends on built in jquery
- git clone -b release_2.6.1 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
- git clone -b release_2.7.0 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
- cd gwt-material-jquery
- mvn install -DskipTests=true -DdryRun=true
- cd ..
Expand Down
2 changes: 1 addition & 1 deletion .utility/deploy.sh
@@ -1,6 +1,6 @@
#!/bin/bash
set -ev
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.6.1" ]; then
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.7.0" ]; 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
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -6,6 +6,7 @@

<br/>


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


## Maven
### Current Version 2.6.1
### Current Version 2.7.0
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material</artifactId>
<version>2.6.1</version>
<version>2.7.0</version>
</dependency>
```
### Snapshot Version 2.6.1-SNAPSHOT
### Snapshot Version 2.8.0-SNAPSHOT
```xml
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>2.8.0-SNAPSHOT</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion gwt-material/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.6.1</version>
<version>2.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Expand Up @@ -28,6 +28,7 @@
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.UIObject;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.base.error.ErrorHandler;
import gwt.material.design.client.base.error.ErrorHandlerType;
import gwt.material.design.client.base.error.HasErrorHandler;
Expand All @@ -44,7 +45,7 @@

import java.util.List;

public abstract class AbstractValueWidget<V> extends MaterialWidget implements HasValue<V>, LeafValueEditor<V>,
public abstract class AbstractValueWidget<V> extends MaterialWidget implements HasResetField, HasValue<V>, LeafValueEditor<V>,
HasEditorErrors<V>, HasErrorHandler, HasStatusText, HasValidators<V>, HasRequiredField, HasClearOnKeyUp, HasCopyCommand {

private V initialValue;
Expand All @@ -55,6 +56,7 @@ public abstract class AbstractValueWidget<V> extends MaterialWidget implements H
private StatusTextMixin<AbstractValueWidget, ?> statusTextMixin;
private ErrorHandlerMixin<V> errorHandlerMixin;
private RequiredFieldMixin<AbstractValueWidget, UIObject> requiredFieldMixin;
private ResetFieldMixin<Widget> resetFieldMixin;
private ClearOnKeyUpMixin<AbstractValueWidget, MaterialLabel> clearOnKeyUpMixin;
private HandlerRegistration attachHandler, blurHandler;
protected CopyCommandMixin<AbstractValueWidget> copyCommandMixin;
Expand Down Expand Up @@ -151,6 +153,22 @@ public boolean isSuccessTextVisible() {
return getStatusTextMixin().isSuccessTextVisible();
}

@Override
public void resetFields() {
getResetFieldMixin().resetFields();
getValidatorMixin().reset();
}

@Override
public void setAllowResettingFields(boolean allowResettingFields) {
getResetFieldMixin().setAllowResettingFields(allowResettingFields);
}

@Override
public boolean isAllowResettingFields() {
return getResetFieldMixin().isAllowResettingFields();
}

@Override
public void setStatusDisplayType(StatusDisplayType displayType) {
getStatusTextMixin().setStatusDisplayType(displayType);
Expand Down Expand Up @@ -432,4 +450,11 @@ protected CopyCommandMixin<AbstractValueWidget> getCopyCommandMixin() {
}
return copyCommandMixin;
}

public ResetFieldMixin<Widget> getResetFieldMixin() {
if (resetFieldMixin == null) {
resetFieldMixin = new ResetFieldMixin<>(this);
}
return resetFieldMixin;
}
}
@@ -0,0 +1,167 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2022 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.client.base;

import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.base.mixin.ToggleStyleMixin;
import gwt.material.design.client.constants.Display;
import gwt.material.design.client.constants.IconType;
import gwt.material.design.client.ui.*;

import java.util.List;

import static gwt.material.design.client.js.JsMaterialElement.$;

public class DefaultMoreChipHandler implements MoreChipHandler {

protected int visibleChipsSize = 0;
protected MaterialLink more = new MaterialLink();
protected String localizedMoreText = "Show {0} more items";
protected MaterialChipContainer container;
protected ToggleStyleMixin<MaterialChipContainer> toggleStyleMixin;
protected HandlerRegistration handlerRegistration;
protected MaterialLabel collapseLabel = new MaterialLabel();
protected MaterialIcon collapseIcon = new MaterialIcon(IconType.KEYBOARD_ARROW_UP);
protected ToggleStyleMixin<Widget> collapsibleMixin;
protected ToggleStyleMixin<Widget> collapseMixin;

public DefaultMoreChipHandler(MaterialChipContainer container) {
this.container = container;
more.setDisplay(Display.BLOCK);
more.setMarginLeft(4);
more.setMarginTop(12);
}

@Override
public void setVisibleChipsSize(int visibleChipsSize) {
this.visibleChipsSize = visibleChipsSize;
}

@Override
public void load() {
showHiddenChips(false);
collapseIcon.addStyleName("collapse");
collapseLabel.addStyleName("collapse-label");
collapseIcon.addClickHandler(this::toggle);
collapseLabel.addClickHandler(this::toggle);
if (!collapseIcon.isAttached()) {
collapseIcon.setVisible(false);
collapseLabel.setVisible(false);
container.add(collapseIcon);
container.add(collapseLabel);
}
}

public void collapse() {
getCollapseMixin().setOn(true);
}

public void expand() {
getCollapseMixin().setOn(false);
}

public void setCollapsible(boolean enableCollapsible) {
getCollapsibleMixin().setOn(enableCollapsible);
}

protected void toggle(ClickEvent event) {
if (!getCollapseMixin().isOn()) {
collapse();
} else {
expand();
}
event.stopPropagation();
event.preventDefault();
}

@Override
public void reload() {
showHiddenChips(false);
}

@Override
public void update(MaterialChip chip) {
if (getCollapseMixin().isOn()) {
MaterialIcon icon = chip.getIcon();
icon.registerHandler(icon.addClickHandler(clickEvent -> updateCollapseLabel(chip)));
updateCollapseLabel(chip);
}
}

protected void updateCollapseLabel(MaterialChip chip) {
int length = $(container.getElement()).find(".chip").length();
collapseIcon.setVisible(length > 0);
collapseLabel.setVisible(length > 0);
collapseLabel.setText(length + "");
}

public void showHiddenChips(boolean showHiddenChips) {
if (visibleChipsSize > 0) {
if (handlerRegistration == null) {
handlerRegistration = more.addClickHandler(clickEvent -> showHiddenChips(!getToggleStyleMixin().isOn()));
}
if (!more.isAttached()) {
container.add(more);
}
List<MaterialChip> chipList = container.getChipList();
int hiddenChipsSize = chipList.size() - visibleChipsSize;
for (MaterialChip widgets : chipList) {
if (showHiddenChips) {
$(widgets.getElement()).css("display", "block");
} else {
if (chipList.indexOf(widgets) > visibleChipsSize) {
$(widgets.getElement()).css("display", "none");
}
}
}

if (showHiddenChips) {
more.setVisibility(Style.Visibility.HIDDEN);
} else {
more.setVisibility(Style.Visibility.VISIBLE);
more.setText(localizedMoreText.replace("{0}", hiddenChipsSize + ""));
}
}
}

public ToggleStyleMixin<Widget> getCollapseMixin() {
if (collapseMixin == null) {
collapseMixin = new ToggleStyleMixin<>(container, "collapse");
}
return collapseMixin;
}

public ToggleStyleMixin<Widget> getCollapsibleMixin() {
if (collapsibleMixin == null) {
collapsibleMixin = new ToggleStyleMixin<>(container, "enable-collapsible");
}
return collapsibleMixin;
}

public ToggleStyleMixin<MaterialChipContainer> getToggleStyleMixin() {
if (toggleStyleMixin == null) {
toggleStyleMixin = new ToggleStyleMixin<>(container, "expanded");
}
return toggleStyleMixin;
}
}
Expand Up @@ -39,6 +39,7 @@
import gwt.material.design.client.events.DropEvent;
import gwt.material.design.client.events.*;
import gwt.material.design.client.events.OrientationChangeEvent.OrientationChangeHandler;
import gwt.material.design.client.theme.GlobalThemeConfig;
import gwt.material.design.client.theme.ThemeManager;
import gwt.material.design.jquery.client.api.JQuery;
import gwt.material.design.jquery.client.api.JQueryElement;
Expand All @@ -58,6 +59,7 @@ public class MaterialWidget extends ComplexPanel implements HasId, HasEnabled, H

private static JQueryElement window = null;
private static JQueryElement body = null;
private static GlobalThemeConfig themeConfig;

public static JQueryElement window() {
if (window == null) {
Expand Down Expand Up @@ -1960,4 +1962,11 @@ public void setTranslationKey(String key) {
public String getTranslationKey() {
return translationKey;
}

public static GlobalThemeConfig getGlobalTheme() {
if (themeConfig == null) {
themeConfig = new GlobalThemeConfig();
}
return themeConfig;
}
}
@@ -0,0 +1,39 @@
/*
* #%L
* GwtMaterial
* %%
* Copyright (C) 2015 - 2022 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.client.base;

import gwt.material.design.client.ui.MaterialChip;

public interface MoreChipHandler {

void setVisibleChipsSize(int visibleChipsSize);

void load();

void collapse();

void expand();

void setCollapsible(boolean enableCollapsible);

void reload();

void update(MaterialChip chip);
}
Expand Up @@ -57,8 +57,8 @@ public void resetFields() {
protected void reset(Widget parent) {
if (parent instanceof HasWidgets) {
for (Widget child : (HasWidgets) parent) {
if (child instanceof AbstractValueWidget) {
((AbstractValueWidget) child).reset();
if (child instanceof HasResetField) {
((HasResetField) child).resetFields();
}
else if (propagateToChildren) {
reset(child);
Expand Down

0 comments on commit d96b971

Please sign in to comment.