File tree Expand file tree Collapse file tree 3 files changed +49
-3
lines changed
gwt-material/src/main/java/gwt/material/design/client/ui Expand file tree Collapse file tree 3 files changed +49
-3
lines changed Original file line number Diff line number Diff line change 77
88
99## Demo
10- * [ 1.5 Release Demo] ( http://gwtmaterialdesign.github.io/gwt-material-demo/ )
10+ * [ 1.5.0 Release Demo] ( http://gwtmaterialdesign.github.io/gwt-material-demo/ )
1111* [ 1.5.1 Snapshot Demo] ( http://gwtmaterialdesign.github.io/gwt-material-demo/snapshot/ )
1212
1313## Documentation
Original file line number Diff line number Diff line change @@ -118,6 +118,12 @@ protected void onAttach() {
118118 setPlaceholder (this .placeholder );
119119 }
120120
121+ @ Override
122+ protected void onDetach () {
123+ super .onDetach ();
124+ removeClickHandler (pickatizedDateInput , this );
125+ }
126+
121127 @ Override
122128 public void clear () {
123129 if (initialized ) {
@@ -146,6 +152,10 @@ public void setDateSelectionType(MaterialDatePickerType type) {
146152 }
147153 }
148154
155+ native void removeClickHandler (Element picker , MaterialDatePicker parent ) /*-{
156+ picker.pickadate('picker').off("close", "open", "set");
157+ }-*/ ;
158+
149159 native void initClickHandler (Element picker , MaterialDatePicker parent ) /*-{
150160 picker.pickadate('picker').on({
151161 close: function () {
@@ -287,6 +297,15 @@ public static native JsDate getDatePickerValue(Element picker)/*-{
287297 return picker.pickadate('picker').get('select').obj;
288298 }-*/ ;
289299
300+ /**
301+ * Clears the values of the picker field.
302+ */
303+ public void clearValues () {
304+ if (pickatizedDateInput != null ) {
305+ clearValues (pickatizedDateInput );
306+ }
307+ }
308+
290309 public native void clearValues (Element picker ) /*-{
291310 picker.pickadate('picker').clear();
292311 }-*/ ;
Original file line number Diff line number Diff line change 11package gwt .material .design .client .ui ;
22
3+ import com .google .gwt .core .client .Scheduler ;
4+ import com .google .gwt .core .client .Scheduler .ScheduledCommand ;
5+
36/*
47 * #%L
58 * GwtMaterial
@@ -733,8 +736,32 @@ public void setAccessKey(char key) {
733736 }
734737
735738 @ Override
736- public void setFocus (boolean focused ) {
737- valueBoxBase .setFocus (focused );
739+ public void setFocus (final boolean focused ) {
740+ Scheduler .get ().scheduleDeferred (new ScheduledCommand () {
741+
742+ @ Override
743+ public void execute () {
744+ valueBoxBase .setFocus (focused );
745+ if (focused ) {
746+ label .addStyleName ("active" );
747+ } else {
748+ updateLabelActiveStyle ();
749+ }
750+ }
751+ });
752+ }
753+
754+ /**
755+ * Updates the style of the field label according to the field value if the
756+ * field value is empty - null or "" - removes the label 'active' style else
757+ * will add the 'active' style to the field label.
758+ */
759+ private void updateLabelActiveStyle () {
760+ if (this .valueBoxBase .getText () != null && !this .valueBoxBase .getText ().isEmpty ()) {
761+ label .addStyleName ("active" );
762+ } else {
763+ label .removeStyleName ("active" );
764+ }
738765 }
739766
740767 @ Override
You can’t perform that action at this time.
0 commit comments