diff --git a/.gitignore b/.gitignore index 2ba8b1a9a..6e30fd196 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ target/ gwt-material-addins.iml .idea /war -/gwt-unitCache \ No newline at end of file +/gwt-unitCache +/bin/ diff --git a/.travis.yml b/.travis.yml index 72e285147..da7abf3e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ sudo: false +dist: trusty language: java jdk: - oraclejdk8 @@ -7,15 +8,20 @@ cache: - $HOME/.m2 before_install: # install the gwt-material-jquery library before we build the demo -- git clone -b master https://github.com/GwtMaterialDesign/gwt-material-jquery.git +- git clone -b release_2.4.0 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 master https://github.com/GwtMaterialDesign/gwt-material.git +- git clone -b release_2.4.0 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.0 https://github.com/GwtMaterialDesign/gwt-material-table.git +- cd gwt-material-table +- mvn install -DskipTests=true -DdryRun=true +- cd .. install: true before_script: - chmod +x .utility/* diff --git a/.utility/deploy.sh b/.utility/deploy.sh index 6a2ced0db..ac974e066 100644 --- a/.utility/deploy.sh +++ b/.utility/deploy.sh @@ -1,6 +1,6 @@ #!/bin/bash set -ev -if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then +if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.4.0" ]; then echo "ossrh\${env.OSSRH_USER}\${env.OSSRH_PASS}" > ~/settings.xml - mvn deploy --settings ~/settings.xml + mvn deploy -DskipTests --settings ~/settings.xml fi \ No newline at end of file diff --git a/README.md b/README.md index 25a7c44d9..000243663 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,26 @@ - + # gwt-material-addins -[![Build Status](https://travis-ci.org/GwtMaterialDesign/gwt-material-addins.svg?branch=master)](https://travis-ci.org/GwtMaterialDesign/gwt-material-addins) [![Join the chat at https://gitter.im/GwtMaterialDesign/gwt-material-addins](https://badges.gitter.im/GwtMaterialDesign/gwt-material-addins.svg)](https://gitter.im/GwtMaterialDesign/gwt-material-addins?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://travis-ci.org/GwtMaterialDesign/gwt-material-addins.svg?branch=master)](https://travis-ci.org/GwtMaterialDesign/gwt-material-addins) [![Join us](https://img.shields.io/badge/slack-channel-purple)](https://gmd-project.slack.com) Gwt Material Design Extra Components for https://github.com/GwtMaterialDesign/gwt-material
-## Current Version 2.1 +## Current Version 2.4.0 ```xml com.github.gwtmaterialdesign gwt-material-addins - 2.1 + 2.4.0 ``` -## Snapshot Version 2.2-SNAPSHOT +## Snapshot Version 2.5.0-SNAPSHOT ```xml com.github.gwtmaterialdesign gwt-material-addins - 2.2-SNAPSHOT + 2.5.0-SNAPSHOT ``` @@ -110,6 +110,3 @@ We created [Java Docs](http://gwtmaterialdesign.github.io/gwt-material-demo/apid - Inline Search - Timer (Infinite) - Toggle - -##Follow Us - Google Plus diff --git a/pom.xml b/pom.xml index 0730b327c..5d4ad3a40 100644 --- a/pom.xml +++ b/pom.xml @@ -5,25 +5,26 @@ gwt-material-parent com.github.gwtmaterialdesign - 2.1 + 2.4.0 gwt-material-addins gwt-lib Gwt Material Addins - 2.1 + ${parent.version} Extra Components of GWT Material Framework - 2.1 + ${parent.version} + 2.22.1 scm:git:git@github.com:GwtMaterialDesign/gwt-material-addins.git scm:git:git@github.com:GwtMaterialDesign/gwt-material-addins.git http://github.com/GwtMaterialDesign/gwt-material-addins - v2.1 + v2.4.0 @@ -54,6 +55,13 @@ ${gwt-material.version} + + + com.github.gwtmaterialdesign + gwt-material-table + ${gwt-material.version} + + com.github.gwtmaterialdesign @@ -89,9 +97,14 @@ junit junit - 4.11 + ${junit.version} test + + net.sourceforge.htmlunit + htmlunit + ${htmlunit.version} + @@ -113,22 +126,35 @@ maven-surefire-plugin ${surefire.version} - - ${project.build.sourceDirectory} - ${project.build.testSourceDirectory} - - false - always - -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog + + **/**.java + + test test + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven.failsafe.plugin} + + + **/*.class + + + + net.ltgt.gwt.maven gwt-maven-plugin @@ -152,14 +178,39 @@ true compile+runtime true - true + compile compile + + default-test + + test + + + + + **/ui/**.java + + + **/AddinsTestSuite.java + **/IncubatorTestSuite.java + + + + false + + -checkAssertions + + + diff --git a/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutoComplete.java b/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutoComplete.java index 7d8717de1..d6165bc22 100644 --- a/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutoComplete.java +++ b/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutoComplete.java @@ -29,6 +29,7 @@ import gwt.material.design.addins.client.MaterialAddins; import gwt.material.design.addins.client.autocomplete.constants.AutocompleteType; import gwt.material.design.addins.client.base.constants.AddinsCssName; +import gwt.material.design.addins.client.dark.AddinsDarkThemeReloader; import gwt.material.design.client.MaterialDesignBase; import gwt.material.design.client.base.*; import gwt.material.design.client.base.mixin.*; @@ -160,7 +161,7 @@ */ // @formatter:on public class MaterialAutoComplete extends AbstractValueWidget> implements HasPlaceholder, - HasProgress, HasType, HasSelectionHandlers, HasReadOnly, HasFieldTypes { + HasProgress, HasType, HasSelectionHandlers, HasReadOnly, HasFieldTypes, HasLabel { static { if (MaterialAddins.isDebug()) { @@ -231,60 +232,71 @@ protected void onLoad() { } protected void loadHandlers() { + if (itemBoxBlurHandler == null) { + itemBoxBlurHandler = itemBox.addBlurHandler(blurEvent -> { + if (getValue().size() > 0) { + label.addStyleName(CssName.ACTIVE); + } + }); + } - itemBoxBlurHandler = itemBox.addBlurHandler(blurEvent -> { - if (getValue().size() > 0) { - label.addStyleName(CssName.ACTIVE); - } - }); - - itemBoxKeyDownHandler = itemBox.addKeyDownHandler(event -> { - switch (event.getNativeKeyCode()) { - case KeyCodes.KEY_ENTER: - if (directInputAllowed) { - String value = itemBox.getValue(); - if (value != null && !(value = value.trim()).isEmpty()) { - gwt.material.design.client.base.Suggestion directInput = new gwt.material.design.client.base.Suggestion(); - directInput.setDisplay(value); - directInput.setSuggestion(value); - addItem(directInput); - if (getType() == AutocompleteType.TEXT) { - itemBox.setText(value); - } else { - itemBox.setValue(""); + if (itemBoxKeyDownHandler == null) { + itemBoxKeyDownHandler = itemBox.addKeyDownHandler(event -> { + switch (event.getNativeKeyCode()) { + case KeyCodes.KEY_ENTER: + if (directInputAllowed) { + String value = itemBox.getValue(); + if (value != null && !(value = value.trim()).isEmpty()) { + gwt.material.design.client.base.Suggestion directInput = new gwt.material.design.client.base.Suggestion(); + directInput.setDisplay(value); + directInput.setSuggestion(value); + addItem(directInput); + if (getType() == AutocompleteType.TEXT) { + itemBox.setText(value); + } else { + itemBox.setValue(""); + } + itemBox.setFocus(true); } - itemBox.setFocus(true); } - } - break; - case KeyCodes.KEY_BACKSPACE: - if (itemBox.getValue().trim().isEmpty()) { - if (itemsHighlighted.isEmpty()) { - if (suggestionMap.size() > 0) { - ListItem li = (ListItem) list.getWidget(list.getWidgetCount() - 2); - - if (tryRemoveSuggestion(li.getWidget(0))) { - li.removeFromParent(); + break; + case KeyCodes.KEY_BACKSPACE: + if (itemBox.getValue().trim().isEmpty()) { + if (itemsHighlighted.isEmpty()) { + if (suggestionMap.size() > 0) { + ListItem li = (ListItem) list.getWidget(list.getWidgetCount() - 2); + + if (tryRemoveSuggestion(li.getWidget(0))) { + li.removeFromParent(); + } } } } - } - break; - case KeyCodes.KEY_DELETE: - if (itemBox.getValue().trim().isEmpty()) { - for (ListItem li : itemsHighlighted) { - if (tryRemoveSuggestion(li.getWidget(0))) { - li.removeFromParent(); + break; + case KeyCodes.KEY_DELETE: + if (itemBox.getValue().trim().isEmpty()) { + for (ListItem li : itemsHighlighted) { + if (tryRemoveSuggestion(li.getWidget(0))) { + li.removeFromParent(); + } } + itemsHighlighted.clear(); } - itemsHighlighted.clear(); - } - itemBox.setFocus(true); - break; - } - }); + itemBox.setFocus(true); + break; + } + }); + } + + if (itemBoxClickHandler == null) { + itemBoxClickHandler = itemBox.addClickHandler(event -> suggestBox.showSuggestionList()); + } + + if (itemBox != null && itemBox.isAttached()) { + itemBox.getElement().setAttribute("autocomplete", "off"); + } - itemBoxClickHandler = itemBox.addClickHandler(event -> suggestBox.showSuggestionList()); + AddinsDarkThemeReloader.get().reload(MaterialAutoCompleteDarkTheme.class); } @Override @@ -337,7 +349,7 @@ protected void setup(SuggestOracle suggestions) { panel.add(list); panel.getElement().setAttribute("onclick", - "document.getElementById('" + autocompleteId + "').focus()"); + "document.getElementById('" + autocompleteId + "').focus()"); panel.add(errorLabel); suggestBox.setFocus(true); } @@ -475,7 +487,7 @@ public List getItemValues() { /** * @param itemValues the itemsSelected to set - * @see #setValue(Object) + * @see #setValue(List, boolean) */ public void setItemValues(List itemValues) { setItemValues(itemValues, false); @@ -484,7 +496,7 @@ public void setItemValues(List itemValues) { /** * @param itemValues the itemsSelected to set * @param fireEvents will fire value change event if true - * @see #setValue(Object) + * @see #setValue(List, boolean) */ public void setItemValues(List itemValues, boolean fireEvents) { if (itemValues == null) { @@ -573,10 +585,7 @@ public void setPlaceholder(String placeholder) { itemBox.getElement().setAttribute("placeholder", placeholder); } - /** - * @param label - * @see gwt.material.design.client.ui.MaterialValueBox#setLabel(String) - */ + @Override public void setLabel(String label) { this.label.setText(label); if (!getPlaceholder().isEmpty()) { @@ -584,6 +593,11 @@ public void setLabel(String label) { } } + @Override + public String getLabel() { + return label.getText(); + } + /** * Gets the current {@link MaterialChipProvider}. By default, the class uses * an instance of {@link DefaultMaterialChipProvider}. @@ -808,7 +822,7 @@ public void setEnabled(boolean enabled) { itemBox.setEnabled(enabled); } - public Label getLabel() { + public Label getLabelWidget() { return label; } @@ -918,4 +932,4 @@ protected FieldTypeMixin getFieldTypeMixin() { } return fieldTypeMixin; } -} \ No newline at end of file +} diff --git a/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutoCompleteDarkTheme.java b/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutoCompleteDarkTheme.java new file mode 100644 index 000000000..b1848aaff --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutoCompleteDarkTheme.java @@ -0,0 +1,30 @@ +/* + * #%L + * GwtMaterial + * %% + * Copyright (C) 2015 - 2020 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.autocomplete; + +import gwt.material.design.addins.client.MaterialAddins; +import gwt.material.design.addins.client.dark.AddinsWidgetDarkTheme; + +public class MaterialAutoCompleteDarkTheme extends AddinsWidgetDarkTheme { + + public MaterialAutoCompleteDarkTheme() { + super(MaterialAddins.isDebug() ? MaterialAutocompleteDebugClientBundle.INSTANCE.autocompleteDarkCss() : MaterialAutocompleteClientBundle.INSTANCE.autocompleteDarkCss()); + } +} diff --git a/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutocompleteClientBundle.java b/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutocompleteClientBundle.java index a002dbad5..ba2b0f7bc 100644 --- a/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutocompleteClientBundle.java +++ b/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutocompleteClientBundle.java @@ -34,4 +34,7 @@ interface MaterialAutocompleteClientBundle extends ClientBundle { @Source("resources/css/autocomplete.min.css") TextResource autocompleteCss(); + + @Source("resources/css/autocomplete-dark.min.css") + TextResource autocompleteDarkCss(); } diff --git a/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutocompleteDebugClientBundle.java b/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutocompleteDebugClientBundle.java index 2d89cafe4..e8a8c1e4d 100644 --- a/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutocompleteDebugClientBundle.java +++ b/src/main/java/gwt/material/design/addins/client/autocomplete/MaterialAutocompleteDebugClientBundle.java @@ -34,4 +34,7 @@ interface MaterialAutocompleteDebugClientBundle extends ClientBundle { @Source("resources/css/autocomplete.css") TextResource autocompleteCssDebug(); + + @Source("resources/css/autocomplete-dark.css") + TextResource autocompleteDarkCss(); } diff --git a/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatar.java b/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatar.java index 1f63cd1b6..02f473c8b 100644 --- a/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatar.java +++ b/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatar.java @@ -21,6 +21,7 @@ import com.google.gwt.dom.client.Document; import gwt.material.design.addins.client.MaterialAddins; +import gwt.material.design.addins.client.avatar.js.AvatarOptions; import gwt.material.design.addins.client.avatar.js.JsAvatar; import gwt.material.design.client.MaterialDesignBase; import gwt.material.design.client.base.AbstractValueWidget; @@ -66,6 +67,8 @@ public class MaterialAvatar extends AbstractValueWidget implements JsLoa } private String value; + private AvatarOptions options; + public MaterialAvatar() { super(Document.get().createCanvasElement()); } @@ -84,11 +87,15 @@ protected void onLoad() { @Override public void load() { + if (options != null) { + JsAvatar.config = options; + } JsAvatar.jdenticon(); } @Override - public void unload() {} + public void unload() { + } @Override public void reload() { @@ -112,8 +119,7 @@ public String getName() { } /** - * Replaced by {@link MaterialAvatar#setValue(Object)} - * @param name + * Replaced by {@link MaterialAvatar#setValue(String, boolean)} )} */ @Deprecated public void setName(String name) { @@ -154,7 +160,8 @@ public int getHeight() { /** * Allowing to set the dimension of the Avatar component. - * @param width - the width dimension of the avatar without any Unit suffix (e.i 100) + * + * @param width - the width dimension of the avatar without any Unit suffix (e.i 100) * @param height - the height dimension of the avatar without any Unit suffix (e.i 100) */ public void setDimension(int width, int height) { @@ -170,4 +177,12 @@ protected String generateHashCode(String value) { this.value = value; return JsAvatar.md5(value); } -} \ No newline at end of file + + public AvatarOptions getOptions() { + return options; + } + + public void setOptions(AvatarOptions options) { + this.options = options; + } +} diff --git a/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarClientBundle.java b/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarClientBundle.java index edcbaa8aa..979f75ca9 100644 --- a/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarClientBundle.java +++ b/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarClientBundle.java @@ -32,7 +32,7 @@ public interface MaterialAvatarClientBundle extends ClientBundle { MaterialAvatarClientBundle INSTANCE = GWT.create(MaterialAvatarClientBundle.class); - @Source("resources/js/jdenticon-1.3.2.min.js") + @Source("resources/js/jdenticon-2.2.0.min.js") TextResource jdenticonJs(); @Source("resources/js/md5.min.js") diff --git a/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarDebugClientBundle.java b/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarDebugClientBundle.java index 973bf72d0..633ed0eb9 100644 --- a/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarDebugClientBundle.java +++ b/src/main/java/gwt/material/design/addins/client/avatar/MaterialAvatarDebugClientBundle.java @@ -32,7 +32,7 @@ public interface MaterialAvatarDebugClientBundle extends ClientBundle { MaterialAvatarDebugClientBundle INSTANCE = GWT.create(MaterialAvatarDebugClientBundle.class); - @Source("resources/js/jdenticon-1.3.2.js") + @Source("resources/js/jdenticon-2.2.0.js") TextResource jdenticonDebugJs(); @Source("resources/js/md5.js") diff --git a/src/main/java/gwt/material/design/addins/client/avatar/js/AvatarLightnessOptions.java b/src/main/java/gwt/material/design/addins/client/avatar/js/AvatarLightnessOptions.java new file mode 100644 index 000000000..37e0fd3c0 --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/avatar/js/AvatarLightnessOptions.java @@ -0,0 +1,70 @@ +/* + * #%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.avatar.js; + +import jsinterop.annotations.JsOverlay; +import jsinterop.annotations.JsPackage; +import jsinterop.annotations.JsProperty; +import jsinterop.annotations.JsType; + +/** + * Options for combobox component + * + * @author kevzlou7979 + */ +@JsType(isNative = true, name = "Object", namespace = JsPackage.GLOBAL) +public class AvatarLightnessOptions { + + @JsProperty + private Double[] color; + + @JsProperty + private Double[] grayscale; + + @JsOverlay + public final Double[] getColor() { + return color; + } + + /** + * Specifies the lightness range of colored shapes of an icon. The range is expressed as an array containing + * two numbers, representing the minimum and maximum lightness in the range [0.0, 1.0]. + * Default : [0.4, 0.8] + */ + @JsOverlay + public final void setColor(Double[] color) { + this.color = color; + } + + @JsOverlay + public final Double[] getGrayscale() { + return grayscale; + } + + /** + * Specifies the lightness range of grayscale shapes of an icon. The range is expressed as an array containing + * two numbers, representing the minimum and maximum lightness in the range [0.0, 1.0]. + * Default : [0.3, 0.9] + */ + @JsOverlay + public final void setGrayscale(Double[] grayscale) { + this.grayscale = grayscale; + } +} diff --git a/src/main/java/gwt/material/design/addins/client/avatar/js/AvatarOptions.java b/src/main/java/gwt/material/design/addins/client/avatar/js/AvatarOptions.java new file mode 100644 index 000000000..b39967486 --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/avatar/js/AvatarOptions.java @@ -0,0 +1,146 @@ +/* + * #%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.avatar.js; + +import jsinterop.annotations.JsOverlay; +import jsinterop.annotations.JsPackage; +import jsinterop.annotations.JsProperty; +import jsinterop.annotations.JsType; + +/** + * Options for combobox component + * + * @author kevzlou7979 + */ +@JsType(isNative = true, name = "Object", namespace = JsPackage.GLOBAL) +public class AvatarOptions { + + @JsProperty + private Double[] hues; + + @JsProperty + private AvatarLightnessOptions lightness; + + @JsProperty + private AvatarSaturationOptions saturation; + + @JsProperty + private String backColor; + + @JsProperty + private Number padding; + + @JsProperty + private String replaceMode; + + @JsOverlay + public final Double[] getHues() { + return hues; + } + + /** + * Limits the possible hues in generated icons. The hues are specified as an array of hues in degrees. + * If the option is omitted or an empty array is specified, all hues are allowed. + * Default null + */ + @JsOverlay + public final void setHues(Double[] hues) { + this.hues = hues; + } + + @JsOverlay + public final AvatarLightnessOptions getLightness() { + return lightness; + } + + @JsOverlay + public final void setLightness(AvatarLightnessOptions lightness) { + this.lightness = lightness; + } + + @JsOverlay + public final AvatarSaturationOptions getSaturation() { + return saturation; + } + + @JsOverlay + public final void setSaturation(AvatarSaturationOptions saturation) { + this.saturation = saturation; + } + + @JsOverlay + public final String getBackColor() { + return backColor; + } + + /** + * Specifies the background color to be rendered behind the icon. Supported syntaxes are #rgb, #rgba, #rrggbb and + * #rrggbbaa. + *

+ * Default : "#00000000" + */ + @JsOverlay + public final void setBackColor(String backColor) { + this.backColor = backColor; + } + + @JsOverlay + public final Number getPadding() { + return padding; + } + + /** + * Specifies the padding surrounding the icon in percents in the range 0.0 to 0.5. Additional padding might be + * inserted by Jdenticon to ensure the icon is aligned to the pixel grid. For jdenticon.drawIcon() the default + * value is 0. For all other methods the default value is 0.08. + * Default : 0 or 0.08 + */ + @JsOverlay + public final void setPadding(Number padding) { + this.padding = padding; + } + + @JsOverlay + public final String getReplaceMode() { + return replaceMode; + } + + /** + * Specifies when icons will be rendered. This option has no effect on Node.js. + *

    + *
  • + * {@link ReplaceMode#NEVER} – icons are never rendered automatically. You need to call jdenticon.update() manually to render + * identicons. + *
  • + *
  • + * {@link ReplaceMode#ONCE} – icons are rendered once the page has loaded. Any dynamically inserted or modified icons will + * not be rendered unless jdenticon.update() is manually called. + *
  • + *
  • + * {@link ReplaceMode#OBSERVE} – icons are rendered upon page load, and the DOM is monitored for new icons using a MutationObserver. + * Use this if icons are inserted dynamically, e.g. by using Angular, React or VanillaJS. This option behaves as "once" in IE<11. + *
  • + *
+ */ + @JsOverlay + public final void setReplaceMode(ReplaceMode replaceMode) { + this.replaceMode = replaceMode.getName(); + } +} diff --git a/src/main/java/gwt/material/design/addins/client/avatar/js/AvatarSaturationOptions.java b/src/main/java/gwt/material/design/addins/client/avatar/js/AvatarSaturationOptions.java new file mode 100644 index 000000000..006679b63 --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/avatar/js/AvatarSaturationOptions.java @@ -0,0 +1,70 @@ +/* + * #%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.avatar.js; + +import jsinterop.annotations.JsOverlay; +import jsinterop.annotations.JsPackage; +import jsinterop.annotations.JsProperty; +import jsinterop.annotations.JsType; + +/** + * Options for combobox component + * + * @author kevzlou7979 + */ +@JsType(isNative = true, name = "Object", namespace = JsPackage.GLOBAL) +public class AvatarSaturationOptions { + + @JsProperty + private Double color; + + @JsProperty + private Double grayscale; + + @JsOverlay + public final Double getColor() { + return color; + } + + /** + * Specifies the saturation of the originally colored shapes of an icon. The saturation is expressed as a number + * in the range [0.0, 1.0]. Was previously called just saturation. + * Default : 0.5 + */ + @JsOverlay + public final void setColor(Double color) { + this.color = color; + } + + @JsOverlay + public final Double getGrayscale() { + return grayscale; + } + + /** + * Specifies the saturation of the originally grayscale shapes of an icon. The saturation is expressed as a number + * in the range [0.0, 1.0]. + * Default : 0.0 + */ + @JsOverlay + public final void setGrayscale(Double grayscale) { + this.grayscale = grayscale; + } +} diff --git a/src/main/java/gwt/material/design/addins/client/avatar/js/JsAvatar.java b/src/main/java/gwt/material/design/addins/client/avatar/js/JsAvatar.java index 17c390c71..5911a16eb 100644 --- a/src/main/java/gwt/material/design/addins/client/avatar/js/JsAvatar.java +++ b/src/main/java/gwt/material/design/addins/client/avatar/js/JsAvatar.java @@ -22,6 +22,7 @@ import gwt.material.design.jquery.client.api.JQueryElement; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsPackage; +import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; /** @@ -29,13 +30,15 @@ * * @author kevzlou7979 */ -@JsType(isNative = true) +@JsType(isNative = true, name = "jdenticon", namespace = JsPackage.GLOBAL) public class JsAvatar extends JQueryElement { + @JsProperty + public static AvatarOptions config; + @JsMethod(namespace = JsPackage.GLOBAL) public static native void jdenticon(); @JsMethod(namespace = JsPackage.GLOBAL) public static native String md5(String value); - } diff --git a/src/main/java/gwt/material/design/addins/client/avatar/js/ReplaceMode.java b/src/main/java/gwt/material/design/addins/client/avatar/js/ReplaceMode.java new file mode 100644 index 000000000..42901374e --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/avatar/js/ReplaceMode.java @@ -0,0 +1,51 @@ +/* + * #%L + * GwtMaterial + * %% + * Copyright (C) 2015 - 2020 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.avatar.js; + +public enum ReplaceMode { + + /** + * Icons are never rendered automatically. You need to call jdenticon.update() manually to render identicons. + */ + NEVER("never"), + + /** + * Icons are rendered once the page has loaded. Any dynamically inserted or modified icons will not be rendered + * unless jdenticon.update() is manually called. + */ + ONCE("once"), + + /** + * Icons are rendered upon page load, and the DOM is monitored for new icons using a MutationObserver. + * Use this if icons are inserted dynamically, e.g. by using Angular, React or VanillaJS. This option behaves as + * "once" in IE<11. + */ + OBSERVE("observe"); + + private String name; + + ReplaceMode(java.lang.String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/gwt/material/design/addins/client/base/constants/AddinsCssName.java b/src/main/java/gwt/material/design/addins/client/base/constants/AddinsCssName.java index f08464239..754416b26 100644 --- a/src/main/java/gwt/material/design/addins/client/base/constants/AddinsCssName.java +++ b/src/main/java/gwt/material/design/addins/client/base/constants/AddinsCssName.java @@ -75,6 +75,7 @@ public interface AddinsCssName { String SUCCESS = "success"; String ERROR = "error"; String STEPPER = "stepper"; + String STEP_HEADER = "step-header"; String FEEDBACK = "feedback"; String SUBHEADER = "subheader"; String CONTAINER1 = "container1"; @@ -122,4 +123,7 @@ public interface AddinsCssName { String WIDE = "wide"; String BRIDGE_PATH = "bridge-path"; String INTERACT_IGNORED_CONTENT = "interact-ignored-content"; + String FIXED_STEP_WIDTH = "fixed-step-width"; + String CONTINUOUS_SLIDER = "rkmd-slider slider-continuous"; + } \ No newline at end of file diff --git a/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubble.java b/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubble.java index bd9b804b6..aea53bd7d 100644 --- a/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubble.java +++ b/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubble.java @@ -23,6 +23,8 @@ import gwt.material.design.addins.client.MaterialAddins; import gwt.material.design.addins.client.base.constants.AddinsCssName; import gwt.material.design.addins.client.bubble.js.JsBubbleOptions; +import gwt.material.design.addins.client.combobox.MaterialComboBoxDarkTheme; +import gwt.material.design.addins.client.dark.AddinsDarkThemeReloader; import gwt.material.design.client.MaterialDesignBase; import gwt.material.design.client.base.HasPosition; import gwt.material.design.client.base.JsLoader; @@ -105,6 +107,7 @@ protected void onLoad() { @Override public void load() { $(getElement()).bubble(options); + AddinsDarkThemeReloader.get().reload(MaterialBubbleDarkTheme.class); } @Override @@ -115,7 +118,8 @@ protected void onUnload() { } @Override - public void unload() {} + public void unload() { + } @Override public void reload() { @@ -152,4 +156,4 @@ protected CssNameMixin getPositionMixin() { } return positionMixin; } -} \ No newline at end of file +} diff --git a/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleClientBundle.java b/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleClientBundle.java index ab4b5068c..e1cea3b74 100644 --- a/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleClientBundle.java +++ b/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleClientBundle.java @@ -37,4 +37,7 @@ interface MaterialBubbleClientBundle extends ClientBundle { @Source("resources/css/bubble.min.css") TextResource bubbleCss(); + + @Source("resources/css/bubble-dark.min.css") + TextResource bubbleDarkCss(); } diff --git a/src/main/java/gwt/material/design/incubator/client/chart/chartjs/DoughnutChart.java b/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleDarkTheme.java similarity index 55% rename from src/main/java/gwt/material/design/incubator/client/chart/chartjs/DoughnutChart.java rename to src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleDarkTheme.java index 3e109ae77..40ab0b79a 100644 --- a/src/main/java/gwt/material/design/incubator/client/chart/chartjs/DoughnutChart.java +++ b/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleDarkTheme.java @@ -2,7 +2,7 @@ * #%L * GwtMaterial * %% - * Copyright (C) 2015 - 2017 GwtMaterialDesign + * Copyright (C) 2015 - 2019 GwtMaterialDesign * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,15 +17,14 @@ * limitations under the License. * #L% */ -package gwt.material.design.incubator.client.chart.chartjs; +package gwt.material.design.addins.client.bubble; -import gwt.material.design.incubator.client.chart.chartjs.base.AbstractChart; -import gwt.material.design.incubator.client.chart.chartjs.base.constants.ChartType; -import gwt.material.design.incubator.client.chart.chartjs.js.datasets.LineChartDataSets; +import gwt.material.design.addins.client.MaterialAddins; +import gwt.material.design.addins.client.dark.AddinsWidgetDarkTheme; -public class DoughnutChart extends AbstractChart { +public class MaterialBubbleDarkTheme extends AddinsWidgetDarkTheme { - public DoughnutChart() { - super(ChartType.LINE); + public MaterialBubbleDarkTheme() { + super(MaterialAddins.isDebug() ? MaterialBubbleDebugClientBundle.INSTANCE.bubbleDarkDebugCss() : MaterialBubbleClientBundle.INSTANCE.bubbleDarkCss()); } } diff --git a/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleDebugClientBundle.java b/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleDebugClientBundle.java index 0ca9f634b..4a66af945 100644 --- a/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleDebugClientBundle.java +++ b/src/main/java/gwt/material/design/addins/client/bubble/MaterialBubbleDebugClientBundle.java @@ -37,4 +37,7 @@ interface MaterialBubbleDebugClientBundle extends ClientBundle { @Source("resources/css/bubble.css") TextResource bubbleCssDebug(); + + @Source("resources/css/bubble-dark.css") + TextResource bubbleDarkDebugCss(); } diff --git a/src/main/java/gwt/material/design/addins/client/camera/Html5Camera.java b/src/main/java/gwt/material/design/addins/client/camera/Html5Camera.java index 7cb5420c3..f1a4bea9b 100644 --- a/src/main/java/gwt/material/design/addins/client/camera/Html5Camera.java +++ b/src/main/java/gwt/material/design/addins/client/camera/Html5Camera.java @@ -80,6 +80,7 @@ protected void captureToDataURL() { } } + //TODO: Convert to JSInterop protected native File toFile(Element inputElement) /*-{ return $wnd.jQuery(inputElement).prop('files')[0]; }-*/; diff --git a/src/main/java/gwt/material/design/addins/client/camera/MaterialCameraCapture.java b/src/main/java/gwt/material/design/addins/client/camera/MaterialCameraCapture.java index cc2bf22b8..51cdea361 100644 --- a/src/main/java/gwt/material/design/addins/client/camera/MaterialCameraCapture.java +++ b/src/main/java/gwt/material/design/addins/client/camera/MaterialCameraCapture.java @@ -33,6 +33,7 @@ import gwt.material.design.addins.client.camera.events.CameraCaptureHandler; import gwt.material.design.client.base.JsLoader; import gwt.material.design.client.base.MaterialWidget; +import gwt.material.design.client.ui.MaterialPanel; import gwt.material.design.jscore.client.api.Navigator; import gwt.material.design.jscore.client.api.media.*; @@ -106,7 +107,7 @@ public class MaterialCameraCapture extends MaterialWidget implements JsLoader, H protected CameraFacingMode facingMode = CameraFacingMode.FRONT; private MediaStream mediaStream; private MaterialWidget video = new MaterialWidget(Document.get().createVideoElement()); - private MaterialWidget overlayPanel = new MaterialWidget(Document.get().createDivElement()); + private MaterialPanel overlayPanel; public MaterialCameraCapture() { super(Document.get().createDivElement(), "camera-wrapper"); @@ -119,13 +120,6 @@ protected void onLoad() { setLayoutPosition(Style.Position.RELATIVE); add(video); - overlayPanel.setLayoutPosition(Style.Position.FIXED); - overlayPanel.setTop(0); - overlayPanel.setLeft(0); - overlayPanel.setBottom(0); - overlayPanel.setRight(0); - add(overlayPanel); - load(); } @@ -240,19 +234,28 @@ protected void nativePlay(Element video) { mediaTrackConstraints.facingMode = facingMode.getName(); constraints.video = mediaTrackConstraints; - Navigator.mediaDevices.getUserMedia(constraints).then(streamObj -> { + Navigator.mediaDevices.getUserMedia(constraints).then((streamObj) -> { mediaStream = (MediaStream) streamObj; - if (URL.createObjectURL(mediaStream) != null) { - $(video).attr("src", URL.createObjectURL(mediaStream)); - } else if (WebkitURL.createObjectURL(mediaStream) != null) { - $(video).attr("src", WebkitURL.createObjectURL(mediaStream)); - } - if (video instanceof VideoElement) { - ((VideoElement) video).play(); + + if (mediaStream != null) { + try { + video.setPropertyObject("srcObject", mediaStream); + } catch (Exception exception) { + if (URL.createObjectURL(mediaStream) != null) { + $(video).attr("src", URL.createObjectURL(mediaStream)); + } else if (WebkitURL.createObjectURL(mediaStream) != null) { + $(video).attr("src", WebkitURL.createObjectURL(mediaStream)); + } + } finally { + if (video instanceof VideoElement) { + ((VideoElement) video).play(); + } + } } + onCameraCaptureLoad(); return null; - }).catchException(error -> { + }).fail((e, error) -> { GWT.log("MaterialCameraCapture: An error occured! " + error); onCameraCaptureError(error.toString()); return null; @@ -286,21 +289,21 @@ protected String nativeCaptureToDataURL(CanvasElement canvas, Element element, S */ public static boolean isSupported() { return Navigator.webkitGetUserMedia != null - || Navigator.getUserMedia != null - || Navigator.mozGetUserMedia != null - || Navigator.msGetUserMedia != null; + || Navigator.getUserMedia != null + || Navigator.mozGetUserMedia != null + || Navigator.msGetUserMedia != null; } public void addOverlay(MaterialWidget overlay) { - overlayPanel.add(overlay); + getOverlayPanel().add(overlay); } public void removeOverlay(MaterialWidget overlay) { - overlayPanel.remove(overlay); + getOverlayPanel().remove(overlay); } public void clearOverlays() { - overlayPanel.clear(); + getOverlayPanel().clear(); } public MaterialWidget getVideo() { @@ -311,6 +314,19 @@ public void setVideo(MaterialWidget video) { this.video = video; } + public MaterialPanel getOverlayPanel() { + if (overlayPanel == null && overlayPanel.isAttached()) { + overlayPanel = new MaterialPanel(); + overlayPanel.setLayoutPosition(Style.Position.FIXED); + overlayPanel.setTop(0); + overlayPanel.setLeft(0); + overlayPanel.setBottom(0); + overlayPanel.setRight(0); + add(overlayPanel); + } + return overlayPanel; + } + /** * Set the resolution of the camera */ diff --git a/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarousel.java b/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarousel.java index 132b36d44..47b62ba25 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarousel.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarousel.java @@ -20,7 +20,6 @@ package gwt.material.design.addins.client.carousel; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Document; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; @@ -31,10 +30,12 @@ import gwt.material.design.addins.client.MaterialAddins; import gwt.material.design.addins.client.base.constants.AddinsCssName; import gwt.material.design.addins.client.carousel.constants.CarouselType; +import gwt.material.design.addins.client.carousel.constants.RespondTo; import gwt.material.design.addins.client.carousel.events.*; import gwt.material.design.addins.client.carousel.js.JsCarouselOptions; import gwt.material.design.addins.client.carousel.ui.NextArrow; import gwt.material.design.addins.client.carousel.ui.PreviousArrow; +import gwt.material.design.addins.client.dark.AddinsDarkThemeReloader; import gwt.material.design.client.MaterialDesignBase; import gwt.material.design.client.base.HasType; import gwt.material.design.client.base.JsLoader; @@ -42,7 +43,12 @@ import gwt.material.design.client.base.mixin.CssTypeMixin; import gwt.material.design.client.base.mixin.ToggleStyleMixin; import gwt.material.design.client.constants.CssName; -import gwt.material.design.client.ui.*; +import gwt.material.design.client.ui.MaterialButton; +import gwt.material.design.client.ui.MaterialImage; +import gwt.material.design.client.ui.MaterialPanel; +import gwt.material.design.client.ui.MaterialTab; +import gwt.material.design.jquery.client.api.Functions; +import gwt.material.design.jquery.client.api.JQueryElement; import java.util.List; @@ -98,19 +104,18 @@ public class MaterialCarousel extends MaterialWidget implements JsLoader, HasTyp } } - private MaterialPanel container = new MaterialPanel(); - private NextArrow nextArrow = new NextArrow(); - private PreviousArrow previousArrow = new PreviousArrow(); - private MaterialPanel wrapper = new MaterialPanel(); - - - private JsCarouselOptions options = JsCarouselOptions.create(); - + private final MaterialPanel container = new MaterialPanel(); + private final NextArrow nextArrow = new NextArrow(); + private final PreviousArrow previousArrow = new PreviousArrow(); + private final MaterialPanel wrapper = new MaterialPanel(); + private final JsCarouselOptions options = JsCarouselOptions.create(); private CssTypeMixin typeMixin; private List values; + private final String uniqueId; public MaterialCarousel() { super(Document.get().createDivElement(), AddinsCssName.MATERIAL_CAROUSEL); + uniqueId = DOM.createUniqueId(); } private final ToggleStyleMixin fsMixin = new ToggleStyleMixin<>(this, CssName.FULLSCREEN); @@ -119,7 +124,7 @@ public MaterialCarousel() { protected void onLoad() { super.onLoad(); - container.setId(DOM.createUniqueId()); + container.setId(uniqueId); wrapper.setStyleName(AddinsCssName.MATERIAL_CAROUSEL_CONTAINER); wrapper.add(container); @@ -127,6 +132,27 @@ protected void onLoad() { super.add(previousArrow); super.add(wrapper); + load(); + } + + @Override + public void load() { + loadHandlers(); + + if (nextArrow != null) { + options.nextArrow = "#" + nextArrow.getId(); + } + + if (previousArrow != null) { + options.prevArrow = "#" + previousArrow.getId(); + } + + $(container.getElement()).slick(options); + + AddinsDarkThemeReloader.get().reload(MaterialCarouselDarkTheme.class); + } + + protected void loadHandlers() { $(getElement()).on(CarouselEvents.AFTER_CHANGE, (e, slick, currentSlide) -> { AfterChangeEvent.fire(this, Integer.parseInt(currentSlide.toString())); return true; @@ -148,25 +174,35 @@ protected void onLoad() { return true; }); - $(getElement()).on(CarouselEvents.SWIPE, (e, slick, direction) -> { - SwipeEvent.fire(this, direction.toString()); + $(getElement()).on(CarouselEvents.EDGE, (e, direction) -> { + EdgeEvent.fire(this, direction); return true; }); - load(); - } + $(getElement()).on(CarouselEvents.LAZY_LOAD_ERROR, (e, image, imageSource) -> { + LazyLoadedErrorEvent.fire(this, image, imageSource); + return true; + }); - @Override - public void load() { - if (nextArrow != null) { - options.nextArrow = "#" + nextArrow.getId(); - } + $(getElement()).on(CarouselEvents.LAZY_LOADED, (e, image, imageSource) -> { + LazyLoadedEvent.fire(this, image, imageSource); + return true; + }); - if (previousArrow != null) { - options.prevArrow = "#" + previousArrow.getId(); - } - - $(container.getElement()).slick(options); + $(getElement()).on(CarouselEvents.RE_INIT, (e) -> { + ReInitEvent.fire(this); + return true; + }); + + $(getElement()).on(CarouselEvents.SET_POSITION, (e) -> { + SetPositionEvent.fire(this); + return true; + }); + + $(getElement()).on(CarouselEvents.SWIPE, (e, slick, direction) -> { + SwipeEvent.fire(this, direction.toString()); + return true; + }); } @Override @@ -178,11 +214,17 @@ protected void onUnload() { @Override public void unload() { - $(getElement()).off(CarouselEvents.AFTER_CHANGE); - $(getElement()).off(CarouselEvents.BEFORE_CHANGE); - $(getElement()).off(CarouselEvents.INIT); - $(getElement()).off(CarouselEvents.DESTROY); - $(getElement()).off(CarouselEvents.SWIPE); + JQueryElement element = $(getElement()); + element.off(CarouselEvents.AFTER_CHANGE); + element.off(CarouselEvents.BEFORE_CHANGE); + element.off(CarouselEvents.INIT); + element.off(CarouselEvents.DESTROY); + element.off(CarouselEvents.EDGE); + element.off(CarouselEvents.LAZY_LOAD_ERROR); + element.off(CarouselEvents.LAZY_LOADED); + element.off(CarouselEvents.RE_INIT); + element.off(CarouselEvents.SET_POSITION); + element.off(CarouselEvents.SWIPE); destroy(); } @@ -270,11 +312,25 @@ public void play() { command("slickPlay"); } + /** + * Filters slides using jQuery .filter syntax + */ + public void filter(String selector) { + command("slickFilter", selector); + } + + /** + * Removes applied filter + */ + public void unFilter() { + command("slickUnfilter"); + } + protected Object command(String action, Object... params) { - if (container == null || !container.isAttached()) { + if (container == null) { GWT.log("Your carousel container is not yet initialized", new IllegalStateException()); } else { - return $("#" + container.getId()).slick(action, params); + return $("#" + uniqueId).slick(action, params); } return null; } @@ -310,8 +366,6 @@ public boolean isShowArrows() { */ public void setShowArrows(boolean showArrows) { options.arrows = showArrows; - getBtnPrevArrow().setVisible(showArrows); - getBtnNextArrow().setVisible(showArrows); } public int getSlidesToShow() { @@ -493,6 +547,96 @@ public void setCarouselNavigation(MaterialCarousel navigation) { registerHandler(addBeforeChangeHandler(event -> navigation.goToSlide(event.getNextSlide()))); } + public Functions.Func getCustomPaging() { + return options.customPaging; + } + + /** + * Custom paging templates. See source for use example. + */ + public void setCustomPaging(Functions.Func customPaging) { + this.options.customPaging = customPaging; + } + + public String getDotsClass() { + return options.dotsClass; + } + + /** + * Class for slide indicator dots container + */ + public void setDotsClass(String dotsClass) { + this.options.dotsClass = dotsClass; + } + + public boolean isFocusOnChange() { + return options.focusOnChange; + } + + /** + * Puts focus on slide after change + */ + public void setFocusOnChange(boolean focusOnChange) { + this.options.focusOnChange = focusOnChange; + } + + public String getRespondTo() { + return options.respondTo; + } + + /** + * Width that responsive object responds to. Can be 'window', 'slider' or 'min' (the smaller of the two). + * + * @see gwt.material.design.addins.client.carousel.constants.RespondTo + */ + public void setRespondTo(RespondTo respondTo) { + this.options.respondTo = respondTo.getName(); + } + + public String getSlide() { + return options.slide; + } + + /** + * Slide element query + */ + public void setSlide(String slide) { + this.options.slide = slide; + } + + public boolean isUseCSS() { + return options.useCSS; + } + + /** + * Enable/Disable CSS Transitions + */ + public void setUseCSS(boolean useCSS) { + this.options.useCSS = useCSS; + } + + public boolean isUseTransform() { + return options.useTransform; + } + + /** + * Enable/Disable CSS Transforms + */ + public void setUseTransform(boolean useTransform) { + this.options.useTransform = useTransform; + } + + public int getZIndex() { + return options.zIndex; + } + + /** + * Set the zIndex values for slides, useful for IE9 and lower + */ + public void setZIndex(int zIndex) { + this.options.zIndex = zIndex; + } + public MaterialPanel getWrapper() { return wrapper; } @@ -519,6 +663,31 @@ public HandlerRegistration addBeforeChangeHandler(BeforeChangeEvent.BeforeChange return addHandler(handler, BeforeChangeEvent.getType()); } + @Override + public HandlerRegistration addEdgeHandler(EdgeEvent.EdgeHandler handler) { + return addHandler(handler, EdgeEvent.getType()); + } + + @Override + public HandlerRegistration addLazyLoadedErrorHandler(LazyLoadedErrorEvent.LazyLoadedErrorHandler handler) { + return addHandler(handler, LazyLoadedErrorEvent.getType()); + } + + @Override + public HandlerRegistration addLazyLoadedHandler(LazyLoadedEvent.LazyLoadedHandler handler) { + return addHandler(handler, LazyLoadedEvent.getType()); + } + + @Override + public HandlerRegistration addReInitHandler(ReInitEvent.ReInitHandler handler) { + return addHandler(handler, ReInitEvent.getType()); + } + + @Override + public HandlerRegistration addSetPositionHandler(SetPositionEvent.SetPositionHandler handler) { + return addHandler(handler, SetPositionEvent.getType()); + } + @Override public HandlerRegistration addInitHandler(InitEvent.InitHandler handler) { return addHandler(handler, InitEvent.getType()); @@ -574,4 +743,4 @@ public void setValue(List values, boolean fireEvent) { public HandlerRegistration addValueChangeHandler(ValueChangeHandler> valueChangeHandler) { return addHandler(valueChangeHandler, ValueChangeEvent.getType()); } -} \ No newline at end of file +} diff --git a/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselClientBundle.java b/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselClientBundle.java index 179f3f92e..3f0a042d4 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselClientBundle.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselClientBundle.java @@ -40,4 +40,7 @@ public interface MaterialCarouselClientBundle extends ClientBundle { @Source("resources/css/custom.min.css") TextResource customCss(); + + @Source("resources/css/slick-dark.min.css") + TextResource carouselDarkCss(); } diff --git a/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselDarkTheme.java b/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselDarkTheme.java new file mode 100644 index 000000000..a9403eb11 --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselDarkTheme.java @@ -0,0 +1,32 @@ +/* + * #%L + * GwtMaterial + * %% + * Copyright (C) 2015 - 2019 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.carousel; + +import gwt.material.design.addins.client.MaterialAddins; +import gwt.material.design.addins.client.combobox.MaterialComboBoxClientBundle; +import gwt.material.design.addins.client.combobox.MaterialComboBoxDebugClientBundle; +import gwt.material.design.addins.client.dark.AddinsWidgetDarkTheme; + +public class MaterialCarouselDarkTheme extends AddinsWidgetDarkTheme { + + public MaterialCarouselDarkTheme() { + super(MaterialAddins.isDebug() ? MaterialCarouselDebugClientBundle.INSTANCE.carouselDarkCss() : MaterialCarouselClientBundle.INSTANCE.carouselDarkCss()); + } +} diff --git a/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselDebugClientBundle.java b/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselDebugClientBundle.java index 2eec5a906..313af6a94 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselDebugClientBundle.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/MaterialCarouselDebugClientBundle.java @@ -40,4 +40,7 @@ public interface MaterialCarouselDebugClientBundle extends ClientBundle { @Source("resources/css/custom.css") TextResource customCssDebug(); + + @Source("resources/css/slick-dark.css") + TextResource carouselDarkCss(); } diff --git a/src/main/java/gwt/material/design/incubator/client/chart/chartjs/base/constants/ChartType.java b/src/main/java/gwt/material/design/addins/client/carousel/constants/RespondTo.java similarity index 65% rename from src/main/java/gwt/material/design/incubator/client/chart/chartjs/base/constants/ChartType.java rename to src/main/java/gwt/material/design/addins/client/carousel/constants/RespondTo.java index 779fbd54e..ea9fb9431 100644 --- a/src/main/java/gwt/material/design/incubator/client/chart/chartjs/base/constants/ChartType.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/constants/RespondTo.java @@ -2,7 +2,7 @@ * #%L * GwtMaterial * %% - * Copyright (C) 2015 - 2017 GwtMaterialDesign + * Copyright (C) 2015 - 2020 GwtMaterialDesign * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,22 +17,17 @@ * limitations under the License. * #L% */ -package gwt.material.design.incubator.client.chart.chartjs.base.constants; +package gwt.material.design.addins.client.carousel.constants; -public enum ChartType { +public enum RespondTo { - LINE("line"), - BAR("bar"), - RADAR("radar"), - PIE("pie"), - DOUGHNUT("doughnut"), - POLAR_AREA("polarArea"), - BUBBLE("bubble"), - SCATTER("scatter"); + WINDOW("window"), + SLIDER("slider"), + MIN("min"); - private final String name; + private String name; - ChartType(String name) { + RespondTo(String name) { this.name = name; } diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/AfterChangeEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/AfterChangeEvent.java index 2bf470539..cfa12796b 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/events/AfterChangeEvent.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/AfterChangeEvent.java @@ -24,7 +24,7 @@ import com.google.gwt.event.shared.HasHandlers; /** - * After Change Event for Carousel component + * After slide change callback * * @author kevzlou7979 */ diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/BeforeChangeEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/BeforeChangeEvent.java index 81afd13b6..b9ec9f4b2 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/events/BeforeChangeEvent.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/BeforeChangeEvent.java @@ -24,7 +24,7 @@ import com.google.gwt.event.shared.HasHandlers; /** - * BeforeChange Event for Carousel component + * Before slide change callback * * @author kevzlou7979 */ diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/CarouselEvents.java b/src/main/java/gwt/material/design/addins/client/carousel/events/CarouselEvents.java index 892795c52..19d91247b 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/events/CarouselEvents.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/CarouselEvents.java @@ -23,7 +23,12 @@ public interface CarouselEvents { String AFTER_CHANGE = "afterChange"; String BEFORE_CHANGE = "beforeChange"; - String INIT = "init"; String DESTROY = "destroy"; + String EDGE = "edge"; + String INIT = "init"; + String RE_INIT = "reInit"; + String SET_POSITION = "setPosition"; String SWIPE = "swipe"; + String LAZY_LOADED = "lazyLoaded"; + String LAZY_LOAD_ERROR = "lazyLoadError"; } diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/DestroyEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/DestroyEvent.java index 2dd6f60ed..9c1f99760 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/events/DestroyEvent.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/DestroyEvent.java @@ -24,7 +24,7 @@ import com.google.gwt.event.shared.HasHandlers; /** - * Destroy Event for Carousel component + * When slider is destroyed, or unslicked. * * @author kevzlou7979 */ diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/EdgeEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/EdgeEvent.java new file mode 100644 index 000000000..b9c0e1049 --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/EdgeEvent.java @@ -0,0 +1,65 @@ +/* + * #%L + * GwtMaterial + * %% + * Copyright (C) 2015 - 2016 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.carousel.events; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HasHandlers; + +/** + * Fires when an edge is overscrolled in non-infinite mode. + * + * @author kevzlou7979 + */ +public class EdgeEvent extends GwtEvent { + + public interface EdgeHandler extends EventHandler { + void onEdge(EdgeEvent event); + } + + private Object direction; + public static final Type TYPE = new Type<>(); + + public static Type getType() { + return TYPE; + } + + public EdgeEvent(Object direction) { + this.direction = direction; + } + + public static void fire(HasHandlers source, Object direction) { + source.fireEvent(new EdgeEvent(direction)); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(EdgeEvent.EdgeHandler handler) { + handler.onEdge(this); + } + + public Object getDirection() { + return direction; + } +} diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/HasCarouselEvents.java b/src/main/java/gwt/material/design/addins/client/carousel/events/HasCarouselEvents.java index 06c9b05c7..7a8a45143 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/events/HasCarouselEvents.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/HasCarouselEvents.java @@ -34,6 +34,31 @@ public interface HasCarouselEvents extends HasHandlers { */ HandlerRegistration addBeforeChangeHandler(BeforeChangeEvent.BeforeChangeHandler handler); + /** + * Fires when an edge is overscrolled in non-infinite mode. + */ + HandlerRegistration addEdgeHandler(EdgeEvent.EdgeHandler handler); + + /** + * Fires after image loads lazily + */ + HandlerRegistration addLazyLoadedErrorHandler(LazyLoadedErrorEvent.LazyLoadedErrorHandler handler); + + /** + * Fires after image loads lazily + */ + HandlerRegistration addLazyLoadedHandler(LazyLoadedEvent.LazyLoadedHandler handler); + + /** + * Every time Slick (re-)initializes callback + */ + HandlerRegistration addReInitHandler(ReInitEvent.ReInitHandler handler); + + /** + * Every time Slick recalculates position + */ + HandlerRegistration addSetPositionHandler(SetPositionEvent.SetPositionHandler handler); + /** * Fires after first initialization. */ @@ -48,4 +73,6 @@ public interface HasCarouselEvents extends HasHandlers { * Fires after swipe/drag */ HandlerRegistration addSwipeHandler(SwipeEvent.SwipeHandler handler); + + } diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/InitEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/InitEvent.java index 8c5f652dc..d40d3478d 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/events/InitEvent.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/InitEvent.java @@ -24,7 +24,7 @@ import com.google.gwt.event.shared.HasHandlers; /** - * Init Event for Carousel component + * When Slick initializes for the first time callback. Note that this event should be defined before initializing the slider. * * @author kevzlou7979 */ diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/LazyLoadedErrorEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/LazyLoadedErrorEvent.java new file mode 100644 index 000000000..64544dd68 --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/LazyLoadedErrorEvent.java @@ -0,0 +1,72 @@ +/* + * #%L + * GwtMaterial + * %% + * Copyright (C) 2015 - 2016 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.carousel.events; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HasHandlers; + +/** + * Fires after image loads lazily + * + * @author kevzlou7979 + */ +public class LazyLoadedErrorEvent extends GwtEvent { + + public interface LazyLoadedErrorHandler extends EventHandler { + void onLazyLoadedError(LazyLoadedErrorEvent event); + } + + private Object image; + private Object imageSource; + + public static final Type TYPE = new Type<>(); + + public static Type getType() { + return TYPE; + } + + public LazyLoadedErrorEvent(Object image, Object imageSource) { + this.image = image; + this.imageSource = imageSource; + } + + public static void fire(HasHandlers source, Object image, Object imageSource) { + source.fireEvent(new LazyLoadedErrorEvent(image, imageSource)); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(LazyLoadedErrorEvent.LazyLoadedErrorHandler handler) { + handler.onLazyLoadedError(this); + } + + public Object getImage() { + return image; + } + + public Object getImageSource() { + return imageSource; + } +} diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/LazyLoadedEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/LazyLoadedEvent.java new file mode 100644 index 000000000..8c02f9c33 --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/LazyLoadedEvent.java @@ -0,0 +1,72 @@ +/* + * #%L + * GwtMaterial + * %% + * Copyright (C) 2015 - 2016 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.carousel.events; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HasHandlers; + +/** + * Fires after image loads lazily + * + * @author kevzlou7979 + */ +public class LazyLoadedEvent extends GwtEvent { + + public interface LazyLoadedHandler extends EventHandler { + void onLazyLoaded(LazyLoadedEvent event); + } + + private Object image; + private Object imageSource; + + public static final Type TYPE = new Type<>(); + + public static Type getType() { + return TYPE; + } + + public LazyLoadedEvent(Object image, Object imageSource) { + this.image = image; + this.imageSource = imageSource; + } + + public static void fire(HasHandlers source, Object image, Object imageSource) { + source.fireEvent(new LazyLoadedEvent(image, imageSource)); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(LazyLoadedEvent.LazyLoadedHandler handler) { + handler.onLazyLoaded(this); + } + + public Object getImage() { + return image; + } + + public Object getImageSource() { + return imageSource; + } +} diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/ReInitEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/ReInitEvent.java new file mode 100644 index 000000000..00aec1481 --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/ReInitEvent.java @@ -0,0 +1,59 @@ +/* + * #%L + * GwtMaterial + * %% + * Copyright (C) 2015 - 2016 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.carousel.events; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HasHandlers; + +/** + * Every time Slick (re-)initializes callback + * + * @author kevzlou7979 + */ +public class ReInitEvent extends GwtEvent { + + public interface ReInitHandler extends EventHandler { + void onReInit(ReInitEvent event); + } + + public static final Type TYPE = new Type<>(); + + public static Type getType() { + return TYPE; + } + + public ReInitEvent() { + } + + public static void fire(HasHandlers source) { + source.fireEvent(new ReInitEvent()); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(ReInitEvent.ReInitHandler handler) { + handler.onReInit(this); + } +} diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/SetPositionEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/SetPositionEvent.java new file mode 100644 index 000000000..b18306be0 --- /dev/null +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/SetPositionEvent.java @@ -0,0 +1,59 @@ +/* + * #%L + * GwtMaterial + * %% + * Copyright (C) 2015 - 2016 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.carousel.events; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HasHandlers; + +/** + * Every time Slick recalculates position + * + * @author kevzlou7979 + */ +public class SetPositionEvent extends GwtEvent { + + public interface SetPositionHandler extends EventHandler { + void onSetPosition(SetPositionEvent event); + } + + public static final Type TYPE = new Type<>(); + + public static Type getType() { + return TYPE; + } + + public SetPositionEvent() { + } + + public static void fire(HasHandlers source) { + source.fireEvent(new SetPositionEvent()); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(SetPositionEvent.SetPositionHandler handler) { + handler.onSetPosition(this); + } +} diff --git a/src/main/java/gwt/material/design/addins/client/carousel/events/SwipeEvent.java b/src/main/java/gwt/material/design/addins/client/carousel/events/SwipeEvent.java index 6f5a1b15a..e839a431d 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/events/SwipeEvent.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/events/SwipeEvent.java @@ -24,7 +24,7 @@ import com.google.gwt.event.shared.HasHandlers; /** - * Swipe Event for Carousel component + * Fires after swipe/drag * * @author kevzlou7979 */ diff --git a/src/main/java/gwt/material/design/addins/client/carousel/js/JsCarousel.java b/src/main/java/gwt/material/design/addins/client/carousel/js/JsCarousel.java index 1697f4b00..04df5bdbb 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/js/JsCarousel.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/js/JsCarousel.java @@ -50,11 +50,5 @@ public class JsCarousel extends JQueryElement { public native JQueryElement slick(); @JsMethod - public native JavaScriptObject slick(String action); - - @JsMethod - public native JavaScriptObject slick(Object action, Object param2); - - @JsMethod - public native JavaScriptObject slick(Object action, Object param1, Object param2); + public native JavaScriptObject slick(String action, Object params); } diff --git a/src/main/java/gwt/material/design/addins/client/carousel/js/JsCarouselOptions.java b/src/main/java/gwt/material/design/addins/client/carousel/js/JsCarouselOptions.java index d451792ed..c34dda412 100644 --- a/src/main/java/gwt/material/design/addins/client/carousel/js/JsCarouselOptions.java +++ b/src/main/java/gwt/material/design/addins/client/carousel/js/JsCarouselOptions.java @@ -19,6 +19,7 @@ */ package gwt.material.design.addins.client.carousel.js; +import gwt.material.design.jquery.client.api.Functions; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsProperty; @@ -83,10 +84,10 @@ public static JsCarouselOptions create() { public boolean adaptiveHeight; @JsProperty - public boolean autoplay; + public String appendArrows; @JsProperty - public int autoplaySpeed; + public String appendDots; @JsProperty public boolean arrows; @@ -95,16 +96,10 @@ public static JsCarouselOptions create() { public String asNavFor; @JsProperty - public String appendArrows; - - @JsProperty - public String appendDots; - - @JsProperty - public String prevArrow; + public boolean autoplay; @JsProperty - public String nextArrow; + public int autoplaySpeed; @JsProperty public boolean centerMode; @@ -116,16 +111,16 @@ public static JsCarouselOptions create() { public String cssEase; @JsProperty - public boolean dots; + public Functions.Func customPaging; @JsProperty - public boolean draggable; + public boolean dots; @JsProperty - public boolean fade; + public String dotsClass; @JsProperty - public boolean focusOnSelect; + public boolean draggable; @JsProperty public String easing; @@ -134,10 +129,16 @@ public static JsCarouselOptions create() { public double edgeFriction; @JsProperty - public boolean infinite; + public boolean fade; @JsProperty - public boolean variableWidth; + public boolean focusOnSelect; + + @JsProperty + public boolean focusOnChange; + + @JsProperty + public boolean infinite; @JsProperty public int initialSlide; @@ -148,6 +149,12 @@ public static JsCarouselOptions create() { @JsProperty public boolean mobileFirst; + @JsProperty + public String nextArrow; + + @JsProperty + public boolean pauseOnDotsHover; + @JsProperty public boolean pauseOnFocus; @@ -155,20 +162,32 @@ public static JsCarouselOptions create() { public boolean pauseOnHover; @JsProperty - public boolean pauseOnDotsHover; + public String prevArrow; + + @JsProperty + public String respondTo; + + @JsProperty + public JsResponsiveOptions[] responsive; @JsProperty public int rows; @JsProperty - public int slidesPerRow; + public boolean rtl; @JsProperty - public int slidesToShow; + public String slide; + + @JsProperty + public int slidesPerRow; @JsProperty public int slidesToScroll; + @JsProperty + public int slidesToShow; + @JsProperty public int speed; @@ -185,17 +204,23 @@ public static JsCarouselOptions create() { public int touchThreshold; @JsProperty - public boolean vertical; + public boolean useCSS; @JsProperty - public boolean verticalSwiping; + public boolean useTransform; @JsProperty - public boolean rtl; + public boolean variableWidth; + + @JsProperty + public boolean vertical; + + @JsProperty + public boolean verticalSwiping; @JsProperty public boolean waitForAnimate; @JsProperty - public JsResponsiveOptions[] responsive; + public int zIndex; } diff --git a/src/main/java/gwt/material/design/addins/client/circularprogress/MaterialCircularProgress.java b/src/main/java/gwt/material/design/addins/client/circularprogress/MaterialCircularProgress.java index 584bef4ea..71e734b79 100644 --- a/src/main/java/gwt/material/design/addins/client/circularprogress/MaterialCircularProgress.java +++ b/src/main/java/gwt/material/design/addins/client/circularprogress/MaterialCircularProgress.java @@ -76,12 +76,11 @@ public class MaterialCircularProgress extends AbstractValueWidget implem } - private CircularProgressLabel label = new CircularProgressLabel(); + private final CircularProgressLabel label = new CircularProgressLabel(); + private final JsCircularProgressOptions options = JsCircularProgressOptions.create(); private Color fillColor = Color.BLUE; private Color emptyFillColor = Color.GREY_LIGHTEN_2; - private ToggleStyleMixin responsiveMixin; - private JsCircularProgressOptions options = JsCircularProgressOptions.create(); private FontSizeMixin fontSizeMixin; public MaterialCircularProgress() { @@ -92,11 +91,20 @@ public MaterialCircularProgress() { protected void onLoad() { super.onLoad(); + load(); + } - label.setSize(getSize(), isResponsive()); - add(label); - + @Override + public void load() { + if (!label.isAttached()) { + add(label); + label.setSize(getSize(), isResponsive()); + } + loadHandlers(); + Scheduler.get().scheduleDeferred(() -> $(getElement()).circleProgress(options)); + } + public void loadHandlers() { $(getElement()).on(CircularProgressEvents.PROGRESS, (e, progress, step) -> { ProgressEvent.fire(this, (double) progress, (double) step); return true; @@ -110,13 +118,6 @@ protected void onLoad() { CompleteEvent.fire(this, getValue()); return true; }); - - load(); - } - - @Override - public void load() { - Scheduler.get().scheduleDeferred(() -> $(getElement()).circleProgress(options)); } @Override @@ -128,6 +129,11 @@ protected void onUnload() { @Override public void unload() { + + if (label.isAttached()) { + label.removeFromParent(); + } + $(getElement()).off(CircularProgressEvents.START); $(getElement()).off(CircularProgressEvents.PROGRESS); $(getElement()).off(CircularProgressEvents.COMPLETED); @@ -135,8 +141,15 @@ public void unload() { @Override public void reload() { + reload(false); + } + + public void reload(boolean redraw) { unload(); load(); + if (redraw) { + redraw(); + } } @Override @@ -259,7 +272,7 @@ public boolean isResponsive() { * else set it to the default size = 100 **/ public void setResponsive(boolean responsive) { - options.size = responsive == true ? 1000 : 100; + options.size = responsive ? 1000 : 100; getResponsiveMixin().setOn(responsive); } @@ -269,7 +282,7 @@ public CircularProgressLabel getLabel() { public ToggleStyleMixin getResponsiveMixin() { if (responsiveMixin == null) { - responsiveMixin = new ToggleStyleMixin(this, AddinsCssName.RESPONSIVE); + responsiveMixin = new ToggleStyleMixin<>(this, AddinsCssName.RESPONSIVE); } return responsiveMixin; } diff --git a/src/main/java/gwt/material/design/addins/client/circularprogress/js/JsCircularProgress.java b/src/main/java/gwt/material/design/addins/client/circularprogress/js/JsCircularProgress.java index 79bcc8bda..a26419536 100644 --- a/src/main/java/gwt/material/design/addins/client/circularprogress/js/JsCircularProgress.java +++ b/src/main/java/gwt/material/design/addins/client/circularprogress/js/JsCircularProgress.java @@ -49,8 +49,8 @@ public class JsCircularProgress extends JQueryElement { public native JQueryElement circleProgress(); @JsMethod - public native JQueryElement circleProgress(Object param1); + public native JQueryElement circleProgress(String action); @JsMethod - public native JQueryElement circleProgress(Object param1, Object param2); + public native JQueryElement circleProgress(String action, Double params); } diff --git a/src/main/java/gwt/material/design/addins/client/combobox/MaterialComboBox.java b/src/main/java/gwt/material/design/addins/client/combobox/MaterialComboBox.java index 28534f1df..afab6d65a 100644 --- a/src/main/java/gwt/material/design/addins/client/combobox/MaterialComboBox.java +++ b/src/main/java/gwt/material/design/addins/client/combobox/MaterialComboBox.java @@ -25,11 +25,13 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.event.logical.shared.*; import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.Widget; import gwt.material.design.addins.client.MaterialAddins; import gwt.material.design.addins.client.base.constants.AddinsCssName; -import gwt.material.design.addins.client.combobox.base.HasUnselectItemHandler; +import gwt.material.design.addins.client.combobox.async.DefaultComboBoxDisplayLoader; import gwt.material.design.addins.client.combobox.events.ComboBoxEvents; +import gwt.material.design.addins.client.combobox.events.HasComboBoxHandlers; import gwt.material.design.addins.client.combobox.events.SelectItemEvent; import gwt.material.design.addins.client.combobox.events.UnselectItemEvent; import gwt.material.design.addins.client.combobox.js.JsComboBox; @@ -37,7 +39,13 @@ import gwt.material.design.addins.client.combobox.js.LanguageOptions; import gwt.material.design.addins.client.combobox.js.options.Data; import gwt.material.design.addins.client.combobox.js.options.Params; +import gwt.material.design.addins.client.combobox.js.options.Template; +import gwt.material.design.addins.client.dark.AddinsDarkThemeReloader; import gwt.material.design.client.MaterialDesignBase; +import gwt.material.design.client.async.AsyncWidgetCallback; +import gwt.material.design.client.async.IsAsyncWidget; +import gwt.material.design.client.async.loader.AsyncDisplayLoader; +import gwt.material.design.client.async.mixin.AsyncWidgetMixin; import gwt.material.design.client.base.*; import gwt.material.design.client.base.mixin.EnabledMixin; import gwt.material.design.client.base.mixin.FieldTypeMixin; @@ -45,10 +53,15 @@ import gwt.material.design.client.base.mixin.StatusTextMixin; import gwt.material.design.client.constants.CssName; import gwt.material.design.client.constants.FieldType; +import gwt.material.design.client.events.ClearEvent; +import gwt.material.design.client.events.ClearingEvent; +import gwt.material.design.client.events.ClosingEvent; +import gwt.material.design.client.events.OpeningEvent; import gwt.material.design.client.ui.MaterialLabel; import gwt.material.design.client.ui.html.Label; import gwt.material.design.client.ui.html.OptGroup; import gwt.material.design.client.ui.html.Option; +import gwt.material.design.jquery.client.api.Event; import gwt.material.design.jquery.client.api.Functions; import gwt.material.design.jquery.client.api.JQueryElement; @@ -86,7 +99,7 @@ */ //@formatter:on public class MaterialComboBox extends AbstractValueWidget> implements JsLoader, HasPlaceholder, - HasOpenHandlers, HasCloseHandlers, HasUnselectItemHandler, HasReadOnly, HasFieldTypes { + HasComboBoxHandlers, HasReadOnly, HasFieldTypes, IsAsyncWidget>, HasLabel, HasOpenClose { static { if (MaterialAddins.isDebug()) { @@ -99,29 +112,39 @@ public class MaterialComboBox extends AbstractValueWidget> implements } private int selectedIndex; + private boolean open; private boolean suppressChangeEvent; protected List values = new ArrayList<>(); private Label label = new Label(); private MaterialLabel errorLabel = new MaterialLabel(); protected MaterialWidget listbox = new MaterialWidget(Document.get().createSelectElement()); - private KeyFactory keyFactory = Object::toString; + private KeyFactory keyFactory = new AllowBlankKeyFactory<>(); private JsComboBoxOptions options = JsComboBoxOptions.create(); private StatusTextMixin statusTextMixin; private ReadOnlyMixin readOnlyMixin; private EnabledMixin enabledMixin; private FieldTypeMixin fieldTypeMixin; + private AsyncWidgetMixin> asyncWidgetMixin; public MaterialComboBox() { super(Document.get().createDivElement(), CssName.INPUT_FIELD, AddinsCssName.COMBOBOX); + + setAsyncDisplayLoader(new DefaultComboBoxDisplayLoader<>(this)); + } + + public MaterialComboBox(List items) { + this(); + + setItems(items); } @Override protected void onLoad() { label.setInitialClasses(AddinsCssName.SELECT2LABEL); - super.add(listbox); - super.add(label); - super.add(errorLabel); + addWidget(listbox); + addWidget(label); + addWidget(errorLabel); errorLabel.setMarginTop(8); listbox.setGwtDisplay(Style.Display.BLOCK); @@ -134,9 +157,9 @@ protected void onLoad() { @Override public void load() { - JsComboBox jsComboBox = $(listbox.getElement()); + JsComboBox jsComboBox = getJsComboBox(); jsComboBox.select2(options); - + setId(DOM.createUniqueId()); jsComboBox.on(ComboBoxEvents.CHANGE, event -> { if (!suppressChangeEvent) { ValueChangeEvent.fire(this, getValue()); @@ -156,13 +179,44 @@ public void load() { return true; }); + jsComboBox.on(ComboBoxEvents.OPENING, (e, param1) -> { + OpeningEvent.fire(this); + return true; + }); + jsComboBox.on(ComboBoxEvents.OPEN, (event1, o) -> { - OpenEvent.fire(this, null); + if (isAsynchronous()) { + event1.stopPropagation(); + event1.preventDefault(); + load(getAsyncCallback()); + } else { + OpenEvent.fire(this, null); + } + open = true; + return true; + }); + + jsComboBox.on(ComboBoxEvents.CLOSING, (e, param1) -> { + ClosingEvent.fire(this); + if (getValue() != null && !getValue().isEmpty()) { + focus(); + } return true; }); jsComboBox.on(ComboBoxEvents.CLOSE, (event1, o) -> { CloseEvent.fire(this, null); + open = false; + return true; + }); + + jsComboBox.on(ComboBoxEvents.CLEAR, (e, param1) -> { + ClearEvent.fire(this); + return true; + }); + + jsComboBox.on(ComboBoxEvents.CLEARING, (e, param1) -> { + ClearingEvent.fire(this); return true; }); @@ -171,6 +225,9 @@ public void load() { if (getTextColor() != null) { $(getElement()).find(".select2-selection__rendered").css("color", getTextColor().getCssName()); } + + getStatusTextMixin().getStatusDisplayMixin().setContainer(new MaterialWidget($(getElement()))); + AddinsDarkThemeReloader.get().reload(MaterialComboBoxDarkTheme.class); } @Override @@ -182,15 +239,26 @@ protected void onUnload() { @Override public void unload() { - JsComboBox jsComboBox = $(listbox.getElement()); + JsComboBox jsComboBox = getJsComboBox(); jsComboBox.off(ComboBoxEvents.CHANGE); jsComboBox.off(ComboBoxEvents.SELECT); jsComboBox.off(ComboBoxEvents.UNSELECT); jsComboBox.off(ComboBoxEvents.OPEN); jsComboBox.off(ComboBoxEvents.CLOSE); + jsComboBox.off(ComboBoxEvents.CLEAR); + jsComboBox.off(ComboBoxEvents.CLEARING); + body().off("focus"); jsComboBox.select2("destroy"); } + public void focus() { + getJsComboBox().select2("focus"); + } + + public void destroy() { + getJsComboBox().select2("destroy"); + } + @Override public void reload() { unload(); @@ -201,7 +269,6 @@ public void reload() { public void reset() { super.reset(); displayArrowForAllowClearOption(false); - setSelectedIndex(0); } @Override @@ -218,6 +285,48 @@ public void add(Widget child) { listbox.add(child); } + /** + * Programmatically open the combobox component + */ + @Override + public void open() { + getJsComboBox().select2("open"); + } + + /** + * Programmatically close the combobox component + */ + @Override + public void close() { + getJsComboBox().select2("close"); + } + + @Override + public boolean isOpen() { + return open; + } + + @Override + public void clear() { + final Iterator it = iterator(); + while (it.hasNext()) { + final Widget widget = it.next(); + if (widget != label && widget != errorLabel && widget != listbox) { + it.remove(); + } + } + listbox.clear(); + values.clear(); + } + + public boolean isInitialized() { + return getJsComboBox().hasClass("select2-hidden-accessible"); + } + + public void addWidget(Widget widget) { + super.add(widget); + } + /** * Add OptionGroup directly to combobox component * @@ -267,7 +376,9 @@ public void setItems(Collection items) { } public void addItems(Collection items) { - items.forEach(this::addItem); + if (items != null) { + items.forEach(this::addItem); + } } /** @@ -280,33 +391,6 @@ protected Option buildOption(String text, T value) { return option; } - /** - * Programmatically open the combobox component - */ - public void open() { - $(listbox.getElement()).select2("open"); - } - - /** - * Programmatically close the combobox component - */ - public void close() { - $(listbox.getElement()).select2("close"); - } - - @Override - public void clear() { - final Iterator it = iterator(); - while (it.hasNext()) { - final Widget widget = it.next(); - if (widget != label && widget != errorLabel && widget != listbox) { - it.remove(); - } - } - listbox.clear(); - values.clear(); - } - /** * Sets the parent element of the dropdown */ @@ -371,10 +455,17 @@ public JQueryElement getDropdownContainerElement() { /** * Set the upper label above the combobox */ + @Override public void setLabel(String text) { label.setText(text); } + @Override + public String getLabel() { + return label.getText(); + } + + @Override public String getPlaceholder() { return options.placeholder; @@ -445,16 +536,12 @@ public boolean isMultiple() { */ public void setMultiple(boolean multiple) { if (multiple) { - $(listbox.getElement()).attr("multiple", "multiple"); + getJsComboBox().attr("multiple", "multiple"); } else { - $(listbox.getElement()).removeAttr("multiple"); + getJsComboBox().removeAttr("multiple"); } } - public void setMatcher(Functions.FuncRet2 matcher) { - options.matcher = matcher; - } - public void setAcceptableValues(Collection values) { setItems(values); } @@ -464,15 +551,20 @@ public List getValue() { if (!isMultiple()) { int index = getSelectedIndex(); T value; - if (index != -1) { + if (index != -1) { // Check when the value is a custom tag if (isTags()) { - value = (T) $(listbox.getElement()).val(); + value = (T) getJsComboBox().val(); } else { value = values.get(index); } + // Check whether we add an item with null value + if (index == 0 && value == null) { + return isAllowBlank() ? new ArrayList<>() : null; + } + return Collections.singletonList(value); } } else { @@ -496,7 +588,7 @@ public List getSelectedValue() { */ public T getSingleValue() { List values = getSelectedValue(); - if (!values.isEmpty()) { + if (values != null && !values.isEmpty()) { return values.get(0); } return null; @@ -517,7 +609,13 @@ public void setSingleValue(T value) { @Override public void setValue(List values, boolean fireEvents) { - if (!isMultiple()) { + if (values == null) { + reset(); + + if (fireEvents) { + ValueChangeEvent.fire(this, null); + } + } else if (!isMultiple()) { if (!values.isEmpty()) { setSingleValue(values.get(0), fireEvents); } @@ -532,7 +630,11 @@ public void setValue(List values, boolean fireEvents) { */ public void setSingleValue(T value, boolean fireEvents) { int index = this.values.indexOf(value); - if (index >= 0) { + if (index < 0 && value instanceof String) { + index = getIndexByString((String) value); + } + + if (index > -1) { List before = getValue(); setSelectedIndex(index); @@ -542,6 +644,28 @@ public void setSingleValue(T value, boolean fireEvents) { } } + // TODO: Optimize performance (maybe use a map) + public T getValueByString(String key) { + for (T value : values) { + if (keyFactory.generateKey(value).equals(key)) { + return value; + } + } + return null; + } + + // TODO: Optimize performance (maybe use a map) + public int getIndexByString(String key) { + int index = -1; + + for (T value : values) { + if (keyFactory.generateKey(value).equals(key)) { + return values.indexOf(value); + } + } + return index; + } + /** * Set directly all the values that will be stored into * combobox and build options into it. @@ -560,7 +684,7 @@ public void setValues(List values, boolean fireEvents) { stringValues[i] = keyFactory.generateKey(values.get(i)); } suppressChangeEvent = !fireEvents; - $(listbox.getElement()).val(stringValues).trigger("change", selectedIndex); + getJsComboBox().val(stringValues).trigger("change", selectedIndex); suppressChangeEvent = false; } @@ -585,8 +709,8 @@ public void setSelectedIndex(int selectedIndex) { this.selectedIndex = selectedIndex; if (values.size() > 0) { T value = values.get(selectedIndex); - if (value != null) { - $(listbox.getElement()).val(keyFactory.generateKey(value)).trigger("change.select2", selectedIndex); + if (value != null || isAllowBlank()) { + getJsComboBox().val(keyFactory.generateKey(value)).trigger("change.select2", selectedIndex); } else { GWT.log("Value index is not found.", new IndexOutOfBoundsException()); } @@ -607,6 +731,11 @@ public int getSelectedIndex() { return -1; } + public void unselect() { + getJsComboBox().val("").change(); + getJsComboBox().trigger(new Event(ComboBoxEvents.UNSELECT)); + } + /** * Get all the values sets on combobox */ @@ -618,7 +747,7 @@ public List getValues() { * Get the selected vales from multiple combobox */ public List getSelectedValues() { - Object[] curVal = (Object[]) $(listbox.getElement()).val(); + Object[] curVal = (Object[]) getJsComboBox().val(); List selectedValues = new ArrayList<>(); if (curVal == null || curVal.length < 1) { @@ -699,7 +828,7 @@ public MaterialWidget getListbox() { return listbox; } - public Label getLabel() { + public Label getLabelWidget() { return label; } @@ -730,6 +859,303 @@ public LanguageOptions getLanguage() { return options.language; } + /** + * Supports customization of the container width. + * + * @see Example + */ + public void setContainerWidth(String width) { + options.width = width; + } + + public String getContainerWidth() { + return options.width; + } + + public Object getContainerCss() { + return options.containerCss; + } + + /** + * Adds custom CSS to the container. Expects key-value pairs: + *
+     * { 'css-property': 'value' }
+     * 
+ */ + public void setContainerCss(Object containerCss) { + this.options.containerCss = containerCss; + } + + public String getContainerCssClass() { + return options.containerCssClass; + } + + /** + * Appended a class to the container + */ + public void setContainerCssClass(String containerCssClass) { + this.options.containerCssClass = containerCssClass; + } + + public Object[] getData() { + return options.data; + } + + /** + * Allows rendering dropdown options from an array. + */ + public void setData(Object[] data) { + this.options.data = data; + } + + public Object getDataAdapter() { + return options.dataAdapter; + } + + /** + * Used to override the built-in DataAdapter. + */ + public void setDataAdapter(Object dataAdapter) { + this.options.dataAdapter = dataAdapter; + } + + public boolean isDebug() { + return options.debug; + } + + /** + * Enable debugging messages in the browser console. + */ + public void setDebug(boolean debug) { + this.options.debug = debug; + } + + public Object getDir() { + return options.dir; + } + + public void setDir(Object dir) { + this.options.dir = dir; + } + + public Object getDropdownAdapter() { + return options.dropdownAdapter; + } + + /** + * Used to override the built-in DropdownAdapter + */ + public void setDropdownAdapter(Object dropdownAdapter) { + this.options.dropdownAdapter = dropdownAdapter; + } + + public boolean isDropdownAutoWidth() { + return options.dropdownAutoWidth; + } + + /** + * Will adapt dropdown width to it's parent + */ + public void setDropdownAutoWidth(boolean dropdownAutoWidth) { + this.options.dropdownAutoWidth = dropdownAutoWidth; + } + + public Object getDropdownCss() { + return options.dropdownCss; + } + + /** + * Adds custom CSS to the dropdown. Expects key-value pairs: + *
+     * { 'css-property': 'value' }
+     * 
+ */ + public void setDropdownCss(Object dropdownCss) { + this.options.dropdownCss = dropdownCss; + } + + public String getDropdownCssClass() { + return options.dropdownCssClass; + } + + public void setDropdownCssClass(String dropdownCssClass) { + this.options.dropdownCssClass = dropdownCssClass; + } + + /** + * Append Css class to the dropdown + */ + public void setDropdownParent(JQueryElement dropdownParent) { + this.options.dropdownParent = dropdownParent; + } + + public Functions.Func getEscapeMarkup() { + return options.escapeMarkup; + } + + /** + * Handles automatic escaping of content rendered by custom templates. + */ + public void setEscapeMarkup(Functions.Func escapeMarkup) { + this.options.escapeMarkup = escapeMarkup; + } + + public Functions.FuncRet2 getMatcher() { + return options.matcher; + } + + /** + * Handles custom search matching. + */ + public void setMatcher(Functions.FuncRet2 matcher) { + options.matcher = matcher; + } + + public int getMaximumInputLength() { + return options.maximumInputLength; + } + + /** + * Maximum number of characters that may be provided for a search term. + */ + public void setMaximumInputLength(int maximumInputLength) { + this.options.maximumInputLength = maximumInputLength; + } + + public int getMaximumSelectionLength() { + return options.maximumSelectionLength; + } + + /** + * The maximum number of items that may be selected in a multi-select control. If the value of this option is less + * than 1, the number of selected items will not be limited. + */ + public void setMaximumSelectionLength(int maximumSelectionLength) { + this.options.maximumSelectionLength = maximumSelectionLength; + } + + public int getMinimumInputLength() { + return options.minimumInputLength; + } + + /** + * Minimum number of characters required to start a search. + */ + public void setMinimumInputLength(int minimumInputLength) { + this.options.minimumInputLength = minimumInputLength; + } + + public String getMinimumResultsForSearch() { + return options.minimumResultsForSearch; + } + + /** + * The minimum number of results required to display the search box. + */ + public void setMinimumResultsForSearch(String minimumResultsForSearch) { + this.options.minimumResultsForSearch = minimumResultsForSearch; + } + + public Object getResultsAdapter() { + return options.resultsAdapter; + } + + /** + * Used to override the built-in ResultsAdapter. + */ + public void setResultsAdapter(Object resultsAdapter) { + this.options.resultsAdapter = resultsAdapter; + } + + public Object getSelectionAdapter() { + return options.selectionAdapter; + } + + /** + * Used to override the built-in SelectionAdapter. + */ + public void setSelectionAdapter(Object selectionAdapter) { + this.options.selectionAdapter = selectionAdapter; + } + + public boolean isSelectOnClose() { + return options.selectOnClose; + } + + /** + * Implements automatic selection when the dropdown is closed. + */ + public void setSelectOnClose(boolean selectOnClose) { + this.options.selectOnClose = selectOnClose; + } + + public Functions.Func getSorter() { + return options.sorter; + } + + public void setSorter(Functions.Func sorter) { + this.options.sorter = sorter; + } + + public Functions.FuncRet1