aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-02-20 16:04:06 +0200
committerLeif Åstrand <leif@vaadin.com>2012-02-20 16:04:06 +0200
commit70e58db73f06ef80b769fa30fc62ad7b70f1541c (patch)
treee2a7d3792966ce7e26876d001fbdb487ef2ed48e
parentff9e34d988a65fd5f246e97ec84fa63a344eb3d1 (diff)
downloadvaadin-framework-70e58db73f06ef80b769fa30fc62ad7b70f1541c.tar.gz
vaadin-framework-70e58db73f06ef80b769fa30fc62ad7b70f1541c.zip
PopupDateField without size calculations (#8313)
-rw-r--r--WebContent/VAADIN/themes/reindeer/datefield/datefield.css19
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java14
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VPopupCalendarPaintable.java9
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java75
4 files changed, 16 insertions, 101 deletions
diff --git a/WebContent/VAADIN/themes/reindeer/datefield/datefield.css b/WebContent/VAADIN/themes/reindeer/datefield/datefield.css
index 1dbc59257a..574a4973bf 100644
--- a/WebContent/VAADIN/themes/reindeer/datefield/datefield.css
+++ b/WebContent/VAADIN/themes/reindeer/datefield/datefield.css
@@ -45,6 +45,7 @@ span.v-datefield-calendarpanel-month {
}
.v-datefield-popupcalendar {
min-width: 0;
+ padding-right: 24px;
}
.v-datefield-year .v-datefield-calendarpanel {
width: 100px;
@@ -224,16 +225,25 @@ td.v-datefield-calendarpanel-nextyear {
.v-op .v-datefield-popup {
background: rgba(255,255,255,.95);
}
-.v-datefield-year .v-datefield-textfield {
+.v-datefield-textfield {
+ width: 100%;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+}
+.v-datefield.v-undefined-width > .v-datefield-textfield {
+ box-sizing: content-box;
+ -moz-box-sizing: content-box;
+}
+.v-datefield-year.v-undefined-width > .v-datefield-textfield {
width: 4em;
}
-.v-datefield-month .v-datefield-textfield {
+.v-datefield-month.v-undefined-width > .v-datefield-textfield {
width: 5em;
}
-.v-datefield-day .v-datefield-textfield {
+.v-datefield-day.v-undefined-width > .v-datefield-textfield {
width: 5.5em;
}
-.v-datefield-full .v-datefield-textfield {
+.v-datefield-full.v-undefined-width >.v-datefield-textfield {
width: 12em;
}
.v-datefield-popupcalendar input.v-datefield-textfield {
@@ -256,6 +266,7 @@ td.v-datefield-calendarpanel-nextyear {
}
.v-datefield-popupcalendar .v-datefield-button {
width: 24px;
+ margin-right: -24px;
height: 23px;
background: transparent;
border: none;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
index 1c0b937e05..cbd3a7af8f 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
@@ -277,20 +277,6 @@ public class VPopupCalendar extends VTextualDate implements Field,
/*
* (non-Javadoc)
*
- * @see com.vaadin.terminal.gwt.client.ui.VTextualDate#getFieldExtraWidth()
- */
- @Override
- protected int getFieldExtraWidth() {
- if (fieldExtraWidth < 0) {
- fieldExtraWidth = super.getFieldExtraWidth();
- fieldExtraWidth += calendarToggle.getOffsetWidth();
- }
- return fieldExtraWidth;
- }
-
- /*
- * (non-Javadoc)
- *
* @see com.vaadin.terminal.gwt.client.ui.VTextualDate#buildDate()
*/
@Override
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendarPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendarPaintable.java
index 042d730738..5beb912ff0 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendarPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendarPaintable.java
@@ -114,15 +114,6 @@ public class VPopupCalendarPaintable extends VTextualDatePaintable {
+ "-button-readonly");
}
- if (lastReadOnlyState != getWidgetForPaintable().readonly
- || lastEnabledState != getWidgetForPaintable().isEnabled()) {
- // Enabled or readonly state changed. Differences in theming might
- // affect the width (for instance if the popup button is hidden) so
- // we have to recalculate the width (IF the width of the field is
- // fixed)
- getWidgetForPaintable().updateWidth();
- }
-
getWidgetForPaintable().calendarToggle.setEnabled(true);
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
index bb808321b9..a19be371cf 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
@@ -14,7 +14,6 @@ import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.TextBox;
-import com.vaadin.terminal.gwt.client.ContainerResizedListener;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.Focusable;
import com.vaadin.terminal.gwt.client.LocaleNotLoadedException;
@@ -22,7 +21,7 @@ import com.vaadin.terminal.gwt.client.LocaleService;
import com.vaadin.terminal.gwt.client.VConsole;
public class VTextualDate extends VDateField implements Field, ChangeHandler,
- ContainerResizedListener, Focusable, SubPartAware {
+ Focusable, SubPartAware {
private static final String PARSE_ERROR_CLASSNAME = CLASSNAME
+ "-parseerror";
@@ -31,12 +30,6 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
protected String formatStr;
- private String width;
-
- private boolean needLayout;
-
- protected int fieldExtraWidth = -1;
-
protected boolean lenient;
private static final String CLASSNAME_PROMPT = "prompt";
@@ -295,72 +288,6 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
return format.trim();
}
- @Override
- public void setWidth(String newWidth) {
- if (!"".equals(newWidth)
- && (isUndefinedWidth() || !newWidth.equals(width))) {
- needLayout = true;
- width = newWidth;
- super.setWidth(width);
- iLayout();
- if (newWidth.indexOf("%") < 0) {
- needLayout = false;
- }
- } else {
- if ("".equals(newWidth) && !isUndefinedWidth()) {
- super.setWidth("");
- iLayout(true);
- width = null;
- }
- }
- }
-
- protected boolean isUndefinedWidth() {
- return width == null || "".equals(width);
- }
-
- /**
- * Returns pixels in x-axis reserved for other than textfield content.
- *
- * @return extra width in pixels
- */
- protected int getFieldExtraWidth() {
- if (fieldExtraWidth < 0) {
- text.setWidth("0");
- fieldExtraWidth = text.getOffsetWidth();
- }
- return fieldExtraWidth;
- }
-
- /**
- * Force an recalculation of the width of the component IF the width has
- * been defined. Does nothing if width is undefined as the width will be
- * automatically adjusted by the browser.
- */
- public void updateWidth() {
- if (isUndefinedWidth()) {
- return;
- }
- needLayout = true;
- fieldExtraWidth = -1;
- iLayout(true);
- }
-
- public void iLayout() {
- iLayout(false);
- }
-
- public void iLayout(boolean force) {
- if (needLayout || force) {
- int textFieldWidth = getOffsetWidth() - getFieldExtraWidth();
- if (textFieldWidth < 0) {
- // Field can never be smaller than 0 (causes exception in IE)
- textFieldWidth = 0;
- }
- text.setWidth(textFieldWidth + "px");
- }
- }
-
public void focus() {
text.setFocus(true);
}