Skip to content

Commit 8dec1d5

Browse files
committed
Material Window Dialog
Material Icons Sidebar supports Collapsible Submenus and multi declaration on any interface Scroll Spy
1 parent b00ee1c commit 8dec1d5

File tree

8 files changed

+135
-41
lines changed

8 files changed

+135
-41
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ A Google Material Design wrapper for GWT <br>
1414
<li><a href="http://gwt-material.appspot.com/#dialogs">Material Window Dialog</a></li>
1515
<li><a href="http://gwt-material.appspot.com/#icons">Material Icons</a></li>
1616
<li>Sidebar supports Collapsible Submenus and multi declaration on any interface</li>
17+
<li><a href="http://gwt-material.appspot.com/#icons">Scroll Spy</li></li>
1718
</ul>
1819

1920
<img src="http://gwt-material.appspot.com/bin/starter.gif" width="200px"/>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public void addItem(final Widget item) {
4848
this.add(item);
4949
}
5050

51-
5251
public static native void onInitCollapsible()/*-{
5352
$wnd.jQuery(document).ready(function() {
5453
$wnd.jQuery('.collapsible').collapsible({

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public MaterialCollapsibleItem() {
3030
// TODO Auto-generated constructor stub
3131
}
3232

33+
private UnorderedList ulPanel;
34+
3335
@UiChild(tagname = "header")
3436
public void addHeader(final Widget header) {
3537
header.addStyleName("collapsible-header");
@@ -38,13 +40,13 @@ public void addHeader(final Widget header) {
3840

3941
@UiChild(tagname = "content")
4042
public void addContent(final Widget content) {
41-
MaterialPanel panel = new MaterialPanel("");
42-
panel.addStyleName("collapsible-body");
43+
ulPanel = new UnorderedList();
44+
ulPanel.addStyleName("collapsible-body");
4345

44-
panel.add(content);
45-
panel.getElement().getStyle().setPadding(2, Unit.EM);
46-
panel.getElement().getStyle().setMargin(0, Unit.EM);
47-
this.add(panel);
46+
ulPanel.add(content);
47+
ulPanel.getElement().getStyle().setPadding(2, Unit.EM);
48+
ulPanel.getElement().getStyle().setMargin(0, Unit.EM);
49+
this.add(ulPanel);
4850
}
4951

5052
}

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

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
* #L%
2121
*/
2222

23+
import gwt.material.design.client.custom.CustomIcon;
24+
2325
import com.google.gwt.dom.client.Style.Cursor;
2426
import com.google.gwt.dom.client.Style.Unit;
27+
import com.google.gwt.user.client.ui.Anchor;
2528
import com.google.gwt.user.client.ui.FocusPanel;
2629
import com.google.gwt.user.client.ui.HTMLPanel;
2730
import com.google.gwt.user.client.ui.Widget;
@@ -30,7 +33,7 @@ public class MaterialLink extends FocusPanel {
3033

3134
protected HTMLPanel panel = new HTMLPanel("");
3235
private String text = "";
33-
private String href;
36+
private String href = "";
3437
private String icon = "";
3538
private String iconPosition = "";
3639
private String textColor = "";
@@ -41,34 +44,29 @@ public class MaterialLink extends FocusPanel {
4144
private String tooltipLocation = "bottom";
4245
private String tooltipDelay = "50";
4346
private Widget container;
44-
47+
private Anchor anchorElem;
48+
private CustomIcon iconElem;
4549

4650
private boolean separator = false;
4751
private boolean active = false;
4852

4953
public MaterialLink() {
5054
// TODO Auto-generated constructor stub
5155
}
52-
53-
5456

5557
public MaterialLink(String text, String textColor) {
5658
super();
5759
setText(text);
5860
setTextColor(textColor);
5961
}
6062

61-
62-
6363
@Override
6464
protected void onAttach() {
6565
// TODO Auto-generated method stub
6666
super.onAttach();
6767
initToolTip();
6868
}
6969

70-
71-
7270
public MaterialLink(String text) {
7371
super();
7472
this.text = text;
@@ -129,16 +127,26 @@ public void setIconPosition(String iconPosition) {
129127
}
130128

131129
public void generateLink() {
130+
panel.clear();
132131
this.clear();
133-
String iconMarkup = "";
134-
String hrefMarkup = "";
135-
if (!icon.isEmpty()) {
136-
iconMarkup = "<i class='" + icon + " " + iconPosition + "'></i>";
132+
anchorElem = new Anchor();
133+
iconElem = new CustomIcon();
134+
if (!iconPosition.isEmpty())
135+
iconElem.addStyleName(iconPosition);
136+
137+
if (!href.isEmpty())
138+
anchorElem.setHref(href);
139+
if (!textColor.isEmpty())
140+
anchorElem.addStyleName(textColor + "-text");
141+
if (!text.isEmpty()) {
142+
anchorElem.setText(text);
137143
}
138-
if (this.href != null) {
139-
hrefMarkup = "href='" + href + "' ";
144+
;
145+
if (!icon.isEmpty()) {
146+
anchorElem.getElement().appendChild(iconElem.getElement());
147+
iconElem.addStyleName(icon);
140148
}
141-
panel = new HTMLPanel("<a " + hrefMarkup + "class='" + textColor + "-text'>" + iconMarkup + text + "</a>");
149+
panel.add(anchorElem);
142150
panel.getElement().getStyle().setCursor(Cursor.POINTER);
143151
this.add(panel);
144152
}
@@ -165,7 +173,7 @@ public void setObject(Object object) {
165173
public String getTooltip() {
166174
return tooltip;
167175
}
168-
176+
169177
public void setTooltip(String tooltip) {
170178
this.tooltip = tooltip;
171179
generateTooltip();
@@ -189,49 +197,55 @@ public void setTooltipDelay(String tooltipDelay) {
189197
generateTooltip();
190198
}
191199

192-
private void generateTooltip(){
200+
private void generateTooltip() {
193201
this.addStyleName("tooltipped");
194202
this.getElement().setAttribute("data-position", tooltipLocation);
195203
this.getElement().setAttribute("data-delay", tooltipDelay);
196204
this.getElement().setAttribute("data-tooltip", tooltip);
197205
}
198206

199207
public native void initToolTip()/*-{
200-
$wnd.jQuery(document).ready(function(){
201-
$wnd.jQuery('.tooltipped').tooltip({delay: 50});
202-
});
203-
}-*/;
204-
205-
208+
$wnd.jQuery(document).ready(function(){
209+
$wnd.jQuery('.tooltipped').tooltip({delay: 50});
210+
});
211+
}-*/;
206212

207213
public boolean isActive() {
208214
return active;
209215
}
210216

211-
212-
213217
public void setActive(boolean active) {
214218
this.active = active;
215-
if(active){
219+
if (active) {
216220
this.addStyleName("active");
217221
}
218222
}
219223

220-
221-
222224
public boolean isSeparator() {
223225
return separator;
224226
}
225227

226-
227-
228228
public void setSeparator(boolean separator) {
229229
this.separator = separator;
230-
if(separator){
230+
if (separator) {
231231
this.getElement().setAttribute("style", "border-bottom: 1px solid #e9e9e9;");
232232
}
233233
}
234-
235-
236-
234+
235+
public Anchor getAnchorElem() {
236+
return anchorElem;
237+
}
238+
239+
public void setAnchorElem(Anchor anchorElem) {
240+
this.anchorElem = anchorElem;
241+
}
242+
243+
public CustomIcon getIconElem() {
244+
return iconElem;
245+
}
246+
247+
public void setIconElem(CustomIcon iconElem) {
248+
this.iconElem = iconElem;
249+
}
250+
237251
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class MaterialPanel extends HTMLPanel{
3232
private String shadow = "";
3333
private String type = "";
3434
private String padding = "";
35+
private String scrollspy="";
3536

3637
public MaterialPanel() {
3738
super("");
@@ -110,6 +111,16 @@ public void setPadding(String padding) {
110111
this.getElement().getStyle().setPadding(Double.parseDouble(padding), Unit.PCT);
111112
}
112113

114+
public String getScrollspy() {
115+
return scrollspy;
116+
}
117+
118+
public void setScrollspy(String scrollspy) {
119+
this.scrollspy = scrollspy;
120+
this.addStyleName("scrollspy section");
121+
this.getElement().setId(scrollspy);
122+
}
123+
113124

114125

115126
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package gwt.material.design.client.ui;
2+
3+
import com.google.gwt.core.client.GWT;
4+
import com.google.gwt.uibinder.client.UiBinder;
5+
import com.google.gwt.uibinder.client.UiChild;
6+
import com.google.gwt.uibinder.client.UiField;
7+
import com.google.gwt.user.client.ui.Composite;
8+
import com.google.gwt.user.client.ui.Widget;
9+
10+
public class MaterialScrollspy extends Composite {
11+
12+
private static MaterialScrollspyUiBinder uiBinder = GWT.create(MaterialScrollspyUiBinder.class);
13+
14+
interface MaterialScrollspyUiBinder extends UiBinder<Widget, MaterialScrollspy> {
15+
}
16+
17+
@UiField UnorderedList ulPanel;
18+
19+
private String color = "";
20+
21+
public MaterialScrollspy() {
22+
initWidget(uiBinder.createAndBindUi(this));
23+
}
24+
25+
26+
27+
@UiChild(tagname = "item")
28+
public void onAddItem(Widget w){
29+
ListItem item = new ListItem(w);
30+
ulPanel.add(item);
31+
}
32+
33+
34+
35+
@Override
36+
protected void onAttach() {
37+
// TODO Auto-generated method stub
38+
super.onAttach();
39+
initScrollspy();
40+
}
41+
42+
static native void initScrollspy()/*-{
43+
$wnd.jQuery(".scrollspy").scrollSpy();
44+
}-*/;
45+
46+
public String getColor() {
47+
return color;
48+
}
49+
50+
public void setColor(String color) {
51+
this.color = color;
52+
}
53+
54+
55+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
2+
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
3+
xmlns:m="urn:import:gwt.material.design.client.ui"
4+
xmlns:g="urn:import:com.google.gwt.user.client.ui"
5+
xmlns:c="urn:import:gwt.material.design.client.custom">
6+
<ui:style>
7+
8+
</ui:style>
9+
<m:UnorderedList ui:field="ulPanel" addStyleNames="section table-of-contents">
10+
11+
</m:UnorderedList>
12+
</ui:UiBinder>

0 commit comments

Comments
 (0)