Skip to content

Commit 5f3db41

Browse files
author
Christian
committed
Merge remote-tracking branch 'origin/master'
2 parents 3b460e5 + 5c0b491 commit 5f3db41

File tree

7 files changed

+139
-20
lines changed

7 files changed

+139
-20
lines changed

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@
55
A Google Material Design wrapper for GWT <br>
66
<a href="www.gwt-material.appspot.com">http://www.gwt-material.appspot.com</a>
77

8-
<h3>Version 15.5</h3>
8+
<h3>Version 1.3</h3>
99
<ul>
1010
<li>GWT Material Official Maven Release</li>
1111
<li>Switch bug fixed on setValue()</li>
1212
<li>Transition Added</li>
1313
<li>Embed stylesheets and javascripts inside the project (no more external files)</li>
14-
15-
</ul>
16-
17-
<h3>Version 15.4.15</h3>
18-
<ul>
1914
<li>GWT Material Showcase</li>
2015
<ul>
2116
<li>Parallax</li>
@@ -32,7 +27,7 @@ A Google Material Design wrapper for GWT <br>
3227
<img src="http://gwt-material.appspot.com/bin/weather.gif" />
3328
<img src="http://gwt-material.appspot.com/bin/parallax.gif" />
3429

35-
<h3>Version 15.4</h3>
30+
<h3>Version 1.2</h3>
3631
<ul>
3732
<li>Integrate GWT Material to Phonegap</li>
3833
<li>Remove GWT Uploader on Build Path (Which cause a inheritance problem)</li>
@@ -47,7 +42,7 @@ A Google Material Design wrapper for GWT <br>
4742
<li>Adding Roboto Fonts by default</li>
4843
</ul>
4944

50-
<h3>Version 15.3 </h3>
45+
<h3>Version 1.0 </h3>
5146
<ul>
5247
<li>Collabsible and Accordion</li>
5348
<li>Dropdown Menu</li>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
import com.google.gwt.uibinder.client.UiField;
3535
import com.google.gwt.user.client.ui.ComplexPanel;
3636
import com.google.gwt.user.client.ui.HTMLPanel;
37+
import com.google.gwt.user.client.ui.HasText;
3738
import com.google.gwt.user.client.ui.Label;
3839
import com.google.gwt.user.client.ui.Widget;
3940

40-
public class MaterialButton extends MaterialWidget implements HasClickHandlers{
41+
public class MaterialButton extends MaterialWidget implements HasClickHandlers,HasText{
4142

4243
private static MaterialButtonUiBinder uiBinder = GWT.create(MaterialButtonUiBinder.class);
4344

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ public void hide(){
8282
public static native void showModal(String id)/*-{
8383
$wnd.jQuery('#' + id).openModal();
8484
}-*/;
85-
86-
public static native void closeModal()/*-{
85+
86+
public static native void closeModal(String id)/*-{
8787
$wnd.jQuery('#' + id).closeModal();
8888
}-*/;
8989

90-
91-
90+
public static void closeModal() {
91+
closeModal(panel.getElement().getId());
92+
}
9293
}

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

Lines changed: 124 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,141 @@
2121
*/
2222

2323
import com.google.gwt.core.client.GWT;
24+
import com.google.gwt.dom.client.Element;
25+
import com.google.gwt.dom.client.NodeList;
26+
import com.google.gwt.event.dom.client.ChangeEvent;
27+
import com.google.gwt.event.dom.client.ChangeHandler;
28+
import com.google.gwt.event.dom.client.HasChangeHandlers;
29+
import com.google.gwt.event.shared.HandlerRegistration;
2430
import com.google.gwt.uibinder.client.UiBinder;
2531
import com.google.gwt.user.client.ui.Composite;
2632
import com.google.gwt.user.client.ui.Widget;
2733

28-
public class MaterialRange extends Composite {
34+
/**
35+
* Slider for numeric values
36+
*/
37+
public class MaterialRange extends Composite implements HasChangeHandlers{
2938

30-
private static MaterialRangeUiBinder uiBinder = GWT
31-
.create(MaterialRangeUiBinder.class);
39+
private static MaterialRangeUiBinder uiBinder = GWT.create(MaterialRangeUiBinder.class);
3240

3341
interface MaterialRangeUiBinder extends UiBinder<Widget, MaterialRange> {
3442
}
3543

44+
private static String VALUE = "value";
45+
private static String MAX = "max";
46+
private static String MIN = "min";
47+
private static String INPUT = "INPUT";
48+
49+
// cache the embedded range input element
50+
private Element rangeElement = null;
51+
3652
public MaterialRange() {
3753
initWidget(uiBinder.createAndBindUi(this));
3854
}
3955

56+
/**
57+
* Try to identify the embedded range elements input field (see ui xml)
58+
* @return The found element or null if none found.
59+
*/
60+
private Element getRangeElement() {
61+
if (rangeElement == null) {
62+
NodeList<Element> elements = this.getElement().getElementsByTagName(INPUT);
63+
if (elements != null && elements.getLength() > 0) {
64+
rangeElement = elements.getItem(0);
65+
}
66+
}
67+
return rangeElement;
68+
}
69+
70+
/**
71+
* Retrieve the Integer value from the given Attribute of the range element
72+
* @param attribute The name of the attribute on the range element
73+
* @return The Integer vaulue read from the given attribute or null
74+
*/
75+
private Integer getIntFromRangeElement(String attribute){
76+
Element ele = getRangeElement();
77+
if(ele!=null){
78+
return ele.getPropertyInt(attribute);
79+
}
80+
return null;
81+
}
82+
83+
/**
84+
* Set the given Integer value to the attribute of the range element
85+
* @param attribute
86+
* @param val
87+
*/
88+
private void setIntToRangeElement(String attribute,Integer val)
89+
{
90+
Element ele = getRangeElement();
91+
if(ele!=null){
92+
ele.setPropertyInt(attribute,val);
93+
}
94+
}
95+
96+
/**
97+
* Read the current value
98+
* @return The Integer value or null
99+
*/
100+
public Integer getValue() {
101+
return getIntFromRangeElement(VALUE);
102+
}
103+
104+
/**
105+
* Write the current value
106+
* @param value value must be >= min and <= max
107+
*/
108+
public void setValue(Integer value) {
109+
if (value==null)return;
110+
if (value<getMin())return;
111+
if (value>getMax())return;
112+
setIntToRangeElement(VALUE,value);
113+
}
114+
115+
/**
116+
* Read the min value
117+
* @return The Integer or null
118+
*/
119+
public Integer getMin() {
120+
return getIntFromRangeElement(MIN);
121+
}
122+
123+
/**
124+
* Write the current min value
125+
* @param min value must be < max
126+
*/
127+
public void setMin(Integer min) {
128+
if (min==null)return;
129+
if (min>=getMax())return;
130+
setIntToRangeElement(MIN,min);
131+
}
132+
133+
/**
134+
* Read the max value
135+
* @return The Integer or null
136+
*/
137+
public Integer getMax() {
138+
return getIntFromRangeElement(MAX);
139+
}
140+
141+
/**
142+
* Write the current max value
143+
* @param max value must be > min
144+
*/
145+
public void setMax(Integer max) {
146+
if (max==null)return;
147+
if (max<=getMin())return;
148+
setIntToRangeElement(MAX,max);
149+
}
150+
151+
/**
152+
* Register the ChangeHandler to become notified if the user changes the slider.
153+
* The Handler is called when the user releases the mouse only at the end of the slide
154+
* operation.
155+
*/
156+
@Override
157+
public HandlerRegistration addChangeHandler(ChangeHandler handler) {
158+
return addDomHandler(handler, ChangeEvent.getType());
159+
}
160+
40161
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@
4040
import com.google.gwt.uibinder.client.UiBinder;
4141
import com.google.gwt.uibinder.client.UiField;
4242
import com.google.gwt.user.client.ui.Composite;
43+
import com.google.gwt.user.client.ui.HasText;
4344
import com.google.gwt.user.client.ui.Label;
4445
import com.google.gwt.user.client.ui.TextArea;
4546
import com.google.gwt.user.client.ui.Widget;
4647

47-
public class MaterialTextArea extends Composite implements HasKeyPressHandlers,HasKeyDownHandlers,HasKeyUpHandlers,HasChangeHandlers {
48+
public class MaterialTextArea extends Composite implements HasText,HasKeyPressHandlers,HasKeyDownHandlers,HasKeyUpHandlers,HasChangeHandlers {
4849

4950
private static MaterialTextAreaUiBinder uiBinder = GWT
5051
.create(MaterialTextAreaUiBinder.class);
@@ -96,7 +97,6 @@ public String getText() {
9697
public void setText(String text) {
9798
txtBox.setText(text);
9899
customLabel.addStyleName("active");
99-
100100
}
101101

102102
@Override

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@
3434
import com.google.gwt.uibinder.client.UiBinder;
3535
import com.google.gwt.uibinder.client.UiField;
3636
import com.google.gwt.user.client.ui.Composite;
37+
import com.google.gwt.user.client.ui.HasText;
3738
import com.google.gwt.user.client.ui.Label;
3839
import com.google.gwt.user.client.ui.TextBox;
3940
import com.google.gwt.user.client.ui.Widget;
4041

41-
public class MaterialTextBox extends Composite implements HasKeyUpHandlers{
42+
public class MaterialTextBox extends Composite implements HasText,HasKeyUpHandlers{
4243

4344
private static MaterialTextBoxUiBinder uiBinder = GWT.create(MaterialTextBoxUiBinder.class);
4445

src/main/resources/gwt/material/design/client/ui/MaterialRange.ui.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<g:HTMLPanel>
2727
<form action="#">
2828
<p class="range-field">
29-
<input type="range" id="test5" min="0" max="100" />
29+
<input type="range" min="0" max="100" />
3030
</p>
3131
</form>
3232
</g:HTMLPanel>

0 commit comments

Comments
 (0)