Skip to content

Commit

Permalink
Derive DateField from new AbstractField (#57).
Browse files Browse the repository at this point in the history
Change-Id: I5efe17253ecd28dad5a2250076246a9eb30eec62
  • Loading branch information
Denis Anisimov authored and Vaadin Code Review committed Aug 15, 2016
1 parent 4348979 commit 87118c4
Show file tree
Hide file tree
Showing 123 changed files with 2,785 additions and 786 deletions.
@@ -0,0 +1,30 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.client.legacy.ui;

import com.vaadin.client.ui.datefield.DateFieldConnector;
import com.vaadin.legacy.ui.LegacyDateField;
import com.vaadin.shared.ui.Connect;

/**
* @author Vaadin Ltd
*
*/
@Connect(LegacyDateField.class)
@Deprecated
public class LegacyDateFieldConnector extends DateFieldConnector {

}
@@ -0,0 +1,30 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.client.legacy.ui;

import com.vaadin.client.ui.datefield.InlineDateFieldConnector;
import com.vaadin.legacy.ui.LegacyInlineDateField;
import com.vaadin.shared.ui.Connect;

/**
* @author Vaadin Ltd
*
*/
@Connect(LegacyInlineDateField.class)
@Deprecated
public class LegacyInlineDateFieldConnector extends InlineDateFieldConnector {

}
@@ -0,0 +1,30 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.client.legacy.ui;

import com.vaadin.client.ui.datefield.PopupDateFieldConnector;
import com.vaadin.legacy.ui.LegacyPopupDateField;
import com.vaadin.shared.ui.Connect;

/**
* @author Vaadin Ltd
*
*/
@Deprecated
@Connect(LegacyPopupDateField.class)
public class LegacyPopupDateFieldConnector extends PopupDateFieldConnector {

}
Expand Up @@ -27,13 +27,13 @@
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.VCalendarPanel.FocusChangeListener; import com.vaadin.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.client.ui.VCalendarPanel.TimeChangeListener; import com.vaadin.client.ui.VCalendarPanel.TimeChangeListener;
import com.vaadin.legacy.ui.LegacyDateField;
import com.vaadin.client.ui.VPopupCalendar; import com.vaadin.client.ui.VPopupCalendar;
import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.datefield.PopupDateFieldState; import com.vaadin.shared.ui.datefield.PopupDateFieldState;
import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.ui.DateField;


@Connect(LegacyDateField.class) @Connect(DateField.class)
public class DateFieldConnector extends TextualDateConnector { public class DateFieldConnector extends TextualDateConnector {


/* /*
Expand Down Expand Up @@ -81,20 +81,20 @@ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {


super.updateFromUIDL(uidl, client); super.updateFromUIDL(uidl, client);


getWidget().calendar.setDateTimeService(getWidget() getWidget().calendar
.getDateTimeService()); .setDateTimeService(getWidget().getDateTimeService());
getWidget().calendar.setShowISOWeekNumbers(getWidget() getWidget().calendar
.isShowISOWeekNumbers()); .setShowISOWeekNumbers(getWidget().isShowISOWeekNumbers());
if (getWidget().calendar.getResolution() != getWidget() if (getWidget().calendar.getResolution() != getWidget()
.getCurrentResolution()) { .getCurrentResolution()) {
boolean hasSelectedDate = false; boolean hasSelectedDate = false;
getWidget().calendar.setResolution(getWidget() getWidget().calendar
.getCurrentResolution()); .setResolution(getWidget().getCurrentResolution());
if (getWidget().calendar.getDate() != null if (getWidget().calendar.getDate() != null
&& getWidget().getCurrentDate() != null) { && getWidget().getCurrentDate() != null) {
hasSelectedDate = true; hasSelectedDate = true;
getWidget().calendar.setDate((Date) getWidget() getWidget().calendar
.getCurrentDate().clone()); .setDate((Date) getWidget().getCurrentDate().clone());
} }
// force re-render when changing resolution only // force re-render when changing resolution only
getWidget().calendar.renderCalendar(hasSelectedDate); getWidget().calendar.renderCalendar(hasSelectedDate);
Expand All @@ -105,8 +105,8 @@ && getWidget().getCurrentDate() != null) {
getWidget().calendar.renderCalendar(); getWidget().calendar.renderCalendar();
} }


if (getWidget().getCurrentResolution().getCalendarField() <= Resolution.MONTH if (getWidget().getCurrentResolution()
.getCalendarField()) { .getCalendarField() <= Resolution.MONTH.getCalendarField()) {
getWidget().calendar getWidget().calendar
.setFocusChangeListener(new FocusChangeListener() { .setFocusChangeListener(new FocusChangeListener() {
@Override @Override
Expand All @@ -123,12 +123,13 @@ public void focusChanged(Date date) {
getWidget().calendar.setFocusChangeListener(null); getWidget().calendar.setFocusChangeListener(null);
} }


if (getWidget().getCurrentResolution().getCalendarField() > Resolution.DAY if (getWidget().getCurrentResolution()
.getCalendarField()) { .getCalendarField() > Resolution.DAY.getCalendarField()) {
getWidget().calendar getWidget().calendar
.setTimeChangeListener(new TimeChangeListener() { .setTimeChangeListener(new TimeChangeListener() {
@Override @Override
public void changed(int hour, int min, int sec, int msec) { public void changed(int hour, int min, int sec,
int msec) {
Date d = getWidget().getDate(); Date d = getWidget().getDate();
if (d == null) { if (d == null) {
// date currently null, use the value from // date currently null, use the value from
Expand All @@ -152,11 +153,11 @@ public void changed(int hour, int min, int sec, int msec) {
} }


if (getWidget().isReadonly()) { if (getWidget().isReadonly()) {
getWidget().calendarToggle.addStyleName(VPopupCalendar.CLASSNAME getWidget().calendarToggle.addStyleName(
+ "-button-readonly"); VPopupCalendar.CLASSNAME + "-button-readonly");
} else { } else {
getWidget().calendarToggle.removeStyleName(VPopupCalendar.CLASSNAME getWidget().calendarToggle.removeStyleName(
+ "-button-readonly"); VPopupCalendar.CLASSNAME + "-button-readonly");
} }


getWidget().setDescriptionForAssistiveDevices( getWidget().setDescriptionForAssistiveDevices(
Expand Down Expand Up @@ -200,18 +201,20 @@ protected void setWidgetStyleName(String styleName, boolean add) {
} }


@Override @Override
protected void setWidgetStyleNameWithPrefix(String prefix, protected void setWidgetStyleNameWithPrefix(String prefix, String styleName,
String styleName, boolean add) { boolean add) {
super.setWidgetStyleNameWithPrefix(prefix, styleName, add); super.setWidgetStyleNameWithPrefix(prefix, styleName, add);


// update the style change to popup calendar widget with the correct // update the style change to popup calendar widget with the correct
// prefix // prefix
if (!styleName.startsWith("-")) { if (!styleName.startsWith("-")) {
getWidget().popup.setStyleName(getWidget().getStylePrimaryName() getWidget().popup.setStyleName(
+ "-popup-" + styleName, add); getWidget().getStylePrimaryName() + "-popup-" + styleName,
add);
} else { } else {
getWidget().popup.setStyleName(getWidget().getStylePrimaryName() getWidget().popup.setStyleName(
+ "-popup" + styleName, add); getWidget().getStylePrimaryName() + "-popup" + styleName,
add);
} }
} }


Expand Down
Expand Up @@ -23,13 +23,13 @@
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.VCalendarPanel.FocusChangeListener; import com.vaadin.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.client.ui.VCalendarPanel.TimeChangeListener; import com.vaadin.client.ui.VCalendarPanel.TimeChangeListener;
import com.vaadin.legacy.ui.LegacyInlineDateField;
import com.vaadin.client.ui.VDateFieldCalendar; import com.vaadin.client.ui.VDateFieldCalendar;
import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.datefield.InlineDateFieldState; import com.vaadin.shared.ui.datefield.InlineDateFieldState;
import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.ui.InlineDateField;


@Connect(LegacyInlineDateField.class) @Connect(InlineDateField.class)
public class InlineDateFieldConnector extends AbstractDateFieldConnector { public class InlineDateFieldConnector extends AbstractDateFieldConnector {


@Override @Override
Expand All @@ -40,25 +40,26 @@ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
return; return;
} }


getWidget().calendarPanel.setShowISOWeekNumbers(getWidget() getWidget().calendarPanel
.isShowISOWeekNumbers()); .setShowISOWeekNumbers(getWidget().isShowISOWeekNumbers());
getWidget().calendarPanel.setDateTimeService(getWidget() getWidget().calendarPanel
.getDateTimeService()); .setDateTimeService(getWidget().getDateTimeService());
getWidget().calendarPanel.setResolution(getWidget() getWidget().calendarPanel
.getCurrentResolution()); .setResolution(getWidget().getCurrentResolution());
Date currentDate = getWidget().getCurrentDate(); Date currentDate = getWidget().getCurrentDate();
if (currentDate != null) { if (currentDate != null) {
getWidget().calendarPanel.setDate(new Date(currentDate.getTime())); getWidget().calendarPanel.setDate(new Date(currentDate.getTime()));
} else { } else {
getWidget().calendarPanel.setDate(null); getWidget().calendarPanel.setDate(null);
} }


if (getWidget().getCurrentResolution().getCalendarField() > Resolution.DAY if (getWidget().getCurrentResolution()
.getCalendarField()) { .getCalendarField() > Resolution.DAY.getCalendarField()) {
getWidget().calendarPanel getWidget().calendarPanel
.setTimeChangeListener(new TimeChangeListener() { .setTimeChangeListener(new TimeChangeListener() {
@Override @Override
public void changed(int hour, int min, int sec, int msec) { public void changed(int hour, int min, int sec,
int msec) {
Date d = getWidget().getDate(); Date d = getWidget().getDate();
if (d == null) { if (d == null) {
// date currently null, use the value from // date currently null, use the value from
Expand All @@ -79,8 +80,8 @@ public void changed(int hour, int min, int sec, int msec) {
}); });
} }


if (getWidget().getCurrentResolution().getCalendarField() <= Resolution.MONTH if (getWidget().getCurrentResolution()
.getCalendarField()) { .getCalendarField() <= Resolution.MONTH.getCalendarField()) {
getWidget().calendarPanel getWidget().calendarPanel
.setFocusChangeListener(new FocusChangeListener() { .setFocusChangeListener(new FocusChangeListener() {
@Override @Override
Expand Down
Expand Up @@ -16,10 +16,10 @@


package com.vaadin.client.ui.datefield; package com.vaadin.client.ui.datefield;


import com.vaadin.legacy.ui.LegacyPopupDateField;
import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect;
import com.vaadin.ui.PopupDateField;


@Connect(LegacyPopupDateField.class) @Connect(PopupDateField.class)
public class PopupDateFieldConnector extends DateFieldConnector { public class PopupDateFieldConnector extends DateFieldConnector {


} }

0 comments on commit 87118c4

Please sign in to comment.