summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2012-09-10 22:12:47 +0300
committerArtur Signell <artur@vaadin.com>2012-09-11 12:19:02 +0300
commit0f5284bb827b5f04c6c064c851b851604293665a (patch)
tree4c9949ba7fa08dfae4f276f95c6928cae8b7760f /server/src/com/vaadin
parent8a904080835193e322e1f006aa65f490f2cd930a (diff)
downloadvaadin-framework-0f5284bb827b5f04c6c064c851b851604293665a.tar.gz
vaadin-framework-0f5284bb827b5f04c6c064c851b851604293665a.zip
Constants -> enums (#9072)
Patch from Pekka with minor changes (ButtonCode -> MouseButton, FilteringMode -> ComboBox)
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/data/validator/DateRangeValidator.java2
-rw-r--r--server/src/com/vaadin/event/MouseEvents.java30
-rw-r--r--server/src/com/vaadin/server/Page.java10
-rw-r--r--server/src/com/vaadin/ui/AbstractSelect.java45
-rw-r--r--server/src/com/vaadin/ui/ComboBox.java26
-rw-r--r--server/src/com/vaadin/ui/DateField.java72
-rw-r--r--server/src/com/vaadin/ui/Link.java12
-rw-r--r--server/src/com/vaadin/ui/Table.java1
-rw-r--r--server/src/com/vaadin/ui/Tree.java3
9 files changed, 78 insertions, 123 deletions
diff --git a/server/src/com/vaadin/data/validator/DateRangeValidator.java b/server/src/com/vaadin/data/validator/DateRangeValidator.java
index 44c0d1e929..51eaa2e59b 100644
--- a/server/src/com/vaadin/data/validator/DateRangeValidator.java
+++ b/server/src/com/vaadin/data/validator/DateRangeValidator.java
@@ -17,7 +17,7 @@ package com.vaadin.data.validator;
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.
diff --git a/server/src/com/vaadin/event/MouseEvents.java b/server/src/com/vaadin/event/MouseEvents.java
index e287055c2b..37c6d665b5 100644
--- a/server/src/com/vaadin/event/MouseEvents.java
+++ b/server/src/com/vaadin/event/MouseEvents.java
@@ -19,6 +19,7 @@ package com.vaadin.event;
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;
@@ -44,10 +45,21 @@ public interface MouseEvents {
* @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) {
@@ -57,13 +69,13 @@ public interface MouseEvents {
/**
* 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();
}
diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java
index ccc400341e..bfbfe53429 100644
--- a/server/src/com/vaadin/server/Page.java
+++ b/server/src/com/vaadin/server/Page.java
@@ -211,21 +211,21 @@ public class Page implements Serializable {
"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;
/**
diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java
index 4de3f90d15..45df42a9be 100644
--- a/server/src/com/vaadin/ui/AbstractSelect.java
+++ b/server/src/com/vaadin/ui/AbstractSelect.java
@@ -45,6 +45,7 @@ import com.vaadin.server.LegacyComponent;
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;
/**
@@ -154,15 +155,28 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
/**
* 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.
@@ -170,30 +184,15 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
* @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
}
/**
diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java
index 4f852c2b7b..4987d69fdd 100644
--- a/server/src/com/vaadin/ui/ComboBox.java
+++ b/server/src/com/vaadin/ui/ComboBox.java
@@ -34,6 +34,7 @@ import com.vaadin.server.PaintException;
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
@@ -60,7 +61,7 @@ public class ComboBox extends AbstractSelect implements
// 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;
@@ -186,7 +187,7 @@ public class ComboBox extends AbstractSelect implements
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;
@@ -201,7 +202,7 @@ public class ComboBox extends AbstractSelect implements
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;
@@ -411,18 +412,19 @@ public class ComboBox extends AbstractSelect implements
* @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;
@@ -576,7 +578,7 @@ public class ComboBox extends AbstractSelect implements
*/
protected List<?> getFilteredOptions() {
if (null == filterstring || "".equals(filterstring)
- || Filtering.FILTERINGMODE_OFF == filteringMode) {
+ || FilteringMode.OFF == filteringMode) {
prevfilterstring = null;
filteredOptions = new LinkedList<Object>(getItemIds());
return filteredOptions;
@@ -605,12 +607,12 @@ public class ComboBox extends AbstractSelect implements
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);
@@ -686,12 +688,12 @@ public class ComboBox extends AbstractSelect implements
}
@Override
- public void setFilteringMode(int filteringMode) {
+ public void setFilteringMode(FilteringMode filteringMode) {
this.filteringMode = filteringMode;
}
@Override
- public int getFilteringMode() {
+ public FilteringMode getFilteringMode() {
return filteringMode;
}
diff --git a/server/src/com/vaadin/ui/DateField.java b/server/src/com/vaadin/ui/DateField.java
index f54959fb0a..39230bf662 100644
--- a/server/src/com/vaadin/ui/DateField.java
+++ b/server/src/com/vaadin/ui/DateField.java
@@ -17,12 +17,10 @@
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;
@@ -40,6 +38,7 @@ import com.vaadin.server.LegacyComponent;
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>
@@ -64,71 +63,6 @@ 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.
*
* @deprecated As of 7.0, use {@link Resolution#SECOND}
@@ -212,7 +146,7 @@ public class DateField extends AbstractField<Date> implements
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");
@@ -372,7 +306,7 @@ public class DateField extends AbstractField<Date> implements
// 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)) {
diff --git a/server/src/com/vaadin/ui/Link.java b/server/src/com/vaadin/ui/Link.java
index a2737e4483..6e286174a5 100644
--- a/server/src/com/vaadin/ui/Link.java
+++ b/server/src/com/vaadin/ui/Link.java
@@ -34,15 +34,21 @@ import com.vaadin.shared.ui.link.LinkConstants;
@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;
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 87962d5d15..d9e1403a03 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -59,6 +59,7 @@ import com.vaadin.server.PaintException;
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;
/**
diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java
index 44a1208cf8..1ba011dd00 100644
--- a/server/src/com/vaadin/ui/Tree.java
+++ b/server/src/com/vaadin/ui/Tree.java
@@ -54,6 +54,7 @@ import com.vaadin.server.PaintException;
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;
@@ -519,7 +520,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
: "single"));
if (isMultiSelect()) {
target.addAttribute("multiselectmode",
- multiSelectMode.ordinal());
+ multiSelectMode.toString());
}
} else {
target.addAttribute("selectmode", "none");