Skip to content

Commit a9f00d9

Browse files
committed
Fixed MaterialListValueBox documentation and codeblocks #90
1 parent c942368 commit a9f00d9

File tree

3 files changed

+81
-4
lines changed

3 files changed

+81
-4
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<parent>
55
<artifactId>gwt-material-parent</artifactId>
66
<groupId>com.github.gwtmaterialdesign</groupId>
7-
<version>2.0</version>
7+
<version>2.0.1-SNAPSHOT</version>
88
</parent>
99

1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<artifactId>gwt-material-demo</artifactId>
1313
<packaging>war</packaging>
14-
<version>2.0</version>
14+
<version>2.0.1-SNAPSHOT</version>
1515
<name>Gwt Material Demo</name>
1616
<description>Showcase for gwt-material</description>
1717

@@ -34,7 +34,7 @@
3434
<gwt.version>2.8.1</gwt.version>
3535
<gwtp.version>1.5.3</gwtp.version>
3636
<gin.version>2.1.2</gin.version>
37-
<gwt-material.version>2.0</gwt-material.version>
37+
<gwt-material.version>2.0.1-SNAPSHOT</gwt-material.version>
3838

3939
<gwt.style>PRETTY</gwt.style>
4040

src/main/java/gwt/material/design/demo/client/application/components/forms/listbox/ListBoxView.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,49 @@
2929
import com.google.gwt.user.client.ui.Widget;
3030
import com.gwtplatform.mvp.client.ViewImpl;
3131
import gwt.material.design.client.ui.MaterialListBox;
32+
import gwt.material.design.client.ui.MaterialListValueBox;
3233
import gwt.material.design.client.ui.MaterialToast;
34+
import gwt.material.design.demo.client.application.dto.DataHelper;
35+
import gwt.material.design.demo.client.application.dto.Hero;
3336

3437
import javax.inject.Inject;
3538

3639
public class ListBoxView extends ViewImpl implements ListBoxPresenter.MyView {
3740
interface Binder extends UiBinder<Widget, ListBoxView> {
3841
}
3942

40-
@UiField MaterialListBox lstOptions, lstSetValue, lstAddOptions, lstRemoveOptions, lstLazy;
43+
@UiField
44+
MaterialListBox lstOptions, lstSetValue, lstAddOptions, lstRemoveOptions, lstLazy;
45+
46+
@UiField
47+
MaterialListValueBox<Hero> lstValueBox, lstValueBoxMultiple, lstEmptyPlacehoder, lstFocusAndBlur;
4148

4249
@Inject
4350
ListBoxView(Binder uiBinder) {
4451
initWidget(uiBinder.createAndBindUi(this));
52+
53+
buildListHeroes(lstValueBoxMultiple);
54+
buildListHeroes(lstValueBox);
55+
buildListHeroes(lstEmptyPlacehoder);
56+
57+
lstFocusAndBlur.addFocusHandler(focusEvent -> MaterialToast.fireToast("Focus Event Fired"));
58+
lstFocusAndBlur.addBlurHandler(blurEvent -> MaterialToast.fireToast("Blur Event Fired"));
59+
buildListHeroes(lstFocusAndBlur);
60+
61+
lstOptions.addFocusHandler(focusEvent -> {
62+
MaterialToast.fireToast("FOCUSED");
63+
});
64+
65+
lstOptions.addBlurHandler(blurEvent -> {
66+
MaterialToast.fireToast("BLURRED");
67+
});
68+
}
69+
70+
protected void buildListHeroes(MaterialListValueBox<Hero> listBox) {
71+
listBox.addValueChangeHandler(valueChangeEvent -> MaterialToast.fireToast("VALUE [ " + valueChangeEvent.getValue().getName() + " ]"));
72+
for (Hero hero : DataHelper.getAllHeroes()) {
73+
listBox.addItem(hero, hero.getName());
74+
}
4575
}
4676

4777
@UiHandler("addItems")

src/main/java/gwt/material/design/demo/client/application/components/forms/listbox/ListBoxView.ui.xml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@
4949
</demo:PrettyPre>
5050
</m:MaterialRow>
5151

52+
<m:MaterialRow addStyleNames="code">
53+
<m:MaterialTitle title="Using MaterialListValueBox" description="You can easily set the generic param with your desired object into the MaterialListValueBox." />
54+
<m:MaterialListValueBox ui:field="lstValueBox" placeholder="Choose your hero" grid="s12"/>
55+
<demo:PrettyPre addStyleNames="lang-xml">
56+
&emsp;// UiBinder<br/>
57+
&lt;m:MaterialListValueBox ui:field="lstIntegerListBox" placeholder="Choose your hero" grid="s12"/>
58+
</demo:PrettyPre>
59+
<demo:PrettyPre addStyleNames="lang-java">
60+
&emsp;// Java <br/>
61+
@UiField <br/>
62+
MaterialListValueBox&lt;Hero> lstIntegerListBox; <br/><br/>
63+
64+
for (Hero hero : DataHelper.getAllHeroes()) { <br/>
65+
&emsp;lstIntegerListBox.addItem(hero, hero.getName()); <br/>
66+
} <br/><br/>
67+
68+
lstIntegerListBox.addValueChangeHandler(valueChangeEvent -> { <br/>
69+
&emsp;MaterialToast.fireToast("VALUE: " + valueChangeEvent.getValue().getName()); <br/>
70+
});
71+
</demo:PrettyPre>
72+
</m:MaterialRow>
73+
5274
<m:MaterialRow addStyleNames="code">
5375
<m:MaterialTitle title="Add Option" description="You can easily add an item by calling addItem(Item)"/>
5476
<m:MaterialListBox placeholder="ListBox" grid="s12" ui:field="lstAddOptions">
@@ -162,6 +184,31 @@
162184
</demo:PrettyPre>
163185
</m:MaterialRow>
164186

187+
188+
<m:MaterialRow addStyleNames="code">
189+
<m:MaterialBadge text="FEATURE UPDATE" textColor="AMBER" shadow="1" layoutPosition="RELATIVE" float="RIGHT" backgroundColor="AMBER_LIGHTEN_5" />
190+
<m:MaterialTitle title="Empty Placeholder" />
191+
<m:MaterialListValueBox ui:field="lstEmptyPlacehoder" emptyPlaceHolder="Select your Hero" grid="s12"/>
192+
<demo:PrettyPre addStyleNames="lang-xml">
193+
&emsp;&lt;m:MaterialListValueBox ui:field="lstEmptyPlacehoder" emptyPlaceHolder="Select your Hero"/>
194+
</demo:PrettyPre>
195+
</m:MaterialRow>
196+
197+
<m:MaterialRow addStyleNames="code">
198+
<m:MaterialBadge text="FEATURE UPDATE" textColor="AMBER" shadow="1" layoutPosition="RELATIVE" float="RIGHT" backgroundColor="AMBER_LIGHTEN_5" />
199+
<m:MaterialTitle title="Focus and Blur Handlers" />
200+
<m:MaterialListValueBox ui:field="lstFocusAndBlur" placeholder="Select your Hero" grid="s12"/>
201+
<demo:PrettyPre addStyleNames="lang-java">
202+
&emsp;lstOptions.addFocusHandler(focusEvent -> { <br/>
203+
&emsp;MaterialToast.fireToast("FOCUSED");<br/>
204+
});<br/><br/>
205+
206+
lstOptions.addBlurHandler(blurEvent -> {<br/>
207+
&emsp;MaterialToast.fireToast("BLURRED");<br/>
208+
});
209+
</demo:PrettyPre>
210+
</m:MaterialRow>
211+
165212
<m:MaterialRow addStyleNames="code">
166213
<m:MaterialBadge text="FEATURE UPDATE" textColor="AMBER" shadow="1" layoutPosition="RELATIVE" float="RIGHT" backgroundColor="AMBER_LIGHTEN_5" />
167214
<m:MaterialTitle title="ListBox : Lazyload"/>

0 commit comments

Comments
 (0)