aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/ui
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-12-08 16:26:32 +0200
committerLeif Åstrand <leif@vaadin.com>2011-12-08 16:26:32 +0200
commitd4be34e7bf6a17db29acba8c12652b3117983554 (patch)
tree764af2f47259a1d67c7732afa1c5d87015ca209b /src/com/vaadin/ui
parent8aae0e9bb57bc737a5f7fcc6cf08fdde3aee2de5 (diff)
parent8f95be653356e45692680d595bd96b77df3f949f (diff)
downloadvaadin-framework-d4be34e7bf6a17db29acba8c12652b3117983554.tar.gz
vaadin-framework-d4be34e7bf6a17db29acba8c12652b3117983554.zip
Merge remote branch 'origin/master' into windowing
Diffstat (limited to 'src/com/vaadin/ui')
-rw-r--r--src/com/vaadin/ui/AbstractComponent.java40
-rw-r--r--src/com/vaadin/ui/Form.java30
-rw-r--r--src/com/vaadin/ui/Table.java46
3 files changed, 62 insertions, 54 deletions
diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java
index e91511ae39..8c1d6db524 100644
--- a/src/com/vaadin/ui/AbstractComponent.java
+++ b/src/com/vaadin/ui/AbstractComponent.java
@@ -1322,26 +1322,6 @@ public abstract class AbstractComponent implements Component, MethodEventSource
/*
* (non-Javadoc)
*
- * @see com.vaadin.terminal.Sizeable#setHeight(float)
- */
- @Deprecated
- public void setHeight(float height) {
- setHeight(height, getHeightUnits());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.terminal.Sizeable#setHeightUnits(int)
- */
- @Deprecated
- public void setHeightUnits(int unit) {
- setHeight(getHeight(), unit);
- }
-
- /*
- * (non-Javadoc)
- *
* @see com.vaadin.terminal.Sizeable#setHeight(float, int)
*/
public void setHeight(float height, int unit) {
@@ -1374,26 +1354,6 @@ public abstract class AbstractComponent implements Component, MethodEventSource
/*
* (non-Javadoc)
*
- * @see com.vaadin.terminal.Sizeable#setWidth(float)
- */
- @Deprecated
- public void setWidth(float width) {
- setWidth(width, getWidthUnits());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.terminal.Sizeable#setWidthUnits(int)
- */
- @Deprecated
- public void setWidthUnits(int unit) {
- setWidth(getWidth(), unit);
- }
-
- /*
- * (non-Javadoc)
- *
* @see com.vaadin.terminal.Sizeable#setWidth(float, int)
*/
public void setWidth(float width, int unit) {
diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java
index 8ee702bbb4..1a28c679f9 100644
--- a/src/com/vaadin/ui/Form.java
+++ b/src/com/vaadin/ui/Form.java
@@ -491,7 +491,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item,
}
// Configures the field
- field.setPropertyDataSource(property);
+ bindPropertyToField(id, property, field);
// Register and attach the created field
addField(id, field);
@@ -755,7 +755,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item,
final Field f = fieldFactory.createField(itemDatasource, id,
this);
if (f != null) {
- f.setPropertyDataSource(property);
+ bindPropertyToField(id, property, f);
addField(id, f);
}
}
@@ -763,6 +763,32 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item,
}
/**
+ * Binds an item property to a field. The default behavior is to bind
+ * property straight to Field. If Property.Viewer type property (e.g.
+ * PropertyFormatter) is already set for field, the property is bound to
+ * that Property.Viewer.
+ *
+ * @param propertyId
+ * @param property
+ * @param field
+ * @since 6.7.3
+ */
+ protected void bindPropertyToField(final Object propertyId,
+ final Property property, final Field field) {
+ // check if field has a property that is Viewer set. In that case we
+ // expect developer has e.g. PropertyFormatter that he wishes to use and
+ // assign the property to the Viewer instead.
+ boolean hasFilterProperty = field.getPropertyDataSource() != null
+ && (field.getPropertyDataSource() instanceof Property.Viewer);
+ if (hasFilterProperty) {
+ ((Property.Viewer) field.getPropertyDataSource())
+ .setPropertyDataSource(property);
+ } else {
+ field.setPropertyDataSource(property);
+ }
+ }
+
+ /**
* Gets the layout of the form.
*
* <p>
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 5efb2545e0..b95d738157 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -3405,7 +3405,7 @@ public class Table extends AbstractSelect implements Action.Container,
// Remember that we have made this association so we can remove
// it when the component is removed
associatedProperties.put(f, property);
- f.setPropertyDataSource(property);
+ bindPropertyToField(rowId, colId, property, f);
return f;
}
}
@@ -3414,6 +3414,33 @@ public class Table extends AbstractSelect implements Action.Container,
}
/**
+ * Binds an item property to a field generated by TableFieldFactory. The
+ * default behavior is to bind property straight to Field. If
+ * Property.Viewer type property (e.g. PropertyFormatter) is already set for
+ * field, the property is bound to that Property.Viewer.
+ *
+ * @param rowId
+ * @param colId
+ * @param property
+ * @param field
+ * @since 6.7.3
+ */
+ protected void bindPropertyToField(Object rowId, Object colId,
+ Property property, Field field) {
+ // check if field has a property that is Viewer set. In that case we
+ // expect developer has e.g. PropertyFormatter that he wishes to use and
+ // assign the property to the Viewer instead.
+ boolean hasFilterProperty = field.getPropertyDataSource() != null
+ && (field.getPropertyDataSource() instanceof Property.Viewer);
+ if (hasFilterProperty) {
+ ((Property.Viewer) field.getPropertyDataSource())
+ .setPropertyDataSource(property);
+ } else {
+ field.setPropertyDataSource(property);
+ }
+ }
+
+ /**
* Formats table cell property values. By default the property.toString()
* and return a empty string for null properties.
*
@@ -3775,8 +3802,8 @@ public class Table extends AbstractSelect implements Action.Container,
* <p>
* Note, that some due to historical reasons the name of the method is bit
* misleading. Some items may be partly or totally out of the viewport of
- * the table's scrollable area. Actully detecting rows which can be actually
- * seen by the end user may be problematic due to the client server
+ * the table's scrollable area. Actually detecting rows which can be
+ * actually seen by the end user may be problematic due to the client server
* architecture. Using {@link #getCurrentPageFirstItemId()} combined with
* {@link #getPageLength()} may produce good enough estimates in some
* situations.
@@ -4507,19 +4534,14 @@ public class Table extends AbstractSelect implements Action.Container,
* com.vaadin.event.dd.acceptcriteria.AcceptCriterion#accepts(com.vaadin
* .event.dd.DragAndDropEvent)
*/
+ @SuppressWarnings("unchecked")
public boolean accept(DragAndDropEvent dragEvent) {
AbstractSelectTargetDetails dropTargetData = (AbstractSelectTargetDetails) dragEvent
.getTargetDetails();
table = (Table) dragEvent.getTargetDetails().getTarget();
- ArrayList<Object> visibleItemIds = new ArrayList<Object>(
- table.getPageLength());
- visibleItemIds.size();
- Object id = table.getCurrentPageFirstItemId();
- for (int i = 0; i < table.getPageLength() && id != null; i++) {
- visibleItemIds.add(id);
- id = table.nextItemId(id);
- }
- allowedItemIds = getAllowedItemIds(dragEvent, table, visibleItemIds);
+ Collection<?> visibleItemIds = table.getVisibleItemIds();
+ allowedItemIds = getAllowedItemIds(dragEvent, table,
+ (Collection<Object>) visibleItemIds);
return allowedItemIds.contains(dropTargetData.getItemIdOver());
}