Skip to content

Commit 9189b75

Browse files
committed
Merge pull request #1 from GwtMaterialDesign/master
Update from original
2 parents 9298018 + 25405b7 commit 9189b75

23 files changed

+33331
-822
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
<br/>
55
A Google Material Design wrapper for GWT <br>
66
<a href="www.gwt-material.appspot.com">http://www.gwt-material.appspot.com</a>
7+
<h3>Version 1.3.2</h3>
8+
<ul>
9+
<li><a href="http://gwt-material.appspot.com/#theme" >GWT Material Themes</a></li>
10+
<li><a href="http://gwt-material.appspot.com/#shadow">Shadow DOM on Material Panels, Columns, Rows</a></li>
11+
<li><a href="http://gwt-material.appspot.com/#helper">Helpers (Alignment, Hiding Content, Formatting esp. Text Truncation)</a></li>
12+
<li><a href="http://gwt-material.appspot.com/#table">Tables (Bordered Table, Striped Table, Hoverable Table, Centered Table, Responsive Table)</a></li>
13+
<li>Updated the Getting Started Page of showcase site to add Starter Template Sample (UI Binder Code) <a href="http://gwt-material-starter.appspot.com">Demo(Google Inbox App)</a></li>
14+
</ul>
715
<h3>Version 1.3.1</h3>
816
<ul>
917
<li>Many bug fixes provided. <a href='https://github.com/GwtMaterialDesign/gwt-material/releases/tag/gwt-material-1.3.1'>See release notes</a></li>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package gwt.material.design.client.custom;
2+
3+
/*
4+
* #%L
5+
* GwtMaterial
6+
* %%
7+
* Copyright (C) 2015 GwtMaterialDesign
8+
* %%
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* #L%
21+
*/
22+
23+
import com.google.gwt.uibinder.client.UiChild;
24+
import com.google.gwt.user.client.DOM;
25+
import com.google.gwt.user.client.ui.ComplexPanel;
26+
import com.google.gwt.user.client.ui.Widget;
27+
28+
@SuppressWarnings("deprecation")
29+
public class CustomNav extends ComplexPanel {
30+
31+
32+
public CustomNav() {
33+
setElement(DOM.createElement("NAV"));
34+
}
35+
36+
@UiChild(tagname = "child")
37+
public void addWidget(final Widget item) {
38+
add(item);
39+
}
40+
41+
public void add(Widget w) {
42+
super.add(w, getElement());
43+
}
44+
45+
public void insert(Widget w, int beforeIndex) {
46+
super.insert(w, getElement(), beforeIndex, true);
47+
}
48+
49+
}

src/main/java/gwt/material/design/client/ui/MaterialButton.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ interface MaterialButtonUiBinder extends UiBinder<Widget, MaterialButton> {
5757
private String iconPosition = "";
5858
private String size = "";
5959
private String width = "";
60-
60+
private String href= "";
6161

6262
public MaterialButton() {
6363
initWidget(uiBinder.createAndBindUi(this));
@@ -216,6 +216,15 @@ public void setButton(CustomButton button) {
216216
initButtonStyles();
217217
}
218218

219+
public String getHref() {
220+
return href;
221+
}
222+
223+
public void setHref(String href) {
224+
this.href = href;
225+
this.getElement().setAttribute("href", href);
226+
}
227+
219228

220229

221230
}

src/main/java/gwt/material/design/client/ui/MaterialCollection.java

Lines changed: 166 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@
2323
import gwt.material.design.client.custom.MaterialWidget;
2424
import gwt.material.design.client.resources.MaterialResources;
2525

26+
import java.util.Iterator;
27+
2628
import com.google.gwt.core.client.GWT;
2729
import com.google.gwt.uibinder.client.UiBinder;
2830
import com.google.gwt.uibinder.client.UiChild;
2931
import com.google.gwt.uibinder.client.UiField;
3032
import com.google.gwt.user.client.ui.HTMLPanel;
33+
import com.google.gwt.user.client.ui.HasWidgets;
34+
import com.google.gwt.user.client.ui.IsWidget;
3135
import com.google.gwt.user.client.ui.Widget;
3236

3337
public class MaterialCollection extends MaterialWidget {
@@ -37,66 +41,195 @@ public class MaterialCollection extends MaterialWidget {
3741
interface MaterialCollectionUiBinder extends UiBinder<Widget, MaterialCollection> {
3842
}
3943

40-
@UiField
44+
@UiField
4145
UnorderedList collection;
42-
46+
4347
public MaterialCollection() {
4448
initWidget(uiBinder.createAndBindUi(this));
4549
}
4650

47-
48-
4951
@Override
5052
protected void onAttach() {
51-
// TODO Auto-generated method stub
5253
super.onAttach();
5354
this.addStyleName(MaterialResources.INSTANCE.materialcss().collection());
5455
}
5556

56-
57-
5857
/**
59-
* Add each item on a collection container
60-
* @param item the item to be added
58+
* Add new item on the collection container. Implicit as well assigns a
59+
* press indication.
60+
*
61+
* @param item
62+
* The widget to be added to the collection container
63+
* @return The created ListItem, this might be used to add DomHandlers (eg.
64+
* ClickHandlers etc.) and to react therefore on the full widget
65+
* panel
6166
*/
6267
@UiChild(tagname = "item")
63-
public void addCollectionItem(Widget item){
64-
ListItem list = new ListItem(item);
65-
list.addStyleName("collection-item");
66-
collection.add(list);
68+
public ListItem addCollectionItem(Widget item) {
69+
ListItem listItem = new ListItem(item);
70+
listItem.addStyleName("collection-item");
71+
MaterialUiHelper.addMousePressedHandlers(listItem);
72+
collection.add(listItem);
73+
return listItem;
6774
}
68-
75+
76+
/**
77+
* Insert item on a collection container at the given index. Implicit as
78+
* well assigns a press indication.
79+
*
80+
* @param item
81+
* The widget to be inserted into the collection container
82+
* @param beforeIndex
83+
* The location to insert the widget into the collection
84+
* @return The created ListItem, this might be used to add DomHandlers (eg.
85+
* ClickHandlers etc.) and to react therefore on the full widget
86+
* panel
87+
*/
88+
public ListItem insertCollectionItem(Widget item, int beforeIndex) {
89+
ListItem listItem = new ListItem(item);
90+
listItem.addStyleName("collection-item");
91+
MaterialUiHelper.addMousePressedHandlers(listItem);
92+
collection.insert(listItem, beforeIndex);
93+
return listItem;
94+
}
95+
96+
/**
97+
* Adds an item to the collection styled as header row. No PressedHandler/Indication is
98+
* applied here.
99+
*
100+
* @param item The widget to be added to the put at the top of the collection container
101+
* @return The created ListItem, this might be used to add DomHandlers (eg.
102+
* ClickHandlers etc.) and to react therefore on the full widget
103+
* panel
104+
*/
69105
@UiChild(tagname = "header")
70-
public void addHeader(Widget item){
71-
ListItem list = new ListItem(item);
72-
list.addStyleName(MaterialResources.INSTANCE.materialcss().collectionHeader());
73-
collection.add(list);
106+
public ListItem addHeader(Widget item) {
107+
ListItem listItem = new ListItem(item);
108+
listItem.addStyleName(MaterialResources.INSTANCE.materialcss().collectionHeader());
109+
collection.add(listItem);
110+
return listItem;
74111
}
75-
112+
113+
/**
114+
* Add new dismissable item on the collection container. Implicit as well
115+
* assigns a press indication.
116+
*
117+
* @param item
118+
* The widget item to be added
119+
* @return The created ListItem, this might be used to add DomHandlers (eg.
120+
* ClickHandlers etc.) and to react therefore on the full widget
121+
* panel
122+
*/
76123
@UiChild(tagname = "dismissable")
77-
public void addDismissableItem(Widget item){
78-
ListItem list = new ListItem(item);
79-
list.addStyleName("collection-item dismissable");
80-
collection.add(list);
124+
public ListItem addDismissableItem(Widget item) {
125+
ListItem listItem = new ListItem(item);
126+
listItem.addStyleName("collection-item dismissable");
127+
MaterialUiHelper.addMousePressedHandlers(listItem);
128+
collection.add(listItem);
129+
return listItem;
130+
}
131+
132+
/**
133+
* Insert new item on the collection container. Implicit as well assigns a
134+
* press indication.
135+
*
136+
* @param item
137+
* The widget item to be inserted
138+
* @param beforeIndex
139+
* The location to be inserted
140+
* @return The created ListItem, this might be used to add DomHandlers (eg.
141+
* ClickHandlers etc.) and to react therefore on the full widget
142+
* panel
143+
*/
144+
public ListItem insertDismissableItem(Widget item, int beforeIndex) {
145+
ListItem listItem = new ListItem(item);
146+
listItem.addStyleName("collection-item dismissable");
147+
MaterialUiHelper.addMousePressedHandlers(listItem);
148+
collection.insert(listItem, beforeIndex);
149+
return listItem;
81150
}
82-
151+
152+
/**
153+
* Add new Avatar item on the collection container. Implicit as well assigns
154+
* a press indication.
155+
*
156+
* @param item
157+
* The widget item to be added
158+
* @return The created ListItem, this might be used to add DomHandlers (eg.
159+
* ClickHandlers etc.) and to react therefore on the full widget
160+
* panel
161+
*/
83162
@UiChild(tagname = "avatar")
84-
public void addAvatarItem(Widget item){
85-
ListItem list = new ListItem(item);
86-
list.addStyleName("collection-item avatar");
87-
collection.add(list);
88-
if(item instanceof MaterialPanel){
163+
public ListItem addAvatarItem(Widget item) {
164+
ListItem listItem = new ListItem(item);
165+
listItem.addStyleName("collection-item avatar");
166+
MaterialUiHelper.addMousePressedHandlers(listItem);
167+
collection.add(listItem);
168+
if (item instanceof MaterialPanel) {
89169
HTMLPanel panel = (HTMLPanel) item;
90-
for(Widget w : panel){
91-
if(w instanceof MaterialIcon){
170+
for (Widget w : panel) {
171+
if (w instanceof MaterialIcon) {
92172
w.addStyleName("secondary-content");
93173
}
94174
}
95175
}
176+
return listItem;
96177
}
97-
98-
public void clear(){
178+
179+
/**
180+
* Insert new Avatar item on the collection container. Implicit as well
181+
* assigns a press indication.
182+
*
183+
* @param item
184+
* The item to be added
185+
* @param beforeIndex
186+
* The location to insert the widget item
187+
* @return The created ListItem, this might be used to add DomHandlers (eg.
188+
* ClickHandlers etc.) and to react therefore on the full widget
189+
* panel
190+
*/
191+
public ListItem insertAvatarItem(Widget item, int beforeIndex) {
192+
ListItem listItem = new ListItem(item);
193+
listItem.addStyleName("collection-item avatar");
194+
MaterialUiHelper.addMousePressedHandlers(listItem);
195+
collection.insert(listItem, beforeIndex);
196+
if (item instanceof MaterialPanel) {
197+
HTMLPanel panel = (HTMLPanel) item;
198+
for (Widget w : panel) {
199+
if (w instanceof MaterialIcon) {
200+
w.addStyleName("secondary-content");
201+
}
202+
}
203+
}
204+
return listItem;
205+
}
206+
207+
public void clear() {
99208
collection.clear();
100209
}
101210

211+
public Widget getWidget(int index) {
212+
return getFirstChild(collection.getWidget(index));
213+
}
214+
215+
public int getWidgetCount() {
216+
return collection.getWidgetCount();
217+
}
218+
219+
public int getWidgetIndex(Widget child) {
220+
return collection.getWidgetIndex(child.getParent());
221+
}
222+
223+
public int getWidgetIndex(IsWidget child) {
224+
return getWidgetIndex(asWidgetOrNull(child).getParent());
225+
}
226+
227+
private Widget getFirstChild(Widget parent) {
228+
if (parent instanceof HasWidgets) {
229+
Iterator<Widget> iter = ((HasWidgets) parent).iterator();
230+
return (iter != null && iter.hasNext()) ? iter.next() : null;
231+
}
232+
return null;
233+
}
234+
102235
}

src/main/java/gwt/material/design/client/ui/MaterialFloatingContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ protected void onAttach() {
4949
// TODO Auto-generated method stub
5050
super.onAttach();
5151
this.addStyleName("fixed-action-btn");
52-
this.getElement().getStyle().setBottom(1, Unit.PCT);
53-
this.getElement().getStyle().setRight(1, Unit.PCT);
52+
this.getElement().getStyle().setBottom(3, Unit.PCT);
53+
this.getElement().getStyle().setRight(3, Unit.PCT);
5454
this.addStyleName(MaterialResources.INSTANCE.materialcss().floatingButtonsItem());
5555
this.add(list);
5656

src/main/java/gwt/material/design/client/ui/MaterialFooter.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import gwt.material.design.client.custom.CustomFooter;
2424

2525
import com.google.gwt.core.client.GWT;
26+
import com.google.gwt.dom.client.Style.Position;
27+
import com.google.gwt.dom.client.Style.Unit;
2628
import com.google.gwt.uibinder.client.UiBinder;
2729
import com.google.gwt.uibinder.client.UiChild;
2830
import com.google.gwt.uibinder.client.UiField;
@@ -41,6 +43,7 @@ interface MaterialFooterUiBinder extends UiBinder<Widget, MaterialFooter> {
4143
@UiField MaterialPanel container;
4244
private String color = "";
4345
private String copyright = "";
46+
private String type = "";
4447

4548
public MaterialFooter() {
4649
initWidget(uiBinder.createAndBindUi(this));
@@ -70,4 +73,17 @@ public void setCopyright(String copyright) {
7073
if(!copyright.isEmpty()) lblCopyright.setText(copyright);
7174
}
7275

76+
public String getType() {
77+
return type;
78+
}
79+
80+
public void setType(String type) {
81+
this.type = type;
82+
if(type.equals("fixed")){
83+
footerPanel.getElement().getStyle().setPosition(Position.FIXED);
84+
footerPanel.getElement().getStyle().setWidth(100, Unit.PCT);
85+
footerPanel.getElement().getStyle().setBottom(0, Unit.PCT);
86+
}
87+
}
88+
7389
}

src/main/java/gwt/material/design/client/ui/MaterialImage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public MaterialImage() {
3636
protected void onAttach() {
3737
// TODO Auto-generated method stub
3838
super.onAttach();
39+
this.setWidth("100%");
3940
this.addStyleName("responsive-img");
4041
onInitMaterialDesign();
4142

0 commit comments

Comments
 (0)