Patch from Pekka with minor changes (ButtonCode -> MouseButton, FilteringMode -> ComboBox)
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.LocaleInfo;
-import com.vaadin.client.ui.datefield.VDateField;
+import com.vaadin.shared.ui.datefield.Resolution;
/**
* This class provides date/time parsing services to all components on the
}
public static boolean isInRange(Date date, Date rangeStart, Date rangeEnd,
- int resolution) {
+ Resolution resolution) {
Date s;
Date e;
if (rangeStart.after(rangeEnd)) {
long end = e.getYear() * 10000000000l;
long target = date.getYear() * 10000000000l;
- if (resolution == VDateField.RESOLUTION_YEAR) {
+ if (resolution == Resolution.YEAR) {
return (start <= target && end >= target);
}
start += s.getMonth() * 100000000l;
end += e.getMonth() * 100000000l;
target += date.getMonth() * 100000000l;
- if (resolution == VDateField.RESOLUTION_MONTH) {
+ if (resolution == Resolution.MONTH) {
return (start <= target && end >= target);
}
start += s.getDate() * 1000000l;
end += e.getDate() * 1000000l;
target += date.getDate() * 1000000l;
- if (resolution == VDateField.RESOLUTION_DAY) {
+ if (resolution == Resolution.DAY) {
return (start <= target && end >= target);
}
start += s.getHours() * 10000l;
end += e.getHours() * 10000l;
target += date.getHours() * 10000l;
- if (resolution == VDateField.RESOLUTION_HOUR) {
+ if (resolution == Resolution.HOUR) {
return (start <= target && end >= target);
}
start += s.getMinutes() * 100l;
end += e.getMinutes() * 100l;
target += date.getMinutes() * 100l;
- if (resolution == VDateField.RESOLUTION_MIN) {
+ if (resolution == Resolution.MINUTE) {
return (start <= target && end >= target);
}
start += s.getSeconds();
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.user.client.Event;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.MouseEventDetails.MouseButton;
/**
* Helper class for constructing a MouseEventDetails object from a
mouseEventDetails.setType(Event.getTypeInt(evt.getType()));
mouseEventDetails.setClientX(Util.getTouchOrMouseClientX(evt));
mouseEventDetails.setClientY(Util.getTouchOrMouseClientY(evt));
- mouseEventDetails.setButton(evt.getButton());
+ if (evt.getButton() == NativeEvent.BUTTON_LEFT) {
+ mouseEventDetails.setButton(MouseButton.LEFT);
+ } else if (evt.getButton() == NativeEvent.BUTTON_RIGHT) {
+ mouseEventDetails.setButton(MouseButton.RIGHT);
+ } else if (evt.getButton() == NativeEvent.BUTTON_MIDDLE) {
+ mouseEventDetails.setButton(MouseButton.MIDDLE);
+ }
mouseEventDetails.setAltKey(evt.getAltKey());
mouseEventDetails.setCtrlKey(evt.getCtrlKey());
mouseEventDetails.setMetaKey(evt.getMetaKey());
import com.vaadin.client.ui.menubar.MenuItem;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.combobox.ComboBoxConstants;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.ui.ComboBox;
@Connect(ComboBox.class)
}
if (uidl.hasAttribute("filteringmode")) {
- getWidget().filteringmode = uidl.getIntAttribute("filteringmode");
+ getWidget().filteringmode = FilteringMode.valueOf(uidl
+ .getStringAttribute("filteringmode"));
}
getWidget().immediate = getState().immediate;
import com.vaadin.shared.ComponentState;
import com.vaadin.shared.EventId;
import com.vaadin.shared.ui.ComponentStateUtil;
+import com.vaadin.shared.ui.combobox.FilteringMode;
/**
* Client side implementation of the Select component.
}
} else if (item != null
&& !"".equals(lastFilter)
- && (filteringmode == FILTERINGMODE_CONTAINS ? item
+ && (filteringmode == FilteringMode.CONTAINS ? item
.getText().toLowerCase()
.contains(lastFilter.toLowerCase()) : item
.getText().toLowerCase()
}
}
- public static final int FILTERINGMODE_OFF = 0;
- public static final int FILTERINGMODE_STARTSWITH = 1;
- public static final int FILTERINGMODE_CONTAINS = 2;
+ @Deprecated
+ public static final FilteringMode FILTERINGMODE_OFF = FilteringMode.OFF;
+ @Deprecated
+ public static final FilteringMode FILTERINGMODE_STARTSWITH = FilteringMode.STARTSWITH;
+ @Deprecated
+ public static final FilteringMode FILTERINGMODE_CONTAINS = FilteringMode.CONTAINS;
private static final String CLASSNAME = "v-filterselect";
private static final String STYLE_NO_INPUT = "no-input";
protected boolean enabled;
protected boolean readonly;
- protected int filteringmode = FILTERINGMODE_OFF;
+ protected FilteringMode filteringmode = FilteringMode.OFF;
// shown in unfocused empty field, disappears on focus (e.g "Search here")
private static final String CLASSNAME_PROMPT = "prompt";
import com.vaadin.client.VConsole;
import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.shared.ui.datefield.DateFieldConstants;
+import com.vaadin.shared.ui.datefield.Resolution;
public class AbstractDateFieldConnector extends AbstractFieldConnector
implements Paintable {
.getBooleanAttribute(DateFieldConstants.ATTR_WEEK_NUMBERS)
&& getWidget().dts.getFirstDayOfWeek() == 1;
- int newResolution;
+ Resolution newResolution;
if (uidl.hasVariable("sec")) {
- newResolution = VDateField.RESOLUTION_SEC;
+ newResolution = Resolution.SECOND;
} else if (uidl.hasVariable("min")) {
- newResolution = VDateField.RESOLUTION_MIN;
+ newResolution = Resolution.MINUTE;
} else if (uidl.hasVariable("hour")) {
- newResolution = VDateField.RESOLUTION_HOUR;
+ newResolution = Resolution.HOUR;
} else if (uidl.hasVariable("day")) {
- newResolution = VDateField.RESOLUTION_DAY;
+ newResolution = Resolution.DAY;
} else if (uidl.hasVariable("month")) {
- newResolution = VDateField.RESOLUTION_MONTH;
+ newResolution = Resolution.MONTH;
} else {
- newResolution = VDateField.RESOLUTION_YEAR;
+ newResolution = Resolution.YEAR;
}
// Remove old stylename that indicates current resolution
true);
final int year = uidl.getIntVariable("year");
- final int month = (getWidget().currentResolution >= VDateField.RESOLUTION_MONTH) ? uidl
- .getIntVariable("month") : -1;
- final int day = (getWidget().currentResolution >= VDateField.RESOLUTION_DAY) ? uidl
- .getIntVariable("day") : -1;
- final int hour = (getWidget().currentResolution >= VDateField.RESOLUTION_HOUR) ? uidl
- .getIntVariable("hour") : 0;
- final int min = (getWidget().currentResolution >= VDateField.RESOLUTION_MIN) ? uidl
- .getIntVariable("min") : 0;
- final int sec = (getWidget().currentResolution >= VDateField.RESOLUTION_SEC) ? uidl
- .getIntVariable("sec") : 0;
+ final int month = (getWidget().currentResolution.getCalendarField() >= Resolution.MONTH
+ .getCalendarField()) ? uidl.getIntVariable("month") : -1;
+ final int day = (getWidget().currentResolution.getCalendarField() >= Resolution.DAY
+ .getCalendarField()) ? uidl.getIntVariable("day") : -1;
+ final int hour = (getWidget().currentResolution.getCalendarField() >= Resolution.HOUR
+ .getCalendarField()) ? uidl.getIntVariable("hour") : 0;
+ final int min = (getWidget().currentResolution.getCalendarField() >= Resolution.MINUTE
+ .getCalendarField()) ? uidl.getIntVariable("min") : 0;
+ final int sec = (getWidget().currentResolution.getCalendarField() >= Resolution.SECOND
+ .getCalendarField()) ? uidl.getIntVariable("sec") : 0;
// Construct new date for this datefield (only if not null)
if (year > -1) {
import com.vaadin.client.ui.datefield.VCalendarPanel.FocusChangeListener;
import com.vaadin.client.ui.datefield.VCalendarPanel.TimeChangeListener;
import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.ui.InlineDateField;
@Connect(InlineDateField.class)
getWidget().calendarPanel.setDate(null);
}
- if (getWidget().currentResolution > VDateField.RESOLUTION_DAY) {
+ if (getWidget().currentResolution.getCalendarField() > Resolution.DAY
+ .getCalendarField()) {
getWidget().calendarPanel
.setTimeChangeListener(new TimeChangeListener() {
@Override
});
}
- if (getWidget().currentResolution <= VDateField.RESOLUTION_MONTH) {
+ if (getWidget().currentResolution.getCalendarField() <= Resolution.MONTH
+ .getCalendarField()) {
getWidget().calendarPanel
.setFocusChangeListener(new FocusChangeListener() {
@Override
import com.vaadin.client.ui.datefield.VCalendarPanel.FocusChangeListener;
import com.vaadin.client.ui.datefield.VCalendarPanel.TimeChangeListener;
import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.ui.DateField;
@Connect(DateField.class)
}
getWidget().calendarToggle.setEnabled(getWidget().enabled);
- if (getWidget().currentResolution <= VPopupCalendar.RESOLUTION_MONTH) {
+ if (getWidget().currentResolution.getCalendarField() <= Resolution.MONTH
+ .getCalendarField()) {
getWidget().calendar
.setFocusChangeListener(new FocusChangeListener() {
@Override
getWidget().calendar.setFocusChangeListener(null);
}
- if (getWidget().currentResolution > VPopupCalendar.RESOLUTION_DAY) {
+ if (getWidget().currentResolution.getCalendarField() > Resolution.DAY
+ .getCalendarField()) {
getWidget().calendar
.setTimeChangeListener(new TimeChangeListener() {
@Override
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.UIDL;
+import com.vaadin.shared.ui.datefield.Resolution;
public class TextualDateConnector extends AbstractDateFieldConnector {
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- int origRes = getWidget().currentResolution;
+ Resolution origRes = getWidget().currentResolution;
String oldLocale = getWidget().currentLocale;
super.updateFromUIDL(uidl, client);
if (origRes != getWidget().currentResolution
import com.vaadin.client.ui.SubPartAware;
import com.vaadin.client.ui.label.VLabel;
import com.vaadin.client.ui.nativeselect.VNativeSelect;
+import com.vaadin.shared.ui.datefield.Resolution;
@SuppressWarnings("deprecation")
public class VCalendarPanel extends FocusableFlexTable implements
private FlexTable days = new FlexTable();
- private int resolution = VDateField.RESOLUTION_YEAR;
+ private Resolution resolution = Resolution.YEAR;
private int focusedRow;
*/
private void focusDay(Date date) {
// Only used when calender body is present
- if (resolution > VDateField.RESOLUTION_MONTH) {
+ if (resolution.getCalendarField() > Resolution.MONTH.getCalendarField()) {
if (focusedDay != null) {
focusedDay.removeStyleDependentName(CN_FOCUSED);
}
return false;
}
- public int getResolution() {
+ public Resolution getResolution() {
return resolution;
}
- public void setResolution(int resolution) {
+ public void setResolution(Resolution resolution) {
this.resolution = resolution;
if (time != null) {
time.removeFromParent();
if (day > 6) {
day = 0;
}
- if (getResolution() > VDateField.RESOLUTION_MONTH) {
+ if (getResolution().getCalendarField() > Resolution.MONTH
+ .getCalendarField()) {
days.setHTML(headerRow, firstWeekdayColumn + i, "<strong>"
+ getDateTimeService().getShortDay(day) + "</strong>");
} else {
* @return True if it is required
*/
private boolean isTimeSelectorNeeded() {
- return getResolution() > VDateField.RESOLUTION_DAY;
+ return getResolution().getCalendarField() > Resolution.DAY
+ .getCalendarField();
}
/**
displayedMonth = new Date(now.getYear(), now.getMonth(), 1);
}
- if (getResolution() <= VDateField.RESOLUTION_MONTH
- && focusChangeListener != null) {
+ if (getResolution().getCalendarField() <= Resolution.MONTH
+ .getCalendarField() && focusChangeListener != null) {
focusChangeListener.focusChanged(new Date(focusedDate.getTime()));
}
- final boolean needsMonth = getResolution() > VDateField.RESOLUTION_YEAR;
- boolean needsBody = getResolution() >= VDateField.RESOLUTION_DAY;
+ final boolean needsMonth = getResolution().getCalendarField() > Resolution.YEAR
+ .getCalendarField();
+ boolean needsBody = getResolution().getCalendarField() >= Resolution.DAY
+ .getCalendarField();
buildCalendarHeader(needsMonth);
clearCalendarBody(!needsBody);
if (needsBody) {
return false;
}
- else if (resolution == VDateField.RESOLUTION_YEAR) {
+ else if (resolution == Resolution.YEAR) {
return handleNavigationYearMode(keycode, ctrl, shift);
}
- else if (resolution == VDateField.RESOLUTION_MONTH) {
+ else if (resolution == Resolution.MONTH) {
return handleNavigationMonthMode(keycode, ctrl, shift);
}
- else if (resolution == VDateField.RESOLUTION_DAY) {
+ else if (resolution == Resolution.DAY) {
return handleNavigationDayMode(keycode, ctrl, shift);
}
ampm.addChangeHandler(this);
}
- if (getResolution() >= VDateField.RESOLUTION_MIN) {
+ if (getResolution().getCalendarField() >= Resolution.MINUTE
+ .getCalendarField()) {
mins = createListBox();
for (int i = 0; i < 60; i++) {
mins.addItem((i < 10) ? "0" + i : "" + i);
}
mins.addChangeHandler(this);
}
- if (getResolution() >= VDateField.RESOLUTION_SEC) {
+ if (getResolution().getCalendarField() >= Resolution.SECOND
+ .getCalendarField()) {
sec = createListBox();
for (int i = 0; i < 60; i++) {
sec.addItem((i < 10) ? "0" + i : "" + i);
add(hours);
}
- if (getResolution() >= VDateField.RESOLUTION_MIN) {
+ if (getResolution().getCalendarField() >= Resolution.MINUTE
+ .getCalendarField()) {
add(new VLabel(delimiter));
if (isReadonly()) {
final int m = mins.getSelectedIndex();
add(mins);
}
}
- if (getResolution() >= VDateField.RESOLUTION_SEC) {
+ if (getResolution().getCalendarField() >= Resolution.SECOND
+ .getCalendarField()) {
add(new VLabel(delimiter));
if (isReadonly()) {
final int s = sec.getSelectedIndex();
add(sec);
}
}
- if (getResolution() == VDateField.RESOLUTION_HOUR) {
+ if (getResolution() == Resolution.HOUR) {
add(new VLabel(delimiter + "00")); // o'clock
}
if (getDateTimeService().isTwelveHourClock()) {
} else {
hours.setSelectedIndex(value.getHours());
}
- if (getResolution() >= VDateField.RESOLUTION_MIN) {
+ if (getResolution().getCalendarField() >= Resolution.MINUTE
+ .getCalendarField()) {
mins.setSelectedIndex(value.getMinutes());
}
- if (getResolution() >= VDateField.RESOLUTION_SEC) {
+ if (getResolution().getCalendarField() >= Resolution.SECOND
+ .getCalendarField()) {
sec.setSelectedIndex(value.getSeconds());
}
if (getDateTimeService().isTwelveHourClock()) {
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.DateTimeService;
import com.vaadin.client.ui.Field;
+import com.vaadin.shared.ui.datefield.Resolution;
public class VDateField extends FlowPanel implements Field {
protected boolean immediate;
- public static final int RESOLUTION_YEAR = 1;
- public static final int RESOLUTION_MONTH = 2;
- public static final int RESOLUTION_DAY = 4;
- public static final int RESOLUTION_HOUR = 8;
- public static final int RESOLUTION_MIN = 16;
- public static final int RESOLUTION_SEC = 32;
-
- static String resolutionToString(int res) {
- if (res > RESOLUTION_DAY) {
+ @Deprecated
+ public static final Resolution RESOLUTION_YEAR = Resolution.YEAR;
+ @Deprecated
+ public static final Resolution RESOLUTION_MONTH = Resolution.MONTH;
+ @Deprecated
+ public static final Resolution RESOLUTION_DAY = Resolution.DAY;
+ @Deprecated
+ public static final Resolution RESOLUTION_HOUR = Resolution.HOUR;
+ @Deprecated
+ public static final Resolution RESOLUTION_MIN = Resolution.MINUTE;
+ @Deprecated
+ public static final Resolution RESOLUTION_SEC = Resolution.SECOND;
+
+ static String resolutionToString(Resolution res) {
+ if (res.getCalendarField() > Resolution.DAY.getCalendarField()) {
return "full";
}
- if (res == RESOLUTION_DAY) {
+ if (res == Resolution.DAY) {
return "day";
}
- if (res == RESOLUTION_MONTH) {
+ if (res == Resolution.MONTH) {
return "month";
}
return "year";
}
- protected int currentResolution = RESOLUTION_YEAR;
+ protected Resolution currentResolution = Resolution.YEAR;
protected String currentLocale;
DateTimeService.setMilliseconds(date, ms);
}
- public int getCurrentResolution() {
+ public Resolution getCurrentResolution() {
return currentResolution;
}
- public void setCurrentResolution(int currentResolution) {
+ public void setCurrentResolution(Resolution currentResolution) {
this.currentResolution = currentResolution;
}
import com.vaadin.client.DateTimeService;
import com.vaadin.client.ui.datefield.VCalendarPanel.FocusOutListener;
import com.vaadin.client.ui.datefield.VCalendarPanel.SubmitListener;
+import com.vaadin.shared.ui.datefield.Resolution;
/**
* A client side implementation for InlineDateField
setCurrentDate((Date) date2.clone());
getClient().updateVariable(getId(), "year", date2.getYear() + 1900,
false);
- if (getCurrentResolution() > VDateField.RESOLUTION_YEAR) {
+ if (getCurrentResolution().getCalendarField() > Resolution.YEAR
+ .getCalendarField()) {
getClient().updateVariable(getId(), "month",
date2.getMonth() + 1, false);
- if (getCurrentResolution() > RESOLUTION_MONTH) {
+ if (getCurrentResolution().getCalendarField() > Resolution.MONTH
+ .getCalendarField()) {
getClient().updateVariable(getId(), "day", date2.getDate(),
false);
- if (getCurrentResolution() > RESOLUTION_DAY) {
+ if (getCurrentResolution().getCalendarField() > Resolution.DAY
+ .getCalendarField()) {
getClient().updateVariable(getId(), "hour",
date2.getHours(), false);
- if (getCurrentResolution() > RESOLUTION_HOUR) {
+ if (getCurrentResolution().getCalendarField() > Resolution.HOUR
+ .getCalendarField()) {
getClient().updateVariable(getId(), "min",
date2.getMinutes(), false);
- if (getCurrentResolution() > RESOLUTION_MIN) {
+ if (getCurrentResolution().getCalendarField() > Resolution.MINUTE
+ .getCalendarField()) {
getClient().updateVariable(getId(), "sec",
date2.getSeconds(), false);
- if (getCurrentResolution() > RESOLUTION_SEC) {
+ if (getCurrentResolution().getCalendarField() > Resolution.SECOND
+ .getCalendarField()) {
getClient().updateVariable(
getId(),
"msec",
import com.vaadin.client.ui.VOverlay;
import com.vaadin.client.ui.datefield.VCalendarPanel.FocusOutListener;
import com.vaadin.client.ui.datefield.VCalendarPanel.SubmitListener;
+import com.vaadin.shared.ui.datefield.Resolution;
/**
* Represents a date selection component with a text field and a popup date
setCurrentDate((Date) newDate.clone());
getClient().updateVariable(getId(), "year",
newDate.getYear() + 1900, false);
- if (getCurrentResolution() > VDateField.RESOLUTION_YEAR) {
+ if (getCurrentResolution().getCalendarField() > Resolution.YEAR
+ .getCalendarField()) {
getClient().updateVariable(getId(), "month",
newDate.getMonth() + 1, false);
- if (getCurrentResolution() > RESOLUTION_MONTH) {
+ if (getCurrentResolution().getCalendarField() > Resolution.MONTH
+ .getCalendarField()) {
getClient().updateVariable(getId(), "day",
newDate.getDate(), false);
- if (getCurrentResolution() > RESOLUTION_DAY) {
+ if (getCurrentResolution().getCalendarField() > Resolution.DAY
+ .getCalendarField()) {
getClient().updateVariable(getId(), "hour",
newDate.getHours(), false);
- if (getCurrentResolution() > RESOLUTION_HOUR) {
+ if (getCurrentResolution().getCalendarField() > Resolution.HOUR
+ .getCalendarField()) {
getClient().updateVariable(getId(), "min",
newDate.getMinutes(), false);
- if (getCurrentResolution() > RESOLUTION_MIN) {
+ if (getCurrentResolution().getCalendarField() > Resolution.MINUTE
+ .getCalendarField()) {
getClient().updateVariable(getId(), "sec",
newDate.getSeconds(), false);
}
import com.vaadin.client.ui.SubPartAware;
import com.vaadin.client.ui.textfield.VTextField;
import com.vaadin.shared.EventId;
+import com.vaadin.shared.ui.datefield.Resolution;
public class VTextualDate extends VDateField implements Field, ChangeHandler,
Focusable, SubPartAware {
protected String getFormatString() {
if (formatStr == null) {
- if (currentResolution == RESOLUTION_YEAR) {
+ if (currentResolution == Resolution.YEAR) {
formatStr = "yyyy"; // force full year
} else {
frmString = cleanFormat(frmString);
// String delim = LocaleService
// .getClockDelimiter(currentLocale);
-
- if (currentResolution >= RESOLUTION_HOUR) {
+ if (currentResolution.getCalendarField() >= Resolution.HOUR
+ .getCalendarField()) {
if (dts.isTwelveHourClock()) {
frmString += " hh";
} else {
frmString += " HH";
}
- if (currentResolution >= RESOLUTION_MIN) {
+ if (currentResolution.getCalendarField() >= Resolution.MINUTE
+ .getCalendarField()) {
frmString += ":mm";
- if (currentResolution >= RESOLUTION_SEC) {
+ if (currentResolution.getCalendarField() >= Resolution.SECOND
+ .getCalendarField()) {
frmString += ":ss";
}
}
Date currentDate = getDate();
getClient().updateVariable(getId(), "year",
currentDate != null ? currentDate.getYear() + 1900 : -1,
- currentResolution == VDateField.RESOLUTION_YEAR && immediate);
- if (currentResolution >= VDateField.RESOLUTION_MONTH) {
- getClient().updateVariable(
- getId(),
- "month",
+ currentResolution == Resolution.YEAR && immediate);
+ if (currentResolution.getCalendarField() >= Resolution.MONTH
+ .getCalendarField()) {
+ getClient().updateVariable(getId(), "month",
currentDate != null ? currentDate.getMonth() + 1 : -1,
- currentResolution == VDateField.RESOLUTION_MONTH
- && immediate);
+ currentResolution == Resolution.MONTH && immediate);
}
- if (currentResolution >= VDateField.RESOLUTION_DAY) {
- getClient()
- .updateVariable(
- getId(),
- "day",
- currentDate != null ? currentDate.getDate() : -1,
- currentResolution == VDateField.RESOLUTION_DAY
- && immediate);
+ if (currentResolution.getCalendarField() >= Resolution.DAY
+ .getCalendarField()) {
+ getClient().updateVariable(getId(), "day",
+ currentDate != null ? currentDate.getDate() : -1,
+ currentResolution == Resolution.DAY && immediate);
}
- if (currentResolution >= VDateField.RESOLUTION_HOUR) {
- getClient().updateVariable(
- getId(),
- "hour",
+ if (currentResolution.getCalendarField() >= Resolution.HOUR
+ .getCalendarField()) {
+ getClient().updateVariable(getId(), "hour",
currentDate != null ? currentDate.getHours() : -1,
- currentResolution == VDateField.RESOLUTION_HOUR
- && immediate);
+ currentResolution == Resolution.HOUR && immediate);
}
- if (currentResolution >= VDateField.RESOLUTION_MIN) {
- getClient()
- .updateVariable(
- getId(),
- "min",
- currentDate != null ? currentDate.getMinutes() : -1,
- currentResolution == VDateField.RESOLUTION_MIN
- && immediate);
+ if (currentResolution.getCalendarField() >= Resolution.MINUTE
+ .getCalendarField()) {
+ getClient().updateVariable(getId(), "min",
+ currentDate != null ? currentDate.getMinutes() : -1,
+ currentResolution == Resolution.MINUTE && immediate);
}
- if (currentResolution >= VDateField.RESOLUTION_SEC) {
- getClient()
- .updateVariable(
- getId(),
- "sec",
- currentDate != null ? currentDate.getSeconds() : -1,
- currentResolution == VDateField.RESOLUTION_SEC
- && immediate);
+ if (currentResolution.getCalendarField() >= Resolution.SECOND
+ .getCalendarField()) {
+ getClient().updateVariable(getId(), "sec",
+ currentDate != null ? currentDate.getSeconds() : -1,
+ currentResolution == Resolution.SECOND && immediate);
}
}
private String cleanFormat(String format) {
// Remove unnecessary d & M if resolution is too low
- if (currentResolution < VDateField.RESOLUTION_DAY) {
+ if (currentResolution.getCalendarField() < Resolution.DAY
+ .getCalendarField()) {
format = format.replaceAll("d", "");
}
- if (currentResolution < VDateField.RESOLUTION_MONTH) {
+ if (currentResolution.getCalendarField() < Resolution.MONTH
+ .getCalendarField()) {
format = format.replaceAll("M", "");
}
import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler;
import com.vaadin.client.ui.VOverlay;
import com.vaadin.client.ui.splitpanel.VAbstractSplitPanel.SplitterMoveHandler.SplitterMoveEvent;
+import com.vaadin.shared.ui.Orientation;
public class VAbstractSplitPanel extends ComplexPanel {
public static final String CLASSNAME = "v-splitpanel";
- public static final int ORIENTATION_HORIZONTAL = 0;
-
- public static final int ORIENTATION_VERTICAL = 1;
-
private static final int MIN_SIZE = 30;
- private int orientation = ORIENTATION_HORIZONTAL;
+ private Orientation orientation = Orientation.HORIZONTAL;
Widget firstChild;
protected int origScrollTop;
public VAbstractSplitPanel() {
- this(ORIENTATION_HORIZONTAL);
+ this(Orientation.HORIZONTAL);
}
- public VAbstractSplitPanel(int orientation) {
+ public VAbstractSplitPanel(Orientation orientation) {
setElement(DOM.createDiv());
setStyleName(StyleConstants.UI_LAYOUT);
switch (orientation) {
- case ORIENTATION_HORIZONTAL:
+ case HORIZONTAL:
addStyleName(CLASSNAME + "-horizontal");
break;
- case ORIENTATION_VERTICAL:
+ case VERTICAL:
default:
addStyleName(CLASSNAME + "-vertical");
break;
setStylenames();
}
- private void setOrientation(int orientation) {
+ private void setOrientation(Orientation orientation) {
this.orientation = orientation;
- if (orientation == ORIENTATION_HORIZONTAL) {
+ if (orientation == Orientation.HORIZONTAL) {
DOM.setStyleAttribute(splitter, "height", "100%");
DOM.setStyleAttribute(splitter, "top", "0");
DOM.setStyleAttribute(firstContainer, "height", "100%");
void setPositionReversed(boolean reversed) {
if (positionReversed != reversed) {
- if (orientation == ORIENTATION_HORIZONTAL) {
+ if (orientation == Orientation.HORIZONTAL) {
DOM.setStyleAttribute(splitter, "right", "");
DOM.setStyleAttribute(splitter, "left", "");
- } else if (orientation == ORIENTATION_VERTICAL) {
+ } else if (orientation == Orientation.VERTICAL) {
DOM.setStyleAttribute(splitter, "top", "");
DOM.setStyleAttribute(splitter, "bottom", "");
}
posAsFloat = Math.round(Float.parseFloat(pos.substring(0,
pos.length() - 1))
/ 100
- * (orientation == ORIENTATION_HORIZONTAL ? getOffsetWidth()
+ * (orientation == Orientation.HORIZONTAL ? getOffsetWidth()
: getOffsetHeight()));
} else {
posAsFloat = Float.parseFloat(pos.substring(0, pos.length() - 2));
if (pos.endsWith("px")) {
float pixelPosition = Float.parseFloat(pos.substring(0,
pos.length() - 2));
- int offsetLength = orientation == ORIENTATION_HORIZONTAL ? getOffsetWidth()
+ int offsetLength = orientation == Orientation.HORIZONTAL ? getOffsetWidth()
: getOffsetHeight();
// Take splitter size into account at the edge
// Convert percentage values to pixels
if (pos.indexOf("%") > 0) {
- int size = orientation == ORIENTATION_HORIZONTAL ? getOffsetWidth()
+ int size = orientation == Orientation.HORIZONTAL ? getOffsetWidth()
: getOffsetHeight();
float percentage = Float.parseFloat(pos.substring(0,
pos.length() - 1));
}
String attributeName;
- if (orientation == ORIENTATION_HORIZONTAL) {
+ if (orientation == Orientation.HORIZONTAL) {
if (positionReversed) {
attributeName = "right";
} else {
int pixelPosition;
switch (orientation) {
- case ORIENTATION_HORIZONTAL:
+ case HORIZONTAL:
wholeSize = DOM.getElementPropertyInt(wrapper, "clientWidth");
pixelPosition = DOM.getElementPropertyInt(splitter, "offsetLeft");
}
}
break;
- case ORIENTATION_VERTICAL:
+ case VERTICAL:
wholeSize = DOM.getElementPropertyInt(wrapper, "clientHeight");
pixelPosition = DOM.getElementPropertyInt(splitter, "offsetTop");
public void onMouseMove(Event event) {
switch (orientation) {
- case ORIENTATION_HORIZONTAL:
+ case HORIZONTAL:
final int x = Util.getTouchOrMouseClientX(event);
onHorizontalMouseMove(x);
break;
- case ORIENTATION_VERTICAL:
+ case VERTICAL:
default:
final int y = Util.getTouchOrMouseClientY(event);
onVerticalMouseMove(y);
if (splitterSize < 0) {
if (isAttached()) {
switch (orientation) {
- case ORIENTATION_HORIZONTAL:
+ case HORIZONTAL:
splitterSize = DOM.getElementPropertyInt(splitter,
"offsetWidth");
break;
void setStylenames() {
final String splitterClass = CLASSNAME
- + (orientation == ORIENTATION_HORIZONTAL ? "-hsplitter"
+ + (orientation == Orientation.HORIZONTAL ? "-hsplitter"
: "-vsplitter");
final String firstContainerClass = CLASSNAME + "-first-container";
final String secondContainerClass = CLASSNAME + "-second-container";
package com.vaadin.client.ui.splitpanel;
+import com.vaadin.shared.ui.Orientation;
+
public class VSplitPanelHorizontal extends VAbstractSplitPanel {
public VSplitPanelHorizontal() {
- super(VAbstractSplitPanel.ORIENTATION_HORIZONTAL);
+ super(Orientation.HORIZONTAL);
}
}
package com.vaadin.client.ui.splitpanel;
+import com.vaadin.shared.ui.Orientation;
+
public class VSplitPanelVertical extends VAbstractSplitPanel {
public VSplitPanelVertical() {
- super(VAbstractSplitPanel.ORIENTATION_VERTICAL);
+ super(Orientation.VERTICAL);
}
}
import com.vaadin.client.ui.tree.VTree.TreeNode;
import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.shared.ui.tree.TreeConstants;
import com.vaadin.ui.Tree;
if (BrowserInfo.get().isTouchDevice()) {
// Always use the simple mode for touch devices that do not have
// shift/ctrl keys (#8595)
- getWidget().multiSelectMode = VTree.MULTISELECT_MODE_SIMPLE;
+ getWidget().multiSelectMode = MultiSelectMode.SIMPLE;
} else {
- getWidget().multiSelectMode = uidl
- .getIntAttribute("multiselectmode");
+ getWidget().multiSelectMode = MultiSelectMode.valueOf(uidl
+ .getStringAttribute("multiselectmode"));
}
}
import com.vaadin.client.ui.dd.VHasDropHandler;
import com.vaadin.client.ui.dd.VTransferable;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.MouseEventDetails.MouseButton;
+import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.shared.ui.dd.VerticalDropLocation;
import com.vaadin.shared.ui.tree.TreeConstants;
public static final String CLASSNAME = "v-tree";
/**
- * Click selects the current node, ctrl/shift toggles multi selection
+ * @deprecated from 7.0, use {@link MultiSelectMode#DEFAULT} instead.
*/
- public static final int MULTISELECT_MODE_DEFAULT = 0;
+ @Deprecated
+ public static final MultiSelectMode MULTISELECT_MODE_DEFAULT = MultiSelectMode.DEFAULT;
/**
- * Click/touch on node toggles its selected status
+ * @deprecated from 7.0, use {@link MultiSelectMode#SIMPLE} instead.
*/
- public static final int MULTISELECT_MODE_SIMPLE = 1;
+ @Deprecated
+ public static final MultiSelectMode MULTISELECT_MODE_SIMPLE = MultiSelectMode.SIMPLE;
private static final int CHARCODE_SPACE = 32;
private String currentMouseOverKey;
TreeNode lastSelection;
TreeNode focusedNode;
- int multiSelectMode = MULTISELECT_MODE_DEFAULT;
+ MultiSelectMode multiSelectMode = MultiSelectMode.DEFAULT;
private final HashMap<String, TreeNode> keyToNode = new HashMap<String, TreeNode>();
@Override
public void execute() {
- if (multiSelectMode == MULTISELECT_MODE_SIMPLE
+ if (multiSelectMode == MultiSelectMode.SIMPLE
|| !isMultiselect) {
toggleSelection();
lastSelection = TreeNode.this;
- } else if (multiSelectMode == MULTISELECT_MODE_DEFAULT) {
+ } else if (multiSelectMode == MultiSelectMode.DEFAULT) {
// Handle ctrl+click
if (isMultiselect && ctrl && !shift) {
toggleSelection();
// we want to send it immediately.
boolean sendClickEventNow = true;
- if (details.getButton() == NativeEvent.BUTTON_LEFT
- && immediate && selectable) {
+ if (details.getButton() == MouseButton.LEFT && immediate
+ && selectable) {
// Probably a selection that will cause a value change
// event to be sent
sendClickEventNow = false;
import java.util.Date;
-import com.vaadin.ui.DateField.Resolution;
+import com.vaadin.shared.ui.datefield.Resolution;
/**
* Validator for validating that a Date is inside a given range.
import java.lang.reflect.Method;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.MouseEventDetails.MouseButton;
import com.vaadin.ui.Component;
import com.vaadin.util.ReflectTools;
* @since 6.2
*/
public static class ClickEvent extends Component.Event {
- public static final int BUTTON_LEFT = MouseEventDetails.BUTTON_LEFT;
- public static final int BUTTON_MIDDLE = MouseEventDetails.BUTTON_MIDDLE;
- public static final int BUTTON_RIGHT = MouseEventDetails.BUTTON_RIGHT;
-
+ /**
+ * @deprecated use {@link Button#LEFT} instead.
+ */
+ @Deprecated
+ public static final MouseButton BUTTON_LEFT = MouseButton.LEFT;
+ /**
+ * @deprecated use {@link Button#MIDDLE} instead.
+ */
+ @Deprecated
+ public static final MouseButton BUTTON_MIDDLE = MouseButton.MIDDLE;
+ /**
+ * @deprecated use {@link Button#RIGHT} instead.
+ */
+ @Deprecated
+ public static final MouseButton BUTTON_RIGHT = MouseButton.RIGHT;
private MouseEventDetails details;
public ClickEvent(Component source, MouseEventDetails mouseEventDetails) {
/**
* Returns an identifier describing which mouse button the user pushed.
- * Compare with {@link #BUTTON_LEFT},{@link #BUTTON_MIDDLE},
- * {@link #BUTTON_RIGHT} to find out which butten it is.
+ * Compare with {@link MouseButton#LEFT},{@link MouseButton#MIDDLE},
+ * {@link Button#RIGHT} to find out which button it is.
*
- * @return one of {@link #BUTTON_LEFT}, {@link #BUTTON_MIDDLE},
- * {@link #BUTTON_RIGHT}.
+ * @return one of {@link MouseButton#LEFT}, {@link MouseButton#MIDDLE},
+ * {@link MouseButton#RIGHT}.
*/
- public int getButton() {
+ public MouseButton getButton() {
return details.getButton();
}
"browserWindowResized", BrowserWindowResizeEvent.class);
/**
- * A border style used for opening resources in a window without a border.
+ * @deprecated from 7.0, use {@link BorderStyle#NONE} instead.
*/
@Deprecated
public static final BorderStyle BORDER_NONE = BorderStyle.NONE;
/**
- * A border style used for opening resources in a window with a minimal
- * border.
+ * @deprecated from 7.0, use {@link BorderStyle#MINIMAL} instead.
*/
+ @Deprecated
public static final BorderStyle BORDER_MINIMAL = BorderStyle.MINIMAL;
/**
- * A border style that indicates that the default border style should be
- * used when opening resources.
+ * @deprecated from 7.0, use {@link BorderStyle#DEFAULT} instead.
*/
+ @Deprecated
public static final BorderStyle BORDER_DEFAULT = BorderStyle.DEFAULT;
/**
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.Resource;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.shared.ui.dd.VerticalDropLocation;
/**
/**
* Interface for option filtering, used to filter options based on user
* entered value. The value is matched to the item caption.
- * <code>FILTERINGMODE_OFF</code> (0) turns the filtering off.
- * <code>FILTERINGMODE_STARTSWITH</code> (1) matches from the start of the
- * caption. <code>FILTERINGMODE_CONTAINS</code> (1) matches anywhere in the
+ * <code>FilteringMode.OFF</code> (0) turns the filtering off.
+ * <code>FilteringMode.STARTSWITH</code> (1) matches from the start of the
+ * caption. <code>FilteringMode.CONTAINS</code> (1) matches anywhere in the
* caption.
*/
public interface Filtering extends Serializable {
- public static final int FILTERINGMODE_OFF = 0;
- public static final int FILTERINGMODE_STARTSWITH = 1;
- public static final int FILTERINGMODE_CONTAINS = 2;
+
+ /**
+ * @deprecated from 7.0, use {@link FilteringMode#OFF} instead
+ */
+ @Deprecated
+ public static final FilteringMode FILTERINGMODE_OFF = FilteringMode.OFF;
+ /**
+ * @deprecated from 7.0, use {@link FilteringMode#STARTSWITH} instead
+ */
+ @Deprecated
+ public static final FilteringMode FILTERINGMODE_STARTSWITH = FilteringMode.STARTSWITH;
+ /**
+ * @deprecated from 7.0, use {@link FilteringMode#CONTAINS} instead
+ */
+ @Deprecated
+ public static final FilteringMode FILTERINGMODE_CONTAINS = FilteringMode.CONTAINS;
/**
* Sets the option filtering mode.
* @param filteringMode
* the filtering mode to use
*/
- public void setFilteringMode(int filteringMode);
+ public void setFilteringMode(FilteringMode filteringMode);
/**
* Gets the current filtering mode.
*
* @return the filtering mode in use
*/
- public int getFilteringMode();
-
- }
-
- /**
- * Multi select modes that controls how multi select behaves.
- */
- public enum MultiSelectMode {
- /**
- * The default behavior of the multi select mode
- */
- DEFAULT,
+ public FilteringMode getFilteringMode();
- /**
- * The previous more simple behavior of the multselect
- */
- SIMPLE
}
/**
import com.vaadin.server.PaintTarget;
import com.vaadin.server.Resource;
import com.vaadin.shared.ui.combobox.ComboBoxConstants;
+import com.vaadin.shared.ui.combobox.FilteringMode;
/**
* A filtering dropdown single-select. Suitable for newItemsAllowed, but it's
// Current page when the user is 'paging' trough options
private int currentPage = -1;
- private int filteringMode = Filtering.FILTERINGMODE_STARTSWITH;
+ private FilteringMode filteringMode = FilteringMode.STARTSWITH;
private String filterstring;
private String prevfilterstring;
target.addAttribute("pagelength", pageLength);
- target.addAttribute("filteringmode", getFilteringMode());
+ target.addAttribute("filteringmode", getFilteringMode().toString());
// Paints the options and create array of selected id keys
int keyIndex = 0;
boolean nullFilteredOut = filterstring != null
&& !"".equals(filterstring)
- && filteringMode != Filtering.FILTERINGMODE_OFF;
+ && filteringMode != FilteringMode.OFF;
// null option is needed and not filtered out, even if not on current
// page
boolean nullOptionVisible = needNullSelectOption && !nullFilteredOut;
* @param filteringMode
* @return
*/
- protected Filter buildFilter(String filterString, int filteringMode) {
+ protected Filter buildFilter(String filterString,
+ FilteringMode filteringMode) {
Filter filter = null;
if (null != filterString && !"".equals(filterString)) {
switch (filteringMode) {
- case Filtering.FILTERINGMODE_OFF:
+ case OFF:
break;
- case Filtering.FILTERINGMODE_STARTSWITH:
+ case STARTSWITH:
filter = new SimpleStringFilter(getItemCaptionPropertyId(),
filterString, true, true);
break;
- case Filtering.FILTERINGMODE_CONTAINS:
+ case CONTAINS:
filter = new SimpleStringFilter(getItemCaptionPropertyId(),
filterString, true, false);
break;
*/
protected List<?> getFilteredOptions() {
if (null == filterstring || "".equals(filterstring)
- || Filtering.FILTERINGMODE_OFF == filteringMode) {
+ || FilteringMode.OFF == filteringMode) {
prevfilterstring = null;
filteredOptions = new LinkedList<Object>(getItemIds());
return filteredOptions;
caption = caption.toLowerCase();
}
switch (filteringMode) {
- case Filtering.FILTERINGMODE_CONTAINS:
+ case CONTAINS:
if (caption.indexOf(filterstring) > -1) {
filteredOptions.add(itemId);
}
break;
- case Filtering.FILTERINGMODE_STARTSWITH:
+ case STARTSWITH:
default:
if (caption.startsWith(filterstring)) {
filteredOptions.add(itemId);
}
@Override
- public void setFilteringMode(int filteringMode) {
+ public void setFilteringMode(FilteringMode filteringMode) {
this.filteringMode = filteringMode;
}
@Override
- public int getFilteringMode() {
+ public FilteringMode getFilteringMode() {
return filteringMode;
}
package com.vaadin.ui;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.shared.ui.datefield.DateFieldConstants;
+import com.vaadin.shared.ui.datefield.Resolution;
/**
* <p>
public class DateField extends AbstractField<Date> implements
FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, LegacyComponent {
- /**
- * Resolutions for DateFields
- *
- * @author Vaadin Ltd.
- * @since 7.0
- */
- public enum Resolution {
- SECOND(Calendar.SECOND), MINUTE(Calendar.MINUTE), HOUR(
- Calendar.HOUR_OF_DAY), DAY(Calendar.DAY_OF_MONTH), MONTH(
- Calendar.MONTH), YEAR(Calendar.YEAR);
-
- private int calendarField;
-
- private Resolution(int calendarField) {
- this.calendarField = calendarField;
- }
-
- /**
- * Returns the field in {@link Calendar} that corresponds to this
- * resolution.
- *
- * @return one of the field numbers used by Calendar
- */
- public int getCalendarField() {
- return calendarField;
- }
-
- /**
- * Returns the resolutions that are higher or equal to the given
- * resolution, starting from the given resolution. In other words
- * passing DAY to this methods returns DAY,MONTH,YEAR
- *
- * @param r
- * The resolution to start from
- * @return An iterable for the resolutions higher or equal to r
- */
- public static Iterable<Resolution> getResolutionsHigherOrEqualTo(
- Resolution r) {
- List<Resolution> resolutions = new ArrayList<DateField.Resolution>();
- Resolution[] values = Resolution.values();
- for (int i = r.ordinal(); i < values.length; i++) {
- resolutions.add(values[i]);
- }
- return resolutions;
- }
-
- /**
- * Returns the resolutions that are lower than the given resolution,
- * starting from the given resolution. In other words passing DAY to
- * this methods returns HOUR,MINUTE,SECOND.
- *
- * @param r
- * The resolution to start from
- * @return An iterable for the resolutions lower than r
- */
- public static List<Resolution> getResolutionsLowerThan(Resolution r) {
- List<Resolution> resolutions = new ArrayList<DateField.Resolution>();
- Resolution[] values = Resolution.values();
- for (int i = r.ordinal() - 1; i >= 0; i--) {
- resolutions.add(values[i]);
- }
- return resolutions;
- }
- };
-
/**
* Resolution identifier: seconds.
*
private TimeZone timeZone = null;
- private static Map<Resolution, String> variableNameForResolution = new HashMap<DateField.Resolution, String>();
+ private static Map<Resolution, String> variableNameForResolution = new HashMap<Resolution, String>();
{
variableNameForResolution.put(Resolution.SECOND, "sec");
variableNameForResolution.put(Resolution.MINUTE, "min");
// Gets the new date in parts
boolean hasChanges = false;
- Map<Resolution, Integer> calendarFieldChanges = new HashMap<DateField.Resolution, Integer>();
+ Map<Resolution, Integer> calendarFieldChanges = new HashMap<Resolution, Integer>();
for (Resolution r : Resolution
.getResolutionsHigherOrEqualTo(resolution)) {
@SuppressWarnings("serial")
public class Link extends AbstractComponent implements LegacyComponent {
- /* Target window border type constant: No window border */
+ /**
+ * @deprecated from 7.0, use {@link BorderStyle#NONE} instead
+ */
@Deprecated
public static final BorderStyle TARGET_BORDER_NONE = BorderStyle.NONE;
- /* Target window border type constant: Minimal window border */
+ /**
+ * @deprecated from 7.0, use {@link BorderStyle#MINIMAL} instead
+ */
@Deprecated
public static final BorderStyle TARGET_BORDER_MINIMAL = BorderStyle.MINIMAL;
- /* Target window border type constant: Default window border */
+ /**
+ * @deprecated from 7.0, use {@link BorderStyle#DEFAULT} instead
+ */
@Deprecated
public static final BorderStyle TARGET_BORDER_DEFAULT = BorderStyle.DEFAULT;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.Resource;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.shared.ui.table.TableConstants;
/**
import com.vaadin.server.PaintTarget;
import com.vaadin.server.Resource;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.shared.ui.dd.VerticalDropLocation;
import com.vaadin.shared.ui.tree.TreeConstants;
import com.vaadin.util.ReflectTools;
: "single"));
if (isMultiSelect()) {
target.addAttribute("multiselectmode",
- multiSelectMode.ordinal());
+ multiSelectMode.toString());
}
} else {
target.addAttribute("selectmode", "none");
import junit.framework.TestCase;
+import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.util.TestUtil;
-import com.vaadin.ui.DateField.Resolution;
public class ResolutionTest extends TestCase {
import com.vaadin.data.Container;
import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.ui.AbstractSelect.MultiSelectMode;
+import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.ui.Table;
public class TestMultipleSelection extends TestCase {
* Helper class to store and transfer mouse event details.
*/
public class MouseEventDetails implements Serializable {
- // From com.google.gwt.dom.client.NativeEvent
- public static final int BUTTON_LEFT = 1;
- public static final int BUTTON_MIDDLE = 4;
- public static final int BUTTON_RIGHT = 2;
+ /**
+ * @deprecated use {@link MouseButton#LEFT} instead.
+ */
+ @Deprecated
+ public static final MouseButton BUTTON_LEFT = MouseButton.LEFT;
+ /**
+ * @deprecated use {@link MouseButton#MIDDLE} instead.
+ */
+ @Deprecated
+ public static final MouseButton BUTTON_MIDDLE = MouseButton.MIDDLE;
+ /**
+ * @deprecated use {@link MouseButton#RIGHT} instead.
+ */
+ @Deprecated
+ public static final MouseButton BUTTON_RIGHT = MouseButton.RIGHT;
+
+ /**
+ * Constants for mouse buttons.
+ *
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0
+ *
+ */
+ public enum MouseButton {
+ LEFT("left"), RIGHT("right"), MIDDLE("middle");
+
+ private String name;
+
+ private MouseButton(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns a human readable text representing the button
+ *
+ * @return
+ */
+ public String getName() {
+ return name;
+ }
+
+ }
private static final char DELIM = ',';
// From com.google.gwt.user.client.Event
private static final int ONDBLCLICK = 0x00002;
- private int button;
+ private MouseButton button;
private int clientX;
private int clientY;
private boolean altKey;
private int relativeX = -1;
private int relativeY = -1;
- public int getButton() {
+ public MouseButton getButton() {
return button;
}
return relativeY;
}
- public void setButton(int button) {
+ public void setButton(MouseButton button) {
this.button = button;
}
}
public String serialize() {
- return "" + button + DELIM + clientX + DELIM + clientY + DELIM + altKey
- + DELIM + ctrlKey + DELIM + metaKey + DELIM + shiftKey + DELIM
- + type + DELIM + relativeX + DELIM + relativeY;
+ return button.toString() + DELIM + clientX + DELIM + clientY + DELIM
+ + altKey + DELIM + ctrlKey + DELIM + metaKey + DELIM + shiftKey
+ + DELIM + type + DELIM + relativeX + DELIM + relativeY;
}
public static MouseEventDetails deSerialize(String serializedString) {
MouseEventDetails instance = new MouseEventDetails();
String[] fields = serializedString.split(",");
-
- instance.button = Integer.parseInt(fields[0]);
+ instance.button = MouseButton.valueOf(fields[0]);
instance.clientX = Integer.parseInt(fields[1]);
instance.clientY = Integer.parseInt(fields[2]);
instance.altKey = Boolean.valueOf(fields[3]).booleanValue();
}
public String getButtonName() {
- if (button == BUTTON_LEFT) {
- return "left";
- } else if (button == BUTTON_RIGHT) {
- return "right";
- } else if (button == BUTTON_MIDDLE) {
- return "middle";
- }
-
- return "";
+ return button == null ? "" : button.getName();
}
public int getType() {
*/
package com.vaadin.shared.ui;
+/**
+ * Constants for border styles used on HTML elements.
+ *
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0
+ *
+ */
public enum BorderStyle {
- NONE, MINIMAL, DEFAULT;
+ /**
+ * A border style used for using no border.
+ */
+ NONE,
+
+ /**
+ * A border style used for a minimal border.
+ */
+ MINIMAL,
+
+ /**
+ * A border style that indicates that the default border style should be
+ * used.
+ */
+ DEFAULT;
}
--- /dev/null
+package com.vaadin.shared.ui;
+
+/**
+ * Multi select modes that controls how multi select behaves.
+ */
+public enum MultiSelectMode {
+ /**
+ * The default behavior of the multi select mode
+ */
+ DEFAULT,
+
+ /**
+ * The previous more simple behavior of the multi select
+ */
+ SIMPLE
+}
--- /dev/null
+package com.vaadin.shared.ui;
+
+public enum Orientation {
+ HORIZONTAL, VERTICAL;
+}
--- /dev/null
+package com.vaadin.shared.ui.combobox;
+
+public enum FilteringMode {
+ OFF, STARTSWITH, CONTAINS;
+}
--- /dev/null
+package com.vaadin.shared.ui.datefield;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * Resolutions for DateFields
+ *
+ * @author Vaadin Ltd.
+ * @since 7.0
+ */
+public enum Resolution {
+ SECOND(Calendar.SECOND), MINUTE(Calendar.MINUTE), HOUR(Calendar.HOUR_OF_DAY), DAY(
+ Calendar.DAY_OF_MONTH), MONTH(Calendar.MONTH), YEAR(Calendar.YEAR);
+
+ private int calendarField;
+
+ private Resolution(int calendarField) {
+ this.calendarField = calendarField;
+ }
+
+ /**
+ * Returns the field in {@link Calendar} that corresponds to this
+ * resolution.
+ *
+ * @return one of the field numbers used by Calendar
+ */
+ public int getCalendarField() {
+ return calendarField;
+ }
+
+ /**
+ * Returns the resolutions that are higher or equal to the given resolution,
+ * starting from the given resolution. In other words passing DAY to this
+ * methods returns DAY,MONTH,YEAR
+ *
+ * @param r
+ * The resolution to start from
+ * @return An iterable for the resolutions higher or equal to r
+ */
+ public static Iterable<Resolution> getResolutionsHigherOrEqualTo(
+ Resolution r) {
+ List<Resolution> resolutions = new ArrayList<Resolution>();
+ Resolution[] values = Resolution.values();
+ for (int i = r.ordinal(); i < values.length; i++) {
+ resolutions.add(values[i]);
+ }
+ return resolutions;
+ }
+
+ /**
+ * Returns the resolutions that are lower than the given resolution,
+ * starting from the given resolution. In other words passing DAY to this
+ * methods returns HOUR,MINUTE,SECOND.
+ *
+ * @param r
+ * The resolution to start from
+ * @return An iterable for the resolutions lower than r
+ */
+ public static List<Resolution> getResolutionsLowerThan(Resolution r) {
+ List<Resolution> resolutions = new ArrayList<Resolution>();
+ Resolution[] values = Resolution.values();
+ for (int i = r.ordinal() - 1; i >= 0; i--) {
+ resolutions.add(values[i]);
+ }
+ return resolutions;
+ }
+};
import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.Sizeable;
+import com.vaadin.shared.MouseEventDetails.MouseButton;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.components.AbstractComponentTest;
import com.vaadin.ui.AbstractComponent;
if (!isAbstract(cls)) {
String url = baseUrl + cls.getName()
+ "?restartApplication";
- if (event.getButton() == ItemClickEvent.BUTTON_LEFT) {
+ if (event.getButton() == MouseButton.LEFT) {
openEmbedded(url);
naviTree.setValue(event.getItemId());
- } else if (event.getButton() == ItemClickEvent.BUTTON_RIGHT) {
+ } else if (event.getButton() == MouseButton.RIGHT) {
openInNewTab(url);
}
}
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.ThemeResource;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractSelect;
import com.vaadin.ui.Button;
select = new ComboBox();
select.setImmediate(true);
- select.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS);
+ select.setFilteringMode(FilteringMode.CONTAINS);
select.setWidth("400px");
prev = new Button("<<-|");
package com.vaadin.tests.components.combobox;
import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.Log;
-import com.vaadin.ui.AbstractSelect.Filtering;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComboBox;
l.addItem(cities[i]);
}
- l.setFilteringMode(Filtering.FILTERINGMODE_OFF);
+ l.setFilteringMode(FilteringMode.OFF);
l.setImmediate(true);
l.setNewItemsAllowed(true);
package com.vaadin.tests.components.combobox;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.ComboBox;
cb.addItem("Item " + i);
}
- cb.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS);
+ cb.setFilteringMode(FilteringMode.CONTAINS);
addComponent(cb);
}
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.ui.AbstractSelect;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI.LegacyWindow;
layout.addComponent(lbl);
cbox1.setCaption("Com Box 1");
- cbox1.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
+ cbox1.setFilteringMode(FilteringMode.CONTAINS);
cbox1.setContainerDataSource(getContainer());
cbox1.setImmediate(true);
cbox1.setNullSelectionAllowed(false);
package com.vaadin.tests.components.combobox;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.ComboBox;
addComponent(cb);
cb = getComboBox("A combobox with filteringMode off", false);
- cb.setFilteringMode(ComboBox.FILTERINGMODE_OFF);
+ cb.setFilteringMode(FilteringMode.OFF);
}
import java.util.LinkedHashMap;
import com.vaadin.server.Resource;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.tests.components.select.AbstractSelectTestCase;
import com.vaadin.ui.ComboBox;
c.setInputPrompt(value);
}
};
- private Command<T, Integer> filteringModeCommand = new Command<T, Integer>() {
+ private Command<T, FilteringMode> filteringModeCommand = new Command<T, FilteringMode>() {
@Override
- public void execute(T c, Integer value, Object data) {
+ public void execute(T c, FilteringMode value, Object data) {
c.setFilteringMode(value);
}
};
}
private void createFilteringModeAction(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Off", ComboBox.FILTERINGMODE_OFF);
- options.put("Contains", ComboBox.FILTERINGMODE_CONTAINS);
- options.put("Starts with", ComboBox.FILTERINGMODE_STARTSWITH);
+ LinkedHashMap<String, FilteringMode> options = new LinkedHashMap<String, FilteringMode>();
+ options.put("Off", FilteringMode.OFF);
+ options.put("Contains", FilteringMode.CONTAINS);
+ options.put("Starts with", FilteringMode.STARTSWITH);
createSelectAction("Filtering mode", category, options, "Contains",
filteringModeCommand);
import java.util.Date;
import java.util.Locale;
+import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.DateField;
-import com.vaadin.ui.DateField.Resolution;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.util.BeanItem;
import com.vaadin.data.validator.RangeValidator;
+import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.DateField.Resolution;
import com.vaadin.ui.PopupDateField;
public class DateFieldRangeValidation extends TestBase {
import java.util.LinkedHashMap;
import java.util.Locale;
+import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
import com.vaadin.ui.DateField;
-import com.vaadin.ui.DateField.Resolution;
public class DateFieldTest<T extends DateField> extends AbstractFieldTest<T> {
private void createResolutionSelectAction(String category) {
LinkedHashMap<String, Resolution> options = new LinkedHashMap<String, Resolution>();
- options.put("Year", DateField.Resolution.YEAR);
- options.put("Month", DateField.Resolution.MONTH);
- options.put("Day", DateField.Resolution.DAY);
- options.put("Hour", DateField.Resolution.HOUR);
- options.put("Min", DateField.Resolution.MINUTE);
- options.put("Sec", DateField.Resolution.SECOND);
+ options.put("Year", Resolution.YEAR);
+ options.put("Month", Resolution.MONTH);
+ options.put("Day", Resolution.DAY);
+ options.put("Hour", Resolution.HOUR);
+ options.put("Min", Resolution.MINUTE);
+ options.put("Sec", Resolution.SECOND);
createSelectAction("Resolution", category, options, "Year",
resolutionCommand);
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.shared.ui.combobox.FilteringMode;
+import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.DateField;
-import com.vaadin.ui.DateField.Resolution;
public class DateFieldTimezone extends TestBase {
timezoneSelector.setImmediate(true);
timezoneSelector.setNullSelectionAllowed(true);
timezoneSelector.setNullSelectionItemId(nullValue);
- timezoneSelector.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS);
+ timezoneSelector.setFilteringMode(FilteringMode.CONTAINS);
timezoneSelector.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
import java.util.List;
import java.util.Locale;
+import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.ComponentTestCase;
import com.vaadin.ui.Component;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.DateField.Resolution;
import com.vaadin.ui.InlineDateField;
@SuppressWarnings("serial")
pd.setWidth(width);
pd.setValue(new Date(12312312313L));
pd.setLocale(locale);
- pd.setResolution(DateField.Resolution.YEAR);
+ pd.setResolution(Resolution.YEAR);
return pd;
}
private Component createResolutionSelectAction() {
LinkedHashMap<String, Resolution> options = new LinkedHashMap<String, Resolution>();
- options.put("Year", DateField.Resolution.YEAR);
- options.put("Month", DateField.Resolution.MONTH);
- options.put("Day", DateField.Resolution.DAY);
- options.put("Hour", DateField.Resolution.HOUR);
- options.put("Min", DateField.Resolution.MINUTE);
- options.put("Sec", DateField.Resolution.SECOND);
+ options.put("Year", Resolution.YEAR);
+ options.put("Month", Resolution.MONTH);
+ options.put("Day", Resolution.DAY);
+ options.put("Hour", Resolution.HOUR);
+ options.put("Min", Resolution.MINUTE);
+ options.put("Sec", Resolution.SECOND);
return createSelectAction("Resolution", options, "Year",
new Command<InlineDateField, Resolution>() {
import java.util.List;
import java.util.Locale;
+import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.ComponentTestCase;
import com.vaadin.ui.Component;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.DateField.Resolution;
import com.vaadin.ui.PopupDateField;
@SuppressWarnings("serial")
pd.setWidth(width);
pd.setValue(new Date(12312312313L));
pd.setLocale(locale);
- pd.setResolution(DateField.Resolution.YEAR);
+ pd.setResolution(Resolution.YEAR);
return pd;
}
private Component createResolutionSelectAction() {
LinkedHashMap<String, Resolution> options = new LinkedHashMap<String, Resolution>();
- options.put("Year", DateField.Resolution.YEAR);
- options.put("Month", DateField.Resolution.MONTH);
- options.put("Day", DateField.Resolution.DAY);
- options.put("Hour", DateField.Resolution.HOUR);
- options.put("Min", DateField.Resolution.MINUTE);
- options.put("Sec", DateField.Resolution.SECOND);
+ options.put("Year", Resolution.YEAR);
+ options.put("Month", Resolution.MONTH);
+ options.put("Day", Resolution.DAY);
+ options.put("Hour", Resolution.HOUR);
+ options.put("Min", Resolution.MINUTE);
+ options.put("Sec", Resolution.SECOND);
return createSelectAction("Resolution", options, "Year",
new Command<PopupDateField, Resolution>() {
package com.vaadin.tests.components.link;
import com.vaadin.server.ExternalResource;
+import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Link;
l.setTargetName("_blank");
l.setTargetWidth(300);
l.setTargetHeight(300);
- l.setTargetBorder(Link.TARGET_BORDER_NONE);
+ l.setTargetBorder(BorderStyle.NONE);
addComponent(l);
}
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.Log;
-import com.vaadin.ui.AbstractSelect.MultiSelectMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Table;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.server.Resource;
+import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.components.select.AbstractSelectTestCase;
-import com.vaadin.ui.AbstractSelect.MultiSelectMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
public void itemClick(ItemClickEvent event) {
clickCounter++;
switch (event.getButton()) {
- case ItemClickEvent.BUTTON_LEFT:
+ case LEFT:
log.log("Left Click");
break;
- case ItemClickEvent.BUTTON_RIGHT:
+ case RIGHT:
log.log("Right Click");
break;
- case ItemClickEvent.BUTTON_MIDDLE:
+ case MIDDLE:
log.log("Middle Click");
break;
}
import com.vaadin.data.util.HierarchicalContainer;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
+import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.tests.components.select.AbstractSelectTestCase;
-import com.vaadin.ui.AbstractSelect.MultiSelectMode;
import com.vaadin.ui.Tree;
import com.vaadin.ui.Tree.CollapseEvent;
import com.vaadin.ui.Tree.CollapseListener;
package com.vaadin.tests.containers.sqlcontainer;
import com.vaadin.LegacyApplication;
-import com.vaadin.ui.AbstractSelect.Filtering;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.UI;
ComboBox combo = new ComboBox("Names",
databaseHelper.getTestContainer());
combo.setItemCaptionPropertyId("FIELD1");
- combo.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS);
+ combo.setFilteringMode(FilteringMode.CONTAINS);
combo.setImmediate(true);
getMainWindow().addComponent(combo);
import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener;
-import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.AbsoluteLayout;
target = ((Label) component).getValue().toString();
}
}
- String button = "left";
- if (event.getButton() == ClickEvent.BUTTON_RIGHT) {
- button = "right";
- } else if (event.getButton() == ClickEvent.BUTTON_MIDDLE) {
- button = "middle";
-
- }
+ String button = event.getButtonName();
String type = "click";
if (event.isDoubleClick()) {
type = "double-click";
import com.vaadin.data.Container;
import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Panel;
private Component initSelect(Container containerDataSource, String caption,
ObjectProperty<?> property) {
Select select = new Select(caption);
- select.setFilteringMode(Select.FILTERINGMODE_CONTAINS);
+ select.setFilteringMode(FilteringMode.CONTAINS);
select.setImmediate(true);
select.setNullSelectionAllowed(false);
select.setItemCaptionPropertyId(Ticket1506_TestContainer.PROPERTY_2_ID);
public void itemClick(ItemClickEvent event) {
events.addComponent(new Label(new Label("Click:"
+ (event.isDoubleClick() ? "double" : "single")
- + " button:" + event.getButton() + " propertyId:"
+ + " button:" + event.getButtonName() + " propertyId:"
+ event.getPropertyId() + " itemID:"
+ event.getItemId() + " item:" + event.getItem())));
public void itemClick(ItemClickEvent event) {
events2.addComponent(new Label("Click:"
+ (event.isDoubleClick() ? "double" : "single")
- + " button:" + event.getButton() + " propertyId:"
+ + " button:" + event.getButtonName() + " propertyId:"
+ event.getPropertyId() + " itemID:"
+ event.getItemId() + " item:" + event.getItem()));
if (event.isDoubleClick()) {
import com.vaadin.LegacyApplication;
import com.vaadin.server.ExternalResource;
+import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Link;
import com.vaadin.ui.UI.LegacyWindow;
private void createUI(GridLayout layout) {
Link l = new Link("Vaadin home (new 200x200 window, no decor, icon)",
new ExternalResource("http://www.vaadin.com"), "_blank", 200,
- 200, Link.TARGET_BORDER_NONE);
+ 200, BorderStyle.NONE);
layout.addComponent(l);
}