|
25 | 25 | xmlns:demo="urn:import:gwt.material.design.demo.client.ui" |
26 | 26 | xmlns:m.demo="urn:import:gwt.material.design.demo.client.ui"> |
27 | 27 | <g:HTMLPanel> |
28 | | - |
29 | | - <m:MaterialTitle title="Usage" /> |
30 | | - <demo:PrettyPre addStyleNames="lang-xml z-depth-1"> |
31 | | -  <!-- Addin Import --><br/> |
32 | | - xmlns:ma="urn:import:gwt.material.design.addins.client"<br/><br/> |
33 | | - <!-- Addin Usage --><br/> |
34 | | - <ma:autocomplete.MaterialAutoComplete placeholder="Contacts"/> |
35 | | - </demo:PrettyPre> |
36 | | - |
37 | | - <m:MaterialTitle title="Autocomplete" description="Use GWT Autocomplete to search for matches from local or remote data sources. We used MultiWordSuggestOracle to populate the list to be added on the autocomplete values"/> |
38 | | - <m:MaterialRow> |
39 | | - <m:MaterialColumn grid="s12 m12 l6"> |
40 | | - <ma:autocomplete.MaterialAutoComplete ui:field="acList" placeholder="Contacts" /> |
41 | | - </m:MaterialColumn> |
| 28 | + |
| 29 | + <m:MaterialRow addStyleNames="code"> |
| 30 | + <m:MaterialTitle title="Usage" /> |
| 31 | + <demo:PrettyPre addStyleNames="lang-xml"> |
| 32 | +  <!-- Addin Import --><br/> |
| 33 | + xmlns:ma="urn:import:gwt.material.design.addins.client"<br/><br/> |
| 34 | + <!-- Addin Usage --><br/> |
| 35 | + <ma:autocomplete.MaterialAutoComplete placeholder="Contacts"/> |
| 36 | + </demo:PrettyPre> |
42 | 37 | </m:MaterialRow> |
| 38 | + |
| 39 | + <g:HTMLPanel addStyleNames="code"> |
| 40 | + <m:MaterialTitle title="Autocomplete" description="Use GWT Autocomplete to search for matches from local or remote data sources. We used MultiWordSuggestOracle to populate the list to be added on the autocomplete values"/> |
| 41 | + <m:MaterialRow> |
| 42 | + <m:MaterialColumn grid="s12 m12 l6"> |
| 43 | + <ma:autocomplete.MaterialAutoComplete ui:field="acList" placeholder="Contacts" /> |
| 44 | + </m:MaterialColumn> |
| 45 | + </m:MaterialRow> |
43 | 46 |
|
44 | | - <blockquote > |
45 | | - <p>You can click the chips to select it.</p> |
46 | | - <p>Perform any keyboard actions like pressing KEY DELETE and KEY BACKSPACE to remove it from the autocomplete values</p> |
47 | | - <p>By calling automcomplte.getItemValues() you will retrieve all the items that is currently on the Autocomplete Field</p> |
48 | | - <p>If the value is already exist, we automatically remove it when adding</p> |
49 | | - <p>You can add an unknown value by typing new one then PRESS ENTER</p> |
50 | | - <p>To disable , add enabled="false" parameter on the autocomplete widget</p> |
51 | | - </blockquote> |
52 | | - |
53 | | - <m:MaterialButton ui:field="btnGetAll" text="Get All States" waves="LIGHT" backgroundColor="BLUE"/> |
54 | | - <m:MaterialButton ui:field="btnClear" text="Clear" waves="DEFAULT" textColor="BLACK" backgroundColor="WHITE"/> |
55 | | - |
56 | | - <m.demo:PrettyPre addStyleNames="lang-java z-depth-1"> |
57 | | -  @UiField MaterialAutoComplete acList; <br/><br/> |
58 | | - |
59 | | - UserOracle oracle = new UserOracle();<br/> |
60 | | - oracle.addContacts(getAllUsers());<br/> |
61 | | - acList.setSuggestions(oracle); |
62 | | - </m.demo:PrettyPre> |
63 | | - |
64 | | - <m:MaterialTitle title="Gist Files" description="With the given example, we use UserOracle, User and UserSuggestion in order to build the Autocomplete more flexible." /> |
65 | | - <m:MaterialAnchorButton text="Link to Gist" textColor="WHITE" target="_blank" href="https://gist.github.com/kevzlou7979/dfb18c003513311345e53af7253b1e39" /> |
66 | | - |
67 | | - <m:MaterialTitle title="Get all Selected Items" /> |
68 | | - <demo:PrettyPre addStyleNames="lang-java z-depth-1"> |
69 | | -  public List<User> getSelectedUsers() {<br/> |
70 | | -  List<? extends SuggestOracle.Suggestion> values = acList.getValue();<br/> |
71 | | -  List<User> users = new ArrayList<>(values.size());<br/> |
72 | | -  for(SuggestOracle.Suggestion value : values){<br/> |
73 | | -   if(value instanceof UserSuggestion){<br/> |
74 | | -    UserSuggestion us = (UserSuggestion) value;<br/> |
75 | | -    User user = us.getUser();<br/> |
76 | | -    users.add(user);<br/> |
77 | | -   }<br/> |
78 | | -  }<br/> |
79 | | -  return users;<br/> |
80 | | - } |
81 | | - </demo:PrettyPre> |
82 | | - |
83 | | - <m:MaterialTitle title="Events" description="You can easily add Value Change Event and Selection Event on autocomplete component."/> |
84 | | - <demo:PrettyPre addStyleNames="lang-xml z-depth-1"> |
85 | | -  <acList.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {<br/> |
86 | | -  @Override<br/> |
87 | | -  public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {<br/> |
88 | | -   MaterialToast.fireToast(event.getSelectedItem().getDisplayString() + " Selected");<br/> |
89 | | -  }<br/> |
90 | | - });<br/><br/> |
91 | | - acList.addValueChangeHandler(new ValueChangeHandler<List<? extends SuggestOracle.Suggestion>>() {<br/> |
92 | | -  @Override<br/> |
93 | | -  public void onValueChange(ValueChangeEvent<List<? extends SuggestOracle.Suggestion>> event) {<br/> |
94 | | -   for(SuggestOracle.Suggestion user : event.getValue()){<br/> |
95 | | -    MaterialToast.fireToast(user.getDisplayString());<br/> |
96 | | -   }<br/> |
97 | | -  }<br/> |
98 | | - }); |
99 | | - </demo:PrettyPre> |
100 | | - |
101 | | - <m:MaterialTitle title="Clearing Items on Autocomplete" description="You can easily clear the Autocomplete List Items by calling autocomlete.clear()"/> |
102 | | - <demo:PrettyPre addStyleNames="lang-java z-depth-1"> |
103 | | -  acList.clear(); |
104 | | - </demo:PrettyPre> |
105 | | - |
106 | | - <m:MaterialTitle title="Type TEXT" description="Type TEXT is just an alternative for combo box component."/> |
107 | | - <m:MaterialRow> |
108 | | - <m:MaterialColumn grid="s12 m12 l6"> |
109 | | - <ma:autocomplete.MaterialAutoComplete ui:field="acListType" type="TEXT" limit="1" placeholder="Contacts" /> |
110 | | - </m:MaterialColumn> |
| 47 | + <blockquote > |
| 48 | + <p>You can click the chips to select it.</p> |
| 49 | + <p>Perform any keyboard actions like pressing KEY DELETE and KEY BACKSPACE to remove it from the autocomplete values</p> |
| 50 | + <p>By calling automcomplte.getItemValues() you will retrieve all the items that is currently on the Autocomplete Field</p> |
| 51 | + <p>If the value is already exist, we automatically remove it when adding</p> |
| 52 | + <p>You can add an unknown value by typing new one then PRESS ENTER</p> |
| 53 | + <p>To disable , add enabled="false" parameter on the autocomplete widget</p> |
| 54 | + </blockquote> |
| 55 | + |
| 56 | + <m:MaterialButton ui:field="btnGetAll" text="Get All States" waves="LIGHT" backgroundColor="BLUE"/> |
| 57 | + <m:MaterialButton ui:field="btnClear" text="Clear" waves="DEFAULT" textColor="BLACK" backgroundColor="WHITE"/> |
| 58 | + |
| 59 | + <m.demo:PrettyPre addStyleNames="lang-java"> |
| 60 | +  @UiField MaterialAutoComplete acList; <br/><br/> |
| 61 | + |
| 62 | + UserOracle oracle = new UserOracle();<br/> |
| 63 | + oracle.addContacts(getAllUsers());<br/> |
| 64 | + acList.setSuggestions(oracle); |
| 65 | + </m.demo:PrettyPre> |
| 66 | + </g:HTMLPanel> |
| 67 | + |
| 68 | + <m:MaterialRow addStyleNames="code"> |
| 69 | + <m:MaterialTitle title="Gist Files" description="With the given example, we use UserOracle, User and UserSuggestion in order to build the Autocomplete more flexible." /> |
| 70 | + <m:MaterialAnchorButton text="Link to Gist" textColor="WHITE" target="_blank" href="https://gist.github.com/kevzlou7979/dfb18c003513311345e53af7253b1e39" /> |
111 | 71 | </m:MaterialRow> |
112 | | - <demo:PrettyPre addStyleNames="lang-xml z-depth-1"> |
113 | | -  <ma:autocomplete.MaterialAutoComplete type="TEXT" limit="1" placeholder="States" /> |
114 | | - </demo:PrettyPre> |
115 | | - |
116 | | - <m:MaterialTitle title="Limiting Items" description="You can limit the autocomplete items by adding limit='2' attribute."/> |
117 | | - <m:MaterialRow> |
118 | | - <m:MaterialColumn grid="s12 m12 l6"> |
119 | | - <ma:autocomplete.MaterialAutoComplete ui:field="acListLimit" limit="3" placeholder="Contacts" /> |
120 | | - </m:MaterialColumn> |
| 72 | + |
| 73 | + <m:MaterialRow addStyleNames="code"> |
| 74 | + <m:MaterialTitle title="Get all Selected Items" /> |
| 75 | + <demo:PrettyPre addStyleNames="lang-java"> |
| 76 | +  public List<User> getSelectedUsers() {<br/> |
| 77 | +  List<? extends SuggestOracle.Suggestion> values = acList.getValue();<br/> |
| 78 | +  List<User> users = new ArrayList<>(values.size());<br/> |
| 79 | +  for(SuggestOracle.Suggestion value : values){<br/> |
| 80 | +   if(value instanceof UserSuggestion){<br/> |
| 81 | +    UserSuggestion us = (UserSuggestion) value;<br/> |
| 82 | +    User user = us.getUser();<br/> |
| 83 | +    users.add(user);<br/> |
| 84 | +   }<br/> |
| 85 | +  }<br/> |
| 86 | +  return users;<br/> |
| 87 | + } |
| 88 | + </demo:PrettyPre> |
| 89 | + </m:MaterialRow> |
| 90 | + |
| 91 | + <m:MaterialRow addStyleNames="code"> |
| 92 | + <m:MaterialTitle title="Events" description="You can easily add Value Change Event and Selection Event on autocomplete component."/> |
| 93 | + <demo:PrettyPre addStyleNames="lang-xml"> |
| 94 | +  <acList.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {<br/> |
| 95 | +  @Override<br/> |
| 96 | +  public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {<br/> |
| 97 | +   MaterialToast.fireToast(event.getSelectedItem().getDisplayString() + " Selected");<br/> |
| 98 | +  }<br/> |
| 99 | + });<br/><br/> |
| 100 | + acList.addValueChangeHandler(new ValueChangeHandler<List<? extends SuggestOracle.Suggestion>>() {<br/> |
| 101 | +  @Override<br/> |
| 102 | +  public void onValueChange(ValueChangeEvent<List<? extends SuggestOracle.Suggestion>> event) {<br/> |
| 103 | +   for(SuggestOracle.Suggestion user : event.getValue()){<br/> |
| 104 | +    MaterialToast.fireToast(user.getDisplayString());<br/> |
| 105 | +   }<br/> |
| 106 | +  }<br/> |
| 107 | + }); |
| 108 | + </demo:PrettyPre> |
| 109 | + </m:MaterialRow> |
| 110 | + |
| 111 | + <m:MaterialRow addStyleNames="code"> |
| 112 | + <m:MaterialTitle title="Clearing Items on Autocomplete" description="You can easily clear the Autocomplete List Items by calling autocomlete.clear()"/> |
| 113 | + <demo:PrettyPre addStyleNames="lang-java"> |
| 114 | +  acList.clear(); |
| 115 | + </demo:PrettyPre> |
| 116 | + </m:MaterialRow> |
| 117 | + |
| 118 | + <m:MaterialRow addStyleNames="code"> |
| 119 | + <m:MaterialTitle title="Type TEXT" description="Type TEXT is just an alternative for combo box component."/> |
| 120 | + <m:MaterialRow> |
| 121 | + <m:MaterialColumn grid="s12 m12 l6"> |
| 122 | + <ma:autocomplete.MaterialAutoComplete ui:field="acListType" type="TEXT" limit="1" placeholder="Contacts" /> |
| 123 | + </m:MaterialColumn> |
| 124 | + </m:MaterialRow> |
| 125 | + <demo:PrettyPre addStyleNames="lang-xml"> |
| 126 | +  <ma:autocomplete.MaterialAutoComplete type="TEXT" limit="1" placeholder="States" /> |
| 127 | + </demo:PrettyPre> |
| 128 | + </m:MaterialRow> |
| 129 | + |
| 130 | + <m:MaterialRow addStyleNames="code"> |
| 131 | + <m:MaterialTitle title="Limiting Items" description="You can limit the autocomplete items by adding limit='2' attribute."/> |
| 132 | + <m:MaterialRow> |
| 133 | + <m:MaterialColumn grid="s12 m12 l6"> |
| 134 | + <ma:autocomplete.MaterialAutoComplete ui:field="acListLimit" limit="3" placeholder="Contacts" /> |
| 135 | + </m:MaterialColumn> |
| 136 | + </m:MaterialRow> |
| 137 | + <demo:PrettyPre addStyleNames="lang-xml"> |
| 138 | +  <ma:autocomplete.MaterialAutoComplete limit="3" placeholder="States" /> |
| 139 | + </demo:PrettyPre> |
| 140 | + </m:MaterialRow> |
| 141 | + |
| 142 | + <m:MaterialRow addStyleNames="code"> |
| 143 | + <m:MaterialTitle title="Inside Modal" description="You can build your overlay inside the modal" /> |
| 144 | + <m:MaterialButton ui:field="btnOpenModal" text="Open Modal" textColor="WHITE" waves="DEFAULT"/> |
| 145 | + <m:MaterialModal ui:field="modal"> |
| 146 | + <m:MaterialModalContent> |
| 147 | + <m:MaterialTitle title="Select contacts" description="Some description here..."/> |
| 148 | + <ma:autocomplete.MaterialAutoComplete ui:field="acModal" placeholder="Contacts"/> |
| 149 | + </m:MaterialModalContent> |
| 150 | + <m:MaterialModalFooter textAlign="RIGHT"> |
| 151 | + <m:MaterialButton ui:field="btnClose" text="Close" type="FLAT" textColor="BLACK" waves="DEFAULT"/> |
| 152 | + </m:MaterialModalFooter> |
| 153 | + </m:MaterialModal> |
| 154 | + <demo:PrettyPre addStyleNames="lang-xml"> |
| 155 | +  <m:MaterialModal ui:field="modal"><br/> |
| 156 | +  <m:MaterialModalContent><br/> |
| 157 | +  <m:MaterialTitle title="Select contacts" description="Some description here..."/><br/> |
| 158 | +  <ma:autocomplete.MaterialAutoComplete ui:field="acModal" placeholder="Contacts"/><br/> |
| 159 | +  </m:MaterialModalContent><br/> |
| 160 | +  <m:MaterialModalFooter textAlign="RIGHT"><br/> |
| 161 | +  <m:MaterialButton ui:field="btnClose" text="Close" type="FLAT" textColor="BLACK" waves="DEFAULT"/><br/> |
| 162 | +  </m:MaterialModalFooter><br/> |
| 163 | + </m:MaterialModal><br/> |
| 164 | + </demo:PrettyPre> |
121 | 165 | </m:MaterialRow> |
122 | | - <demo:PrettyPre addStyleNames="lang-xml z-depth-1"> |
123 | | -  <ma:autocomplete.MaterialAutoComplete limit="3" placeholder="States" /> |
124 | | - </demo:PrettyPre> |
125 | | - |
126 | | - <m:MaterialTitle title="Inside Modal" description="You can build your overlay inside the modal" /> |
127 | | - <m:MaterialButton ui:field="btnOpenModal" text="Open Modal" textColor="WHITE" waves="DEFAULT"/> |
128 | | - <m:MaterialModal ui:field="modal"> |
129 | | - <m:MaterialModalContent> |
130 | | - <m:MaterialTitle title="Select contacts" description="Some description here..."/> |
131 | | - <ma:autocomplete.MaterialAutoComplete ui:field="acModal" placeholder="Contacts"/> |
132 | | - </m:MaterialModalContent> |
133 | | - <m:MaterialModalFooter textAlign="RIGHT"> |
134 | | - <m:MaterialButton ui:field="btnClose" text="Close" type="FLAT" textColor="BLACK" waves="DEFAULT"/> |
135 | | - </m:MaterialModalFooter> |
136 | | - </m:MaterialModal> |
137 | | - <demo:PrettyPre addStyleNames="lang-xml z-depth-1"> |
138 | | -  <m:MaterialModal ui:field="modal"><br/> |
139 | | -  <m:MaterialModalContent><br/> |
140 | | -  <m:MaterialTitle title="Select contacts" description="Some description here..."/><br/> |
141 | | -  <ma:autocomplete.MaterialAutoComplete ui:field="acModal" placeholder="Contacts"/><br/> |
142 | | -  </m:MaterialModalContent><br/> |
143 | | -  <m:MaterialModalFooter textAlign="RIGHT"><br/> |
144 | | -  <m:MaterialButton ui:field="btnClose" text="Close" type="FLAT" textColor="BLACK" waves="DEFAULT"/><br/> |
145 | | -  </m:MaterialModalFooter><br/> |
146 | | - </m:MaterialModal><br/> |
147 | | - </demo:PrettyPre> |
148 | 166 | </g:HTMLPanel> |
149 | 167 | </ui:UiBinder> |
0 commit comments