Skip to content

Commit

Permalink
Merge pull request #169 from GwtMaterialDesign/release_2.0
Browse files Browse the repository at this point in the history
Release 2.0-rc4
  • Loading branch information
kevzlou7979 authored Mar 8, 2017
2 parents 41858f7 + a53e294 commit 35777ed
Show file tree
Hide file tree
Showing 40 changed files with 609 additions and 160 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Gwt Material Design Extra Components for https://github.com/GwtMaterialDesign/gw
<dependency>
<groupId>com.github.gwtmaterialdesign</groupId>
<artifactId>gwt-material-addins</artifactId>
<version>2.0-rc3</version>
<version>2.0-rc4</version>
</dependency>
```

Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
<parent>
<artifactId>gwt-material-parent</artifactId>
<groupId>com.github.gwtmaterialdesign</groupId>
<version>2.0-rc3</version>
<version>2.0-SNAPSHOT</version>
</parent>

<artifactId>gwt-material-addins</artifactId>

<name>Gwt Material Addins</name>
<version>2.0-rc3</version>
<version>2.0-SNAPSHOT</version>
<description>Extra Components of GWT Material Framework</description>

<properties>
<gwt-material.version>2.0-rc3</gwt-material.version>
<gwt-material.version>2.0-SNAPSHOT</gwt-material.version>
</properties>

<scm>
<connection>scm:git:git@github.com:GwtMaterialDesign/gwt-material-addins.git</connection>
<developerConnection>scm:git:git@github.com:GwtMaterialDesign/gwt-material-addins.git</developerConnection>
<url>http://github.com/GwtMaterialDesign/gwt-material-addins</url>
<tag>v2.0-rc3</tag>
<tag>v2.0-SNAPSHOT</tag>
</scm>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public class MaterialAutoComplete extends AbstractValueWidget<List<? extends Sug
private FocusableMixin<MaterialWidget> focusableMixin;
private ReadOnlyMixin<MaterialAutoComplete, TextBox> readOnlyMixin;

public final CssTypeMixin<AutocompleteType, MaterialAutoComplete> typeMixin = new CssTypeMixin<>(this);
public final CssTypeMixin<AutocompleteType, MaterialAutoComplete> typeMixin = new CssTypeMixin<>(this, this);

/**
* Use MaterialAutocomplete to search for matches from local or remote data
Expand Down Expand Up @@ -260,7 +260,11 @@ protected void generateAutoComplete(SuggestOracle suggestions) {
directInput.setDisplay(value);
directInput.setSuggestion(value);
changed = addItem(directInput);
itemBox.setValue("");
if (getType() == AutocompleteType.TEXT) {
itemBox.setText(value);
} else {
itemBox.setValue("");
}
itemBox.setFocus(true);
}
}
Expand Down Expand Up @@ -382,9 +386,8 @@ protected boolean addItem(final Suggestion suggestion) {

suggestionMap.put(suggestion, chip);
displayItem.add(chip);
list.insert(displayItem, list.getWidgetCount() - 1);
}

list.insert(displayItem, list.getWidgetCount() - 1);
return true;
}

Expand Down Expand Up @@ -433,20 +436,28 @@ public List<String> getItemValues() {
* @see #setValue(Object)
*/
public void setItemValues(List<String> itemValues) {
setItemValues(itemValues, false);
}

/**
* @param itemValues the itemsSelected to set
* @param fireEvents will fire value change event if true
* @see #setValue(Object)
*/
public void setItemValues(List<String> itemValues, boolean fireEvents) {
if (itemValues == null) {
clear();
return;
}
List<Suggestion> list = new ArrayList<>(itemValues.size());
lblPlaceholder.addStyleName(CssName.ACTIVE);
for (String value : itemValues) {
Suggestion suggestion = new gwt.material.design.client.base.Suggestion(value, value);
list.add(suggestion);
}
setValue(list, fireEvents);
if (itemValues.size() > 0) {
lblPlaceholder.addStyleName(CssName.ACTIVE);
}
setValue(list);
}

/**
Expand Down Expand Up @@ -643,7 +654,7 @@ public boolean isToggleReadOnly() {
* Interface that defines how a {@link MaterialChip} is created, given a
* {@link Suggestion}.
*
* @see gwt.material.design.addins.client.autocomplete.MaterialAutoComplete#setChipProvider(MaterialChipProvider)
* @see MaterialAutoComplete#setChipProvider(MaterialChipProvider)
*/
public static interface MaterialChipProvider {

Expand Down Expand Up @@ -683,13 +694,13 @@ public static interface MaterialChipProvider {

/**
* Default implementation of the {@link MaterialChipProvider} interface,
* used by the {@link gwt.material.design.addins.client.autocomplete.MaterialAutoComplete}.
* used by the {@link MaterialAutoComplete}.
* <p>
* <p>
* By default all chips are selectable and removable. The default {@link IconType} used by the chips provided is the {@link IconType#CLOSE}.
* </p>
*
* @see gwt.material.design.addins.client.autocomplete.MaterialAutoComplete#setChipProvider(MaterialChipProvider)
* @see MaterialAutoComplete#setChipProvider(MaterialChipProvider)
*/
public static class DefaultMaterialChipProvider implements MaterialChipProvider {

Expand Down Expand Up @@ -770,6 +781,7 @@ public List<? extends Suggestion> getValue() {
public void setValue(List<? extends Suggestion> value, boolean fireEvents) {
clear();
if (value != null) {
lblPlaceholder.addStyleName(CssName.ACTIVE);
for (Suggestion suggestion : value) {
addItem(suggestion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import static gwt.material.design.addins.client.combobox.js.JsComboBox.$;
Expand Down Expand Up @@ -128,7 +129,7 @@ protected void onLoad() {
super.add(listbox);
super.add(label);
lblError.setLayoutPosition(Style.Position.ABSOLUTE);
lblError.setMarginTop(12);
lblError.setMarginTop(15);
super.add(lblError);
setId(uid);

Expand Down Expand Up @@ -245,6 +246,11 @@ public void setEnabled(boolean enabled) {
listbox.setEnabled(enabled);
}

@Override
public boolean isEnabled() {
return listbox.isEnabled();
}

/**
* Check if allow clear option is enabled
*/
Expand Down Expand Up @@ -296,7 +302,6 @@ public boolean isMultiple() {

@Override
public void setAcceptableValues(Collection<T> values) {
this.values.clear();
clear();
for (T value : values) {
addItem(value);
Expand Down Expand Up @@ -330,7 +335,7 @@ public void setValue(T value) {
@Override
public void setValue(T value, boolean fireEvents) {
int index = values.indexOf(value);
if (index > 0) {
if (index >= 0) {
T before = getValue();
setSelectedIndex(index);

Expand Down Expand Up @@ -425,7 +430,7 @@ public void setSelectedIndex(int selectedIndex) {
this.selectedIndex = selectedIndex;
T value = values.get(selectedIndex);
if (value != null) {
$(listbox.getElement()).val(value.toString()).trigger("change", selectedIndex);
$(listbox.getElement()).val(value.toString()).trigger("change.select2", selectedIndex);
} else {
GWT.log("Value index is not found.", new IndexOutOfBoundsException());
}
Expand Down Expand Up @@ -497,6 +502,19 @@ public void close() {
$(listbox.getElement()).select2("close");
}

@Override
public void clear() {
final Iterator<Widget> it = iterator();
while (it.hasNext()) {
final Widget widget = it.next();
if (widget != label && widget != lblError && widget != listbox) {
it.remove();
}
}
listbox.clear();
values.clear();
}

/**
* Use your own key factory for value keys.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package gwt.material.design.addins.client.fileuploader;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.shared.HandlerRegistration;
Expand Down Expand Up @@ -88,6 +89,7 @@ public class MaterialFileUploader extends MaterialWidget implements HasFileUploa
private Dropzone uploader;
private JsFileUploaderOptions options;
private MaterialUploadPreview uploadPreview = new MaterialUploadPreview();
private boolean enabled = true;

public MaterialFileUploader() {
super(Document.get().createDivElement(), AddinsCssName.FILEUPLOADER);
Expand Down Expand Up @@ -127,32 +129,61 @@ protected void onLoad() {
if (!isInitialize()) {
initDropzone();
setInitialize(true);
applyEnabled();
}
}

public void initDropzone() {
String previews = DOM.createUniqueId();
uploadPreview.getUploadCollection().setId(previews);
if (options.clickable.isEmpty()) {
String clickable = DOM.createUniqueId();
if (getWidget(1) instanceof MaterialUploadLabel) {
MaterialUploadLabel label = (MaterialUploadLabel) getWidget(1);
label.getIcon().setId(clickable);
@Override
public void setEnabled(boolean enabled) {
this.enabled = enabled;
applyEnabled();
}

@Override
public boolean isEnabled() {
return enabled;
}

protected void applyEnabled() {
if (uploader != null) {
if (!enabled) {
addStyleName(CssName.DISABLED);
uploader.removeEventListeners();
} else {
getWidget(1).getElement().setId(clickable);
removeStyleName(CssName.DISABLED);
uploader.setupEventListeners();
}
setClickable(clickable);
}
}

if (!isPreview()) {
uploadPreview.setDisplay(Display.NONE);
}
public void initDropzone() {
if (getWidgetCount() > 1) {
String previews = DOM.createUniqueId();
uploadPreview.getUploadCollection().setId(previews);
if (options.clickable.isEmpty()) {
String clickable = DOM.createUniqueId();

if (getWidget(1) instanceof MaterialUploadLabel) {
MaterialUploadLabel label = (MaterialUploadLabel) getWidget(1);
label.getIcon().setId(clickable);
} else {
getWidget(1).getElement().setId(clickable);
}
setClickable(clickable);
}

initDropzone(getElement(),
uploadPreview.getUploadCollection().getItem().getElement(),
previews,
uploadPreview.getElement(),
uploadPreview.getUploadHeader().getUploadedFiles().getElement());
if (!isPreview()) {
uploadPreview.setDisplay(Display.NONE);
}

initDropzone(getElement(),
uploadPreview.getUploadCollection().getItem().getElement(),
previews,
uploadPreview.getElement(),
uploadPreview.getUploadHeader().getUploadedFiles().getElement());
}else {
GWT.log("You don't have any child widget to use as a upload label");
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ public Dropzone(Element e, JsFileUploaderOptions options) {

public native Dropzone on(String events, Functions.Func2<File, String> callback);

public native void removeEventListeners();

public native void setupEventListeners();

public native void removeAllFiles();
}
Loading

0 comments on commit 35777ed

Please sign in to comment.