* @return <code>true</code> if the operation succeeded, | * @return <code>true</code> if the operation succeeded, | ||||
* <code>false</code> if not | * <code>false</code> if not | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItem(Object itemId) | public boolean removeItem(Object itemId) | ||||
throws UnsupportedOperationException; | throws UnsupportedOperationException; | ||||
} | } |
public static final Object CAPTION_PROPERTY_ID = "Caption"; | public static final Object CAPTION_PROPERTY_ID = "Caption"; | ||||
@Override | |||||
public <T extends Field> T createField(Class<?> type, Class<T> fieldType) { | public <T extends Field> T createField(Class<?> type, Class<T> fieldType) { | ||||
if (Enum.class.isAssignableFrom(type)) { | if (Enum.class.isAssignableFrom(type)) { | ||||
return createEnumField(type, fieldType); | return createEnumField(type, fieldType); |
this.propertyId = propertyId; | this.propertyId = propertyId; | ||||
} | } | ||||
@Override | |||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
public IDTYPE getIdForBean(BEANTYPE bean) | public IDTYPE getIdForBean(BEANTYPE bean) | ||||
throws IllegalArgumentException { | throws IllegalArgumentException { | ||||
* | * | ||||
* @see com.vaadin.data.Container#getType(java.lang.Object) | * @see com.vaadin.data.Container#getType(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Class<?> getType(Object propertyId) { | public Class<?> getType(Object propertyId) { | ||||
return model.get(propertyId).getPropertyType(); | return model.get(propertyId).getPropertyType(); | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.Container#getContainerPropertyIds() | * @see com.vaadin.data.Container#getContainerPropertyIds() | ||||
*/ | */ | ||||
@Override | |||||
public Collection<String> getContainerPropertyIds() { | public Collection<String> getContainerPropertyIds() { | ||||
return model.keySet(); | return model.keySet(); | ||||
} | } | ||||
* @see com.vaadin.data.Container#getContainerProperty(java.lang.Object, | * @see com.vaadin.data.Container#getContainerProperty(java.lang.Object, | ||||
* java.lang.Object) | * java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | public Property<?> getContainerProperty(Object itemId, Object propertyId) { | ||||
Item item = getItem(itemId); | Item item = getItem(itemId); | ||||
if (item == null) { | if (item == null) { | ||||
/** | /** | ||||
* Re-filter the container when one of the monitored properties changes. | * Re-filter the container when one of the monitored properties changes. | ||||
*/ | */ | ||||
@Override | |||||
public void valueChange(ValueChangeEvent event) { | public void valueChange(ValueChangeEvent event) { | ||||
// if a property that is used in a filter is changed, refresh filtering | // if a property that is used in a filter is changed, refresh filtering | ||||
filterAll(); | filterAll(); | ||||
* com.vaadin.data.Container.Filterable#addContainerFilter(java.lang.Object, | * com.vaadin.data.Container.Filterable#addContainerFilter(java.lang.Object, | ||||
* java.lang.String, boolean, boolean) | * java.lang.String, boolean, boolean) | ||||
*/ | */ | ||||
@Override | |||||
public void addContainerFilter(Object propertyId, String filterString, | public void addContainerFilter(Object propertyId, String filterString, | ||||
boolean ignoreCase, boolean onlyMatchPrefix) { | boolean ignoreCase, boolean onlyMatchPrefix) { | ||||
try { | try { | ||||
* | * | ||||
* @see com.vaadin.data.Container.Filterable#removeAllContainerFilters() | * @see com.vaadin.data.Container.Filterable#removeAllContainerFilters() | ||||
*/ | */ | ||||
@Override | |||||
public void removeAllContainerFilters() { | public void removeAllContainerFilters() { | ||||
if (!getFilters().isEmpty()) { | if (!getFilters().isEmpty()) { | ||||
for (Item item : itemIdToItem.values()) { | for (Item item : itemIdToItem.values()) { | ||||
* com.vaadin.data.Container.Filterable#removeContainerFilters(java.lang | * com.vaadin.data.Container.Filterable#removeContainerFilters(java.lang | ||||
* .Object) | * .Object) | ||||
*/ | */ | ||||
@Override | |||||
public void removeContainerFilters(Object propertyId) { | public void removeContainerFilters(Object propertyId) { | ||||
Collection<Filter> removedFilters = super.removeFilters(propertyId); | Collection<Filter> removedFilters = super.removeFilters(propertyId); | ||||
if (!removedFilters.isEmpty()) { | if (!removedFilters.isEmpty()) { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void addContainerFilter(Filter filter) | public void addContainerFilter(Filter filter) | ||||
throws UnsupportedFilterException { | throws UnsupportedFilterException { | ||||
addFilter(filter); | addFilter(filter); | ||||
} | } | ||||
@Override | |||||
public void removeContainerFilter(Filter filter) { | public void removeContainerFilter(Filter filter) { | ||||
removeFilter(filter); | removeFilter(filter); | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds() | * @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds() | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getSortableContainerPropertyIds() { | public Collection<?> getSortableContainerPropertyIds() { | ||||
return getSortablePropertyIds(); | return getSortablePropertyIds(); | ||||
} | } | ||||
* @see com.vaadin.data.Container.Sortable#sort(java.lang.Object[], | * @see com.vaadin.data.Container.Sortable#sort(java.lang.Object[], | ||||
* boolean[]) | * boolean[]) | ||||
*/ | */ | ||||
@Override | |||||
public void sort(Object[] propertyId, boolean[] ascending) { | public void sort(Object[] propertyId, boolean[] ascending) { | ||||
sortContainer(propertyId, ascending); | sortContainer(propertyId, ascending); | ||||
} | } |
super(source); | super(source); | ||||
} | } | ||||
@Override | |||||
public Container getContainer() { | public Container getContainer() { | ||||
return (Container) getSource(); | return (Container) getSource(); | ||||
} | } | ||||
super(source); | super(source); | ||||
} | } | ||||
@Override | |||||
public Container getContainer() { | public Container getContainer() { | ||||
return (Container) getSource(); | return (Container) getSource(); | ||||
} | } |
// Container interface methods with more specific return class | // Container interface methods with more specific return class | ||||
// default implementation, can be overridden | // default implementation, can be overridden | ||||
@Override | |||||
public ITEMCLASS getItem(Object itemId) { | public ITEMCLASS getItem(Object itemId) { | ||||
if (containsId(itemId)) { | if (containsId(itemId)) { | ||||
return getUnfilteredItem(itemId); | return getUnfilteredItem(itemId); | ||||
// Container interface method implementations | // Container interface method implementations | ||||
@Override | |||||
public int size() { | public int size() { | ||||
return getVisibleItemIds().size(); | return getVisibleItemIds().size(); | ||||
} | } | ||||
@Override | |||||
public boolean containsId(Object itemId) { | public boolean containsId(Object itemId) { | ||||
// only look at visible items after filtering | // only look at visible items after filtering | ||||
if (itemId == null) { | if (itemId == null) { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public List<?> getItemIds() { | public List<?> getItemIds() { | ||||
return Collections.unmodifiableList(getVisibleItemIds()); | return Collections.unmodifiableList(getVisibleItemIds()); | ||||
} | } | ||||
// Container.Ordered | // Container.Ordered | ||||
@Override | |||||
public ITEMIDTYPE nextItemId(Object itemId) { | public ITEMIDTYPE nextItemId(Object itemId) { | ||||
int index = indexOfId(itemId); | int index = indexOfId(itemId); | ||||
if (index >= 0 && index < size() - 1) { | if (index >= 0 && index < size() - 1) { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public ITEMIDTYPE prevItemId(Object itemId) { | public ITEMIDTYPE prevItemId(Object itemId) { | ||||
int index = indexOfId(itemId); | int index = indexOfId(itemId); | ||||
if (index > 0) { | if (index > 0) { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public ITEMIDTYPE firstItemId() { | public ITEMIDTYPE firstItemId() { | ||||
if (size() > 0) { | if (size() > 0) { | ||||
return getIdByIndex(0); | return getIdByIndex(0); | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public ITEMIDTYPE lastItemId() { | public ITEMIDTYPE lastItemId() { | ||||
if (size() > 0) { | if (size() > 0) { | ||||
return getIdByIndex(size() - 1); | return getIdByIndex(size() - 1); | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public boolean isFirstId(Object itemId) { | public boolean isFirstId(Object itemId) { | ||||
if (itemId == null) { | if (itemId == null) { | ||||
return false; | return false; | ||||
return itemId.equals(firstItemId()); | return itemId.equals(firstItemId()); | ||||
} | } | ||||
@Override | |||||
public boolean isLastId(Object itemId) { | public boolean isLastId(Object itemId) { | ||||
if (itemId == null) { | if (itemId == null) { | ||||
return false; | return false; | ||||
// Container.Indexed | // Container.Indexed | ||||
@Override | |||||
public ITEMIDTYPE getIdByIndex(int index) { | public ITEMIDTYPE getIdByIndex(int index) { | ||||
return getVisibleItemIds().get(index); | return getVisibleItemIds().get(index); | ||||
} | } | ||||
@Override | |||||
public int indexOfId(Object itemId) { | public int indexOfId(Object itemId) { | ||||
return getVisibleItemIds().indexOf(itemId); | return getVisibleItemIds().indexOf(itemId); | ||||
} | } | ||||
// methods that are unsupported by default, override to support | // methods that are unsupported by default, override to support | ||||
@Override | |||||
public Object addItemAt(int index) throws UnsupportedOperationException { | public Object addItemAt(int index) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | "Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | ||||
} | } | ||||
@Override | |||||
public Item addItemAt(int index, Object newItemId) | public Item addItemAt(int index, Object newItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | "Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | ||||
} | } | ||||
@Override | |||||
public Object addItemAfter(Object previousItemId) | public Object addItemAfter(Object previousItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | "Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | ||||
} | } | ||||
@Override | |||||
public Item addItemAfter(Object previousItemId, Object newItemId) | public Item addItemAfter(Object previousItemId, Object newItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | "Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | ||||
} | } | ||||
@Override | |||||
public Item addItem(Object itemId) throws UnsupportedOperationException { | public Item addItem(Object itemId) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | "Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | ||||
} | } | ||||
@Override | |||||
public Object addItem() throws UnsupportedOperationException { | public Object addItem() throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | "Adding items not supported. Override the relevant addItem*() methods if required as specified in AbstractInMemoryContainer javadoc."); | ||||
} | } | ||||
@Override | |||||
public boolean removeItem(Object itemId) | public boolean removeItem(Object itemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Removing items not supported. Override the removeItem() method if required as specified in AbstractInMemoryContainer javadoc."); | "Removing items not supported. Override the removeItem() method if required as specified in AbstractInMemoryContainer javadoc."); | ||||
} | } | ||||
@Override | |||||
public boolean removeAllItems() throws UnsupportedOperationException { | public boolean removeAllItems() throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Removing items not supported. Override the removeAllItems() method if required as specified in AbstractInMemoryContainer javadoc."); | "Removing items not supported. Override the removeAllItems() method if required as specified in AbstractInMemoryContainer javadoc."); | ||||
} | } | ||||
@Override | |||||
public boolean addContainerProperty(Object propertyId, Class<?> type, | public boolean addContainerProperty(Object propertyId, Class<?> type, | ||||
Object defaultValue) throws UnsupportedOperationException { | Object defaultValue) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"Adding container properties not supported. Override the addContainerProperty() method if required."); | "Adding container properties not supported. Override the addContainerProperty() method if required."); | ||||
} | } | ||||
@Override | |||||
public boolean removeContainerProperty(Object propertyId) | public boolean removeContainerProperty(Object propertyId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( |
* Override for additional restrictions on what is considered a read-only | * Override for additional restrictions on what is considered a read-only | ||||
* property. | * property. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isReadOnly() { | public boolean isReadOnly() { | ||||
return readOnly; | return readOnly; | ||||
} | } | ||||
@Override | |||||
public void setReadOnly(boolean newStatus) { | public void setReadOnly(boolean newStatus) { | ||||
boolean oldStatus = isReadOnly(); | boolean oldStatus = isReadOnly(); | ||||
readOnly = newStatus; | readOnly = newStatus; | ||||
* | * | ||||
* @return source Property of the event. | * @return source Property of the event. | ||||
*/ | */ | ||||
@Override | |||||
public Property getProperty() { | public Property getProperty() { | ||||
return (Property) getSource(); | return (Property) getSource(); | ||||
} | } | ||||
* @param listener | * @param listener | ||||
* the new Listener to be registered. | * the new Listener to be registered. | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Property.ReadOnlyStatusChangeListener listener) { | public void addListener(Property.ReadOnlyStatusChangeListener listener) { | ||||
if (readOnlyStatusChangeListeners == null) { | if (readOnlyStatusChangeListeners == null) { | ||||
readOnlyStatusChangeListeners = new LinkedList<ReadOnlyStatusChangeListener>(); | readOnlyStatusChangeListeners = new LinkedList<ReadOnlyStatusChangeListener>(); | ||||
* @param listener | * @param listener | ||||
* the listener to be removed. | * the listener to be removed. | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Property.ReadOnlyStatusChangeListener listener) { | public void removeListener(Property.ReadOnlyStatusChangeListener listener) { | ||||
if (readOnlyStatusChangeListeners != null) { | if (readOnlyStatusChangeListeners != null) { | ||||
readOnlyStatusChangeListeners.remove(listener); | readOnlyStatusChangeListeners.remove(listener); | ||||
* | * | ||||
* @return source Property of the event. | * @return source Property of the event. | ||||
*/ | */ | ||||
@Override | |||||
public Property getProperty() { | public Property getProperty() { | ||||
return (Property) getSource(); | return (Property) getSource(); | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void addListener(ValueChangeListener listener) { | public void addListener(ValueChangeListener listener) { | ||||
if (valueChangeListeners == null) { | if (valueChangeListeners == null) { | ||||
valueChangeListeners = new LinkedList<ValueChangeListener>(); | valueChangeListeners = new LinkedList<ValueChangeListener>(); | ||||
} | } | ||||
@Override | |||||
public void removeListener(ValueChangeListener listener) { | public void removeListener(ValueChangeListener listener) { | ||||
if (valueChangeListeners != null) { | if (valueChangeListeners != null) { | ||||
valueChangeListeners.remove(listener); | valueChangeListeners.remove(listener); |
private static class IdentityBeanIdResolver<BT> implements | private static class IdentityBeanIdResolver<BT> implements | ||||
BeanIdResolver<BT, BT> { | BeanIdResolver<BT, BT> { | ||||
@Override | |||||
public BT getIdForBean(BT bean) { | public BT getIdForBean(BT bean) { | ||||
return bean; | return bean; | ||||
} | } |
this.itemIds = itemIds; | this.itemIds = itemIds; | ||||
} | } | ||||
@Override | |||||
public int compare(Object o1, Object o2) { | public int compare(Object o1, Object o2) { | ||||
if (o1.equals(o2)) { | if (o1.equals(o2)) { | ||||
return 0; | return 0; | ||||
* Can the specified Item have any children? Don't add a JavaDoc comment | * Can the specified Item have any children? Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean areChildrenAllowed(Object itemId) { | public boolean areChildrenAllowed(Object itemId) { | ||||
// If the wrapped container implements the method directly, use it | // If the wrapped container implements the method directly, use it | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getChildren(Object itemId) { | public Collection<?> getChildren(Object itemId) { | ||||
// If the wrapped container implements the method directly, use it | // If the wrapped container implements the method directly, use it | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Object getParent(Object itemId) { | public Object getParent(Object itemId) { | ||||
// If the wrapped container implements the method directly, use it | // If the wrapped container implements the method directly, use it | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean hasChildren(Object itemId) { | public boolean hasChildren(Object itemId) { | ||||
// If the wrapped container implements the method directly, use it | // If the wrapped container implements the method directly, use it | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isRoot(Object itemId) { | public boolean isRoot(Object itemId) { | ||||
// If the wrapped container implements the method directly, use it | // If the wrapped container implements the method directly, use it | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> rootItemIds() { | public Collection<?> rootItemIds() { | ||||
// If the wrapped container implements the method directly, use it | // If the wrapped container implements the method directly, use it | ||||
* @return <code>true</code> if the operation succeeded, <code>false</code> | * @return <code>true</code> if the operation succeeded, <code>false</code> | ||||
* if not | * if not | ||||
*/ | */ | ||||
@Override | |||||
public boolean setChildrenAllowed(Object itemId, boolean childrenAllowed) { | public boolean setChildrenAllowed(Object itemId, boolean childrenAllowed) { | ||||
// If the wrapped container implements the method directly, use it | // If the wrapped container implements the method directly, use it | ||||
* @return <code>true</code> if the operation succeeded, <code>false</code> | * @return <code>true</code> if the operation succeeded, <code>false</code> | ||||
* if not | * if not | ||||
*/ | */ | ||||
@Override | |||||
public boolean setParent(Object itemId, Object newParentId) { | public boolean setParent(Object itemId, Object newParentId) { | ||||
// If the wrapped container implements the method directly, use it | // If the wrapped container implements the method directly, use it | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItem is not supported. | * if the addItem is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Object addItem() throws UnsupportedOperationException { | public Object addItem() throws UnsupportedOperationException { | ||||
final Object id = container.addItem(); | final Object id = container.addItem(); | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItem is not supported. | * if the addItem is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Item addItem(Object itemId) throws UnsupportedOperationException { | public Item addItem(Object itemId) throws UnsupportedOperationException { | ||||
// Null ids are not accepted | // Null ids are not accepted | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeAllItems is not supported. | * if the removeAllItems is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeAllItems() throws UnsupportedOperationException { | public boolean removeAllItems() throws UnsupportedOperationException { | ||||
final boolean success = container.removeAllItems(); | final boolean success = container.removeAllItems(); | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeItem is not supported. | * if the removeItem is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItem(Object itemId) | public boolean removeItem(Object itemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addContainerProperty is not supported. | * if the addContainerProperty is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean addContainerProperty(Object propertyId, Class<?> type, | public boolean addContainerProperty(Object propertyId, Class<?> type, | ||||
Object defaultValue) throws UnsupportedOperationException { | Object defaultValue) throws UnsupportedOperationException { | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeContainerProperty is not supported. | * if the removeContainerProperty is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeContainerProperty(Object propertyId) | public boolean removeContainerProperty(Object propertyId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
return container.removeContainerProperty(propertyId); | return container.removeContainerProperty(propertyId); | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean containsId(Object itemId) { | public boolean containsId(Object itemId) { | ||||
return container.containsId(itemId); | return container.containsId(itemId); | ||||
} | } | ||||
* Gets the specified Item from the container. Don't add a JavaDoc comment | * Gets the specified Item from the container. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Item getItem(Object itemId) { | public Item getItem(Object itemId) { | ||||
return container.getItem(itemId); | return container.getItem(itemId); | ||||
} | } | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getItemIds() { | public Collection<?> getItemIds() { | ||||
return container.getItemIds(); | return container.getItemIds(); | ||||
} | } | ||||
* Container Don't add a JavaDoc comment here, we use the default | * Container Don't add a JavaDoc comment here, we use the default | ||||
* documentation from implemented interface. | * documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | public Property<?> getContainerProperty(Object itemId, Object propertyId) { | ||||
return container.getContainerProperty(itemId, propertyId); | return container.getContainerProperty(itemId, propertyId); | ||||
} | } | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getContainerPropertyIds() { | public Collection<?> getContainerPropertyIds() { | ||||
return container.getContainerPropertyIds(); | return container.getContainerPropertyIds(); | ||||
} | } | ||||
* Don't add a JavaDoc comment here, we use the default documentation from | * Don't add a JavaDoc comment here, we use the default documentation from | ||||
* implemented interface. | * implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Class<?> getType(Object propertyId) { | public Class<?> getType(Object propertyId) { | ||||
return container.getType(propertyId); | return container.getType(propertyId); | ||||
} | } | ||||
* Gets the number of Items in the Container. Don't add a JavaDoc comment | * Gets the number of Items in the Container. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public int size() { | public int size() { | ||||
return container.size(); | return container.size(); | ||||
} | } | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Container.ItemSetChangeListener listener) { | public void addListener(Container.ItemSetChangeListener listener) { | ||||
if (container instanceof Container.ItemSetChangeNotifier) { | if (container instanceof Container.ItemSetChangeNotifier) { | ||||
((Container.ItemSetChangeNotifier) container) | ((Container.ItemSetChangeNotifier) container) | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Container.ItemSetChangeListener listener) { | public void removeListener(Container.ItemSetChangeListener listener) { | ||||
if (container instanceof Container.ItemSetChangeNotifier) { | if (container instanceof Container.ItemSetChangeNotifier) { | ||||
((Container.ItemSetChangeNotifier) container) | ((Container.ItemSetChangeNotifier) container) | ||||
* add a JavaDoc comment here, we use the default documentation from | * add a JavaDoc comment here, we use the default documentation from | ||||
* implemented interface. | * implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Container.PropertySetChangeListener listener) { | public void addListener(Container.PropertySetChangeListener listener) { | ||||
if (container instanceof Container.PropertySetChangeNotifier) { | if (container instanceof Container.PropertySetChangeNotifier) { | ||||
((Container.PropertySetChangeNotifier) container) | ((Container.PropertySetChangeNotifier) container) | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Container.PropertySetChangeListener listener) { | public void removeListener(Container.PropertySetChangeListener listener) { | ||||
if (container instanceof Container.PropertySetChangeNotifier) { | if (container instanceof Container.PropertySetChangeNotifier) { | ||||
((Container.PropertySetChangeNotifier) container) | ((Container.PropertySetChangeNotifier) container) | ||||
listener = realListener; | listener = realListener; | ||||
} | } | ||||
@Override | |||||
public void containerItemSetChange(ItemSetChangeEvent event) { | public void containerItemSetChange(ItemSetChangeEvent event) { | ||||
updateHierarchicalWrapper(); | updateHierarchicalWrapper(); | ||||
((Container.ItemSetChangeListener) listener) | ((Container.ItemSetChangeListener) listener) | ||||
} | } | ||||
@Override | |||||
public void containerPropertySetChange(PropertySetChangeEvent event) { | public void containerPropertySetChange(PropertySetChangeEvent event) { | ||||
updateHierarchicalWrapper(); | updateHierarchicalWrapper(); | ||||
((Container.PropertySetChangeListener) listener) | ((Container.PropertySetChangeListener) listener) |
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Object firstItemId() { | public Object firstItemId() { | ||||
if (ordered) { | if (ordered) { | ||||
return ((Container.Ordered) container).firstItemId(); | return ((Container.Ordered) container).firstItemId(); | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isFirstId(Object itemId) { | public boolean isFirstId(Object itemId) { | ||||
if (ordered) { | if (ordered) { | ||||
return ((Container.Ordered) container).isFirstId(itemId); | return ((Container.Ordered) container).isFirstId(itemId); | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isLastId(Object itemId) { | public boolean isLastId(Object itemId) { | ||||
if (ordered) { | if (ordered) { | ||||
return ((Container.Ordered) container).isLastId(itemId); | return ((Container.Ordered) container).isLastId(itemId); | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Object lastItemId() { | public Object lastItemId() { | ||||
if (ordered) { | if (ordered) { | ||||
return ((Container.Ordered) container).lastItemId(); | return ((Container.Ordered) container).lastItemId(); | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Object nextItemId(Object itemId) { | public Object nextItemId(Object itemId) { | ||||
if (ordered) { | if (ordered) { | ||||
return ((Container.Ordered) container).nextItemId(itemId); | return ((Container.Ordered) container).nextItemId(itemId); | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Object prevItemId(Object itemId) { | public Object prevItemId(Object itemId) { | ||||
if (ordered) { | if (ordered) { | ||||
return ((Container.Ordered) container).prevItemId(itemId); | return ((Container.Ordered) container).prevItemId(itemId); | ||||
* @return <code>true</code> if the operation succeeded, <code>false</code> | * @return <code>true</code> if the operation succeeded, <code>false</code> | ||||
* if not | * if not | ||||
*/ | */ | ||||
@Override | |||||
public boolean addContainerProperty(Object propertyId, Class<?> type, | public boolean addContainerProperty(Object propertyId, Class<?> type, | ||||
Object defaultValue) throws UnsupportedOperationException { | Object defaultValue) throws UnsupportedOperationException { | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItem is not supported. | * if the addItem is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Object addItem() throws UnsupportedOperationException { | public Object addItem() throws UnsupportedOperationException { | ||||
final Object id = container.addItem(); | final Object id = container.addItem(); | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItem is not supported. | * if the addItem is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Item addItem(Object itemId) throws UnsupportedOperationException { | public Item addItem(Object itemId) throws UnsupportedOperationException { | ||||
final Item item = container.addItem(itemId); | final Item item = container.addItem(itemId); | ||||
if (!ordered && item != null) { | if (!ordered && item != null) { | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeAllItems is not supported. | * if the removeAllItems is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeAllItems() throws UnsupportedOperationException { | public boolean removeAllItems() throws UnsupportedOperationException { | ||||
final boolean success = container.removeAllItems(); | final boolean success = container.removeAllItems(); | ||||
if (!ordered && success) { | if (!ordered && success) { | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeItem is not supported. | * if the removeItem is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItem(Object itemId) | public boolean removeItem(Object itemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeContainerProperty is not supported. | * if the removeContainerProperty is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeContainerProperty(Object propertyId) | public boolean removeContainerProperty(Object propertyId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
return container.removeContainerProperty(propertyId); | return container.removeContainerProperty(propertyId); | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean containsId(Object itemId) { | public boolean containsId(Object itemId) { | ||||
return container.containsId(itemId); | return container.containsId(itemId); | ||||
} | } | ||||
* Gets the specified Item from the container. Don't add a JavaDoc comment | * Gets the specified Item from the container. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Item getItem(Object itemId) { | public Item getItem(Object itemId) { | ||||
return container.getItem(itemId); | return container.getItem(itemId); | ||||
} | } | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getItemIds() { | public Collection<?> getItemIds() { | ||||
return container.getItemIds(); | return container.getItemIds(); | ||||
} | } | ||||
* Container Don't add a JavaDoc comment here, we use the default | * Container Don't add a JavaDoc comment here, we use the default | ||||
* documentation from implemented interface. | * documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | public Property<?> getContainerProperty(Object itemId, Object propertyId) { | ||||
return container.getContainerProperty(itemId, propertyId); | return container.getContainerProperty(itemId, propertyId); | ||||
} | } | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getContainerPropertyIds() { | public Collection<?> getContainerPropertyIds() { | ||||
return container.getContainerPropertyIds(); | return container.getContainerPropertyIds(); | ||||
} | } | ||||
* Don't add a JavaDoc comment here, we use the default documentation from | * Don't add a JavaDoc comment here, we use the default documentation from | ||||
* implemented interface. | * implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Class<?> getType(Object propertyId) { | public Class<?> getType(Object propertyId) { | ||||
return container.getType(propertyId); | return container.getType(propertyId); | ||||
} | } | ||||
* Gets the number of Items in the Container. Don't add a JavaDoc comment | * Gets the number of Items in the Container. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public int size() { | public int size() { | ||||
int newSize = container.size(); | int newSize = container.size(); | ||||
if (lastKnownSize != -1 && newSize != lastKnownSize | if (lastKnownSize != -1 && newSize != lastKnownSize | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Container.ItemSetChangeListener listener) { | public void addListener(Container.ItemSetChangeListener listener) { | ||||
if (container instanceof Container.ItemSetChangeNotifier) { | if (container instanceof Container.ItemSetChangeNotifier) { | ||||
((Container.ItemSetChangeNotifier) container) | ((Container.ItemSetChangeNotifier) container) | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Container.ItemSetChangeListener listener) { | public void removeListener(Container.ItemSetChangeListener listener) { | ||||
if (container instanceof Container.ItemSetChangeNotifier) { | if (container instanceof Container.ItemSetChangeNotifier) { | ||||
((Container.ItemSetChangeNotifier) container) | ((Container.ItemSetChangeNotifier) container) | ||||
* add a JavaDoc comment here, we use the default documentation from | * add a JavaDoc comment here, we use the default documentation from | ||||
* implemented interface. | * implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Container.PropertySetChangeListener listener) { | public void addListener(Container.PropertySetChangeListener listener) { | ||||
if (container instanceof Container.PropertySetChangeNotifier) { | if (container instanceof Container.PropertySetChangeNotifier) { | ||||
((Container.PropertySetChangeNotifier) container) | ((Container.PropertySetChangeNotifier) container) | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Container.PropertySetChangeListener listener) { | public void removeListener(Container.PropertySetChangeListener listener) { | ||||
if (container instanceof Container.PropertySetChangeNotifier) { | if (container instanceof Container.PropertySetChangeNotifier) { | ||||
((Container.PropertySetChangeNotifier) container) | ((Container.PropertySetChangeNotifier) container) | ||||
* @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object, | * @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object, | ||||
* java.lang.Object) | * java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Item addItemAfter(Object previousItemId, Object newItemId) | public Item addItemAfter(Object previousItemId, Object newItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
* | * | ||||
* @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object) | * @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Object addItemAfter(Object previousItemId) | public Object addItemAfter(Object previousItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
listener = realListener; | listener = realListener; | ||||
} | } | ||||
@Override | |||||
public void containerItemSetChange(ItemSetChangeEvent event) { | public void containerItemSetChange(ItemSetChangeEvent event) { | ||||
updateOrderWrapper(); | updateOrderWrapper(); | ||||
((Container.ItemSetChangeListener) listener) | ((Container.ItemSetChangeListener) listener) | ||||
} | } | ||||
@Override | |||||
public void containerPropertySetChange(PropertySetChangeEvent event) { | public void containerPropertySetChange(PropertySetChangeEvent event) { | ||||
updateOrderWrapper(); | updateOrderWrapper(); | ||||
((Container.PropertySetChangeListener) listener) | ((Container.PropertySetChangeListener) listener) |
* @see com.vaadin.data.util.ItemSorter#compare(java.lang.Object, | * @see com.vaadin.data.util.ItemSorter#compare(java.lang.Object, | ||||
* java.lang.Object) | * java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public int compare(Object o1, Object o2) { | public int compare(Object o1, Object o2) { | ||||
Item item1 = container.getItem(o1); | Item item1 = container.getItem(o1); | ||||
Item item2 = container.getItem(o2); | Item item2 = container.getItem(o2); | ||||
* com.vaadin.data.util.ItemSorter#setSortProperties(com.vaadin.data.Container | * com.vaadin.data.util.ItemSorter#setSortProperties(com.vaadin.data.Container | ||||
* .Sortable, java.lang.Object[], boolean[]) | * .Sortable, java.lang.Object[], boolean[]) | ||||
*/ | */ | ||||
@Override | |||||
public void setSortProperties(Container.Sortable container, | public void setSortProperties(Container.Sortable container, | ||||
Object[] propertyId, boolean[] ascending) { | Object[] propertyId, boolean[] ascending) { | ||||
this.container = container; | this.container = container; | ||||
public static class DefaultPropertyValueComparator implements | public static class DefaultPropertyValueComparator implements | ||||
Comparator<Object>, Serializable { | Comparator<Object>, Serializable { | ||||
@Override | |||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
public int compare(Object o1, Object o2) { | public int compare(Object o1, Object o2) { | ||||
int r = 0; | int r = 0; |
* @return <code>true</code> if the specified Item is a directory, | * @return <code>true</code> if the specified Item is a directory, | ||||
* <code>false</code> otherwise. | * <code>false</code> otherwise. | ||||
*/ | */ | ||||
@Override | |||||
public boolean areChildrenAllowed(Object itemId) { | public boolean areChildrenAllowed(Object itemId) { | ||||
return itemId instanceof File && ((File) itemId).canRead() | return itemId instanceof File && ((File) itemId).canRead() | ||||
&& ((File) itemId).isDirectory(); | && ((File) itemId).isDirectory(); | ||||
* add a JavaDoc comment here, we use the default documentation from | * add a JavaDoc comment here, we use the default documentation from | ||||
* implemented interface. | * implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<File> getChildren(Object itemId) { | public Collection<File> getChildren(Object itemId) { | ||||
if (!(itemId instanceof File)) { | if (!(itemId instanceof File)) { | ||||
* Gets the parent item of the specified Item. Don't add a JavaDoc comment | * Gets the parent item of the specified Item. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Object getParent(Object itemId) { | public Object getParent(Object itemId) { | ||||
if (!(itemId instanceof File)) { | if (!(itemId instanceof File)) { | ||||
* Tests if the specified Item has any children. Don't add a JavaDoc comment | * Tests if the specified Item has any children. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean hasChildren(Object itemId) { | public boolean hasChildren(Object itemId) { | ||||
if (!(itemId instanceof File)) { | if (!(itemId instanceof File)) { | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isRoot(Object itemId) { | public boolean isRoot(Object itemId) { | ||||
if (!(itemId instanceof File)) { | if (!(itemId instanceof File)) { | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<File> rootItemIds() { | public Collection<File> rootItemIds() { | ||||
File[] f; | File[] f; | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the setChildrenAllowed is not supported. | * if the setChildrenAllowed is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) | public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the setParent is not supported. | * if the setParent is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean setParent(Object itemId, Object newParentId) | public boolean setParent(Object itemId, Object newParentId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean containsId(Object itemId) { | public boolean containsId(Object itemId) { | ||||
if (!(itemId instanceof File)) { | if (!(itemId instanceof File)) { | ||||
* Gets the specified Item from the filesystem. Don't add a JavaDoc comment | * Gets the specified Item from the filesystem. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Item getItem(Object itemId) { | public Item getItem(Object itemId) { | ||||
if (!(itemId instanceof File)) { | if (!(itemId instanceof File)) { | ||||
* Gets the IDs of Items in the filesystem. Don't add a JavaDoc comment | * Gets the IDs of Items in the filesystem. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<File> getItemIds() { | public Collection<File> getItemIds() { | ||||
if (recursive) { | if (recursive) { | ||||
* the property's ID. | * the property's ID. | ||||
* @return the requested property's value, or <code>null</code> | * @return the requested property's value, or <code>null</code> | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | public Property<?> getContainerProperty(Object itemId, Object propertyId) { | ||||
if (!(itemId instanceof File)) { | if (!(itemId instanceof File)) { | ||||
* | * | ||||
* @return Unmodifiable collection containing all available file properties. | * @return Unmodifiable collection containing all available file properties. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<String> getContainerPropertyIds() { | public Collection<String> getContainerPropertyIds() { | ||||
return FILE_PROPERTIES; | return FILE_PROPERTIES; | ||||
} | } | ||||
* the ID of the property whose type is requested. | * the ID of the property whose type is requested. | ||||
* @return data type of the requested property, or <code>null</code> | * @return data type of the requested property, or <code>null</code> | ||||
*/ | */ | ||||
@Override | |||||
public Class<?> getType(Object propertyId) { | public Class<?> getType(Object propertyId) { | ||||
if (propertyId.equals(PROPERTY_NAME)) { | if (propertyId.equals(PROPERTY_NAME)) { | ||||
* | * | ||||
* @return Number of Items in the container. | * @return Number of Items in the container. | ||||
*/ | */ | ||||
@Override | |||||
public int size() { | public int size() { | ||||
if (recursive) { | if (recursive) { | ||||
* Gets the specified property of this file. Don't add a JavaDoc comment | * Gets the specified property of this file. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getItemProperty(Object id) { | public Property<?> getItemProperty(Object id) { | ||||
return getContainerProperty(file, id); | return getContainerProperty(file, id); | ||||
} | } | ||||
* JavaDoc comment here, we use the default documentation from | * JavaDoc comment here, we use the default documentation from | ||||
* implemented interface. | * implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<String> getItemPropertyIds() { | public Collection<String> getItemPropertyIds() { | ||||
return getContainerPropertyIds(); | return getContainerPropertyIds(); | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.Item#addItemProperty(Object, Property) | * @see com.vaadin.data.Item#addItemProperty(Object, Property) | ||||
*/ | */ | ||||
@Override | |||||
public boolean addItemProperty(Object id, Property property) | public boolean addItemProperty(Object id, Property property) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException("Filesystem container " | throw new UnsupportedOperationException("Filesystem container " | ||||
* | * | ||||
* @see com.vaadin.data.Item#removeItemProperty(Object) | * @see com.vaadin.data.Item#removeItemProperty(Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItemProperty(Object id) | public boolean removeItemProperty(Object id) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
* | * | ||||
* @see java.io.FilenameFilter#accept(File, String) | * @see java.io.FilenameFilter#accept(File, String) | ||||
*/ | */ | ||||
@Override | |||||
public boolean accept(File dir, String name) { | public boolean accept(File dir, String name) { | ||||
if (name.endsWith(filter)) { | if (name.endsWith(filter)) { | ||||
return true; | return true; | ||||
* @see com.vaadin.data.Container#addContainerProperty(java.lang.Object, | * @see com.vaadin.data.Container#addContainerProperty(java.lang.Object, | ||||
* java.lang.Class, java.lang.Object) | * java.lang.Class, java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean addContainerProperty(Object propertyId, Class<?> type, | public boolean addContainerProperty(Object propertyId, Class<?> type, | ||||
Object defaultValue) throws UnsupportedOperationException { | Object defaultValue) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
* | * | ||||
* @see com.vaadin.data.Container#addItem() | * @see com.vaadin.data.Container#addItem() | ||||
*/ | */ | ||||
@Override | |||||
public Object addItem() throws UnsupportedOperationException { | public Object addItem() throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"File system container does not support this operation"); | "File system container does not support this operation"); | ||||
* | * | ||||
* @see com.vaadin.data.Container#addItem(java.lang.Object) | * @see com.vaadin.data.Container#addItem(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Item addItem(Object itemId) throws UnsupportedOperationException { | public Item addItem(Object itemId) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"File system container does not support this operation"); | "File system container does not support this operation"); | ||||
* | * | ||||
* @see com.vaadin.data.Container#removeAllItems() | * @see com.vaadin.data.Container#removeAllItems() | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeAllItems() throws UnsupportedOperationException { | public boolean removeAllItems() throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
"File system container does not support this operation"); | "File system container does not support this operation"); | ||||
* | * | ||||
* @see com.vaadin.data.Container#removeItem(java.lang.Object) | * @see com.vaadin.data.Container#removeItem(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItem(Object itemId) | public boolean removeItem(Object itemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
* | * | ||||
* @see com.vaadin.data.Container#removeContainerProperty(java.lang.Object ) | * @see com.vaadin.data.Container#removeContainerProperty(java.lang.Object ) | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeContainerProperty(Object propertyId) | public boolean removeContainerProperty(Object propertyId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( |
* Can the specified Item have any children? Don't add a JavaDoc comment | * Can the specified Item have any children? Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean areChildrenAllowed(Object itemId) { | public boolean areChildrenAllowed(Object itemId) { | ||||
if (noChildrenAllowed.contains(itemId)) { | if (noChildrenAllowed.contains(itemId)) { | ||||
return false; | return false; | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getChildren(Object itemId) { | public Collection<?> getChildren(Object itemId) { | ||||
LinkedList<Object> c; | LinkedList<Object> c; | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Object getParent(Object itemId) { | public Object getParent(Object itemId) { | ||||
if (filteredParent != null) { | if (filteredParent != null) { | ||||
return filteredParent.get(itemId); | return filteredParent.get(itemId); | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean hasChildren(Object itemId) { | public boolean hasChildren(Object itemId) { | ||||
if (filteredChildren != null) { | if (filteredChildren != null) { | ||||
return filteredChildren.containsKey(itemId); | return filteredChildren.containsKey(itemId); | ||||
* JavaDoc comment here, we use the default documentation from implemented | * JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isRoot(Object itemId) { | public boolean isRoot(Object itemId) { | ||||
// If the container is filtered the itemId must be among filteredRoots | // If the container is filtered the itemId must be among filteredRoots | ||||
// to be a root. | // to be a root. | ||||
* comment here, we use the default documentation from implemented | * comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> rootItemIds() { | public Collection<?> rootItemIds() { | ||||
if (filteredRoots != null) { | if (filteredRoots != null) { | ||||
return Collections.unmodifiableCollection(filteredRoots); | return Collections.unmodifiableCollection(filteredRoots); | ||||
* @return <code>true</code> if the operation succeeded, <code>false</code> | * @return <code>true</code> if the operation succeeded, <code>false</code> | ||||
* if not | * if not | ||||
*/ | */ | ||||
@Override | |||||
public boolean setChildrenAllowed(Object itemId, boolean childrenAllowed) { | public boolean setChildrenAllowed(Object itemId, boolean childrenAllowed) { | ||||
// Checks that the item is in the container | // Checks that the item is in the container | ||||
* @return <code>true</code> if the operation succeeded, <code>false</code> | * @return <code>true</code> if the operation succeeded, <code>false</code> | ||||
* if not | * if not | ||||
*/ | */ | ||||
@Override | |||||
public boolean setParent(Object itemId, Object newParentId) { | public boolean setParent(Object itemId, Object newParentId) { | ||||
// Checks that the item is in the container | // Checks that the item is in the container |
hierarchical = toBeWrapped; | hierarchical = toBeWrapped; | ||||
} | } | ||||
@Override | |||||
public boolean areChildrenAllowed(Object itemId) { | public boolean areChildrenAllowed(Object itemId) { | ||||
return hierarchical.areChildrenAllowed(itemId); | return hierarchical.areChildrenAllowed(itemId); | ||||
} | } | ||||
@Override | |||||
public Collection<?> getChildren(Object itemId) { | public Collection<?> getChildren(Object itemId) { | ||||
return hierarchical.getChildren(itemId); | return hierarchical.getChildren(itemId); | ||||
} | } | ||||
@Override | |||||
public Object getParent(Object itemId) { | public Object getParent(Object itemId) { | ||||
return hierarchical.getParent(itemId); | return hierarchical.getParent(itemId); | ||||
} | } | ||||
@Override | |||||
public boolean hasChildren(Object itemId) { | public boolean hasChildren(Object itemId) { | ||||
return hierarchical.hasChildren(itemId); | return hierarchical.hasChildren(itemId); | ||||
} | } | ||||
@Override | |||||
public boolean isRoot(Object itemId) { | public boolean isRoot(Object itemId) { | ||||
return hierarchical.isRoot(itemId); | return hierarchical.isRoot(itemId); | ||||
} | } | ||||
@Override | |||||
public Collection<?> rootItemIds() { | public Collection<?> rootItemIds() { | ||||
return hierarchical.rootItemIds(); | return hierarchical.rootItemIds(); | ||||
} | } | ||||
@Override | |||||
public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) | public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
return hierarchical.setChildrenAllowed(itemId, areChildrenAllowed); | return hierarchical.setChildrenAllowed(itemId, areChildrenAllowed); | ||||
} | } | ||||
@Override | |||||
public boolean setParent(Object itemId, Object newParentId) | public boolean setParent(Object itemId, Object newParentId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
return hierarchical.setParent(itemId, newParentId); | return hierarchical.setParent(itemId, newParentId); |
* | * | ||||
* @see com.vaadin.data.Container#getContainerPropertyIds() | * @see com.vaadin.data.Container#getContainerPropertyIds() | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getContainerPropertyIds() { | public Collection<?> getContainerPropertyIds() { | ||||
return Collections.unmodifiableCollection(propertyIds); | return Collections.unmodifiableCollection(propertyIds); | ||||
} | } | ||||
* the ID of the Property. | * the ID of the Property. | ||||
* @return Type of the requested Property | * @return Type of the requested Property | ||||
*/ | */ | ||||
@Override | |||||
public Class<?> getType(Object propertyId) { | public Class<?> getType(Object propertyId) { | ||||
return types.get(propertyId); | return types.get(propertyId); | ||||
} | } | ||||
* @see com.vaadin.data.Container#getContainerProperty(java.lang.Object, | * @see com.vaadin.data.Container#getContainerProperty(java.lang.Object, | ||||
* java.lang.Object) | * java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | public Property<?> getContainerProperty(Object itemId, Object propertyId) { | ||||
if (!containsId(itemId)) { | if (!containsId(itemId)) { | ||||
return null; | return null; | ||||
* | * | ||||
* @see com.vaadin.data.Property.ValueChangeEvent#getProperty() | * @see com.vaadin.data.Property.ValueChangeEvent#getProperty() | ||||
*/ | */ | ||||
@Override | |||||
public Property getProperty() { | public Property getProperty() { | ||||
return (Property) getSource(); | return (Property) getSource(); | ||||
} | } | ||||
* @see com.vaadin.data.Property.ValueChangeNotifier#addListener(com. | * @see com.vaadin.data.Property.ValueChangeNotifier#addListener(com. | ||||
* vaadin.data.Property.ValueChangeListener) | * vaadin.data.Property.ValueChangeListener) | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Property.ValueChangeListener listener) { | public void addListener(Property.ValueChangeListener listener) { | ||||
if (propertyValueChangeListeners == null) { | if (propertyValueChangeListeners == null) { | ||||
propertyValueChangeListeners = new LinkedList<Property.ValueChangeListener>(); | propertyValueChangeListeners = new LinkedList<Property.ValueChangeListener>(); | ||||
* @see com.vaadin.data.Property.ValueChangeNotifier#removeListener(com | * @see com.vaadin.data.Property.ValueChangeNotifier#removeListener(com | ||||
* .vaadin.data.Property.ValueChangeListener) | * .vaadin.data.Property.ValueChangeListener) | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Property.ValueChangeListener listener) { | public void removeListener(Property.ValueChangeListener listener) { | ||||
if (propertyValueChangeListeners != null) { | if (propertyValueChangeListeners != null) { | ||||
propertyValueChangeListeners.remove(listener); | propertyValueChangeListeners.remove(listener); | ||||
* | * | ||||
* @see com.vaadin.data.Item#getItemProperty(java.lang.Object) | * @see com.vaadin.data.Item#getItemProperty(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getItemProperty(Object id) { | public Property<?> getItemProperty(Object id) { | ||||
return new IndexedContainerProperty(itemId, id); | return new IndexedContainerProperty(itemId, id); | ||||
} | } | ||||
@Override | |||||
public Collection<?> getItemPropertyIds() { | public Collection<?> getItemPropertyIds() { | ||||
return Collections.unmodifiableCollection(propertyIds); | return Collections.unmodifiableCollection(propertyIds); | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.Item#addProperty(Object, Property) | * @see com.vaadin.data.Item#addProperty(Object, Property) | ||||
*/ | */ | ||||
@Override | |||||
public boolean addItemProperty(Object id, Property property) | public boolean addItemProperty(Object id, Property property) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException("Indexed container item " | throw new UnsupportedOperationException("Indexed container item " | ||||
* | * | ||||
* @see com.vaadin.data.Item#removeProperty(Object) | * @see com.vaadin.data.Item#removeProperty(Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItemProperty(Object id) | public boolean removeItemProperty(Object id) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException( | throw new UnsupportedOperationException( | ||||
* | * | ||||
* @see com.vaadin.data.Property#getType() | * @see com.vaadin.data.Property#getType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<?> getType() { | public Class<?> getType() { | ||||
return types.get(propertyId); | return types.get(propertyId); | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.Property#getValue() | * @see com.vaadin.data.Property#getValue() | ||||
*/ | */ | ||||
@Override | |||||
public Object getValue() { | public Object getValue() { | ||||
return items.get(itemId).get(propertyId); | return items.get(itemId).get(propertyId); | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.Property#isReadOnly() | * @see com.vaadin.data.Property#isReadOnly() | ||||
*/ | */ | ||||
@Override | |||||
public boolean isReadOnly() { | public boolean isReadOnly() { | ||||
return readOnlyProperties.contains(this); | return readOnlyProperties.contains(this); | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.Property#setReadOnly(boolean) | * @see com.vaadin.data.Property#setReadOnly(boolean) | ||||
*/ | */ | ||||
@Override | |||||
public void setReadOnly(boolean newStatus) { | public void setReadOnly(boolean newStatus) { | ||||
if (newStatus) { | if (newStatus) { | ||||
readOnlyProperties.add(this); | readOnlyProperties.add(this); | ||||
* | * | ||||
* @see com.vaadin.data.Property#setValue(java.lang.Object) | * @see com.vaadin.data.Property#setValue(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public void setValue(Object newValue) throws Property.ReadOnlyException { | public void setValue(Object newValue) throws Property.ReadOnlyException { | ||||
// Gets the Property set | // Gets the Property set | ||||
final Map<Object, Object> propertySet = items.get(itemId); | final Map<Object, Object> propertySet = items.get(itemId); | ||||
* @see com.vaadin.data.Property.ValueChangeNotifier#addListener( | * @see com.vaadin.data.Property.ValueChangeNotifier#addListener( | ||||
* com.vaadin.data.Property.ValueChangeListener) | * com.vaadin.data.Property.ValueChangeListener) | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Property.ValueChangeListener listener) { | public void addListener(Property.ValueChangeListener listener) { | ||||
addSinglePropertyChangeListener(propertyId, itemId, listener); | addSinglePropertyChangeListener(propertyId, itemId, listener); | ||||
} | } | ||||
* @see com.vaadin.data.Property.ValueChangeNotifier#removeListener | * @see com.vaadin.data.Property.ValueChangeNotifier#removeListener | ||||
* (com.vaadin.data.Property.ValueChangeListener) | * (com.vaadin.data.Property.ValueChangeListener) | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Property.ValueChangeListener listener) { | public void removeListener(Property.ValueChangeListener listener) { | ||||
removeSinglePropertyChangeListener(propertyId, itemId, listener); | removeSinglePropertyChangeListener(propertyId, itemId, listener); | ||||
} | } | ||||
* @see com.vaadin.data.Container.Sortable#sort(java.lang.Object[], | * @see com.vaadin.data.Container.Sortable#sort(java.lang.Object[], | ||||
* boolean[]) | * boolean[]) | ||||
*/ | */ | ||||
@Override | |||||
public void sort(Object[] propertyId, boolean[] ascending) { | public void sort(Object[] propertyId, boolean[] ascending) { | ||||
sortContainer(propertyId, ascending); | sortContainer(propertyId, ascending); | ||||
} | } | ||||
* @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds | * @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds | ||||
* () | * () | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getSortableContainerPropertyIds() { | public Collection<?> getSortableContainerPropertyIds() { | ||||
return getSortablePropertyIds(); | return getSortablePropertyIds(); | ||||
} | } | ||||
return nc; | return nc; | ||||
} | } | ||||
@Override | |||||
public void addContainerFilter(Object propertyId, String filterString, | public void addContainerFilter(Object propertyId, String filterString, | ||||
boolean ignoreCase, boolean onlyMatchPrefix) { | boolean ignoreCase, boolean onlyMatchPrefix) { | ||||
try { | try { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void removeAllContainerFilters() { | public void removeAllContainerFilters() { | ||||
removeAllFilters(); | removeAllFilters(); | ||||
} | } | ||||
@Override | |||||
public void removeContainerFilters(Object propertyId) { | public void removeContainerFilters(Object propertyId) { | ||||
removeFilters(propertyId); | removeFilters(propertyId); | ||||
} | } | ||||
@Override | |||||
public void addContainerFilter(Filter filter) | public void addContainerFilter(Filter filter) | ||||
throws UnsupportedFilterException { | throws UnsupportedFilterException { | ||||
addFilter(filter); | addFilter(filter); | ||||
} | } | ||||
@Override | |||||
public void removeContainerFilter(Filter filter) { | public void removeContainerFilter(Filter filter) { | ||||
removeFilter(filter); | removeFilter(filter); | ||||
} | } |
* | * | ||||
* @see Comparator#compare(Object, Object) | * @see Comparator#compare(Object, Object) | ||||
*/ | */ | ||||
@Override | |||||
int compare(Object itemId1, Object itemId2); | int compare(Object itemId1, Object itemId2); | ||||
} | } |
* | * | ||||
* @return type of the Property | * @return type of the Property | ||||
*/ | */ | ||||
@Override | |||||
public final Class<? extends T> getType() { | public final Class<? extends T> getType() { | ||||
return type; | return type; | ||||
} | } | ||||
* | * | ||||
* @return the value of the Property | * @return the value of the Property | ||||
*/ | */ | ||||
@Override | |||||
public T getValue() { | public T getValue() { | ||||
try { | try { | ||||
return (T) getMethod.invoke(instance, getArgs); | return (T) getMethod.invoke(instance, getArgs); | ||||
* read-only mode. | * read-only mode. | ||||
* @see #invokeSetMethod(Object) | * @see #invokeSetMethod(Object) | ||||
*/ | */ | ||||
@Override | |||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
public void setValue(Object newValue) throws Property.ReadOnlyException { | public void setValue(Object newValue) throws Property.ReadOnlyException { | ||||
} | } | ||||
}; | }; | ||||
@Override | |||||
public String getName() { | public String getName() { | ||||
return name; | return name; | ||||
} | } | ||||
@Override | |||||
public Class<?> getPropertyType() { | public Class<?> getPropertyType() { | ||||
return propertyType; | return propertyType; | ||||
} | } | ||||
@Override | |||||
public Property<?> createProperty(Object bean) { | public Property<?> createProperty(Object bean) { | ||||
return new MethodProperty<Object>(propertyType, bean, readMethod, | return new MethodProperty<Object>(propertyType, bean, readMethod, | ||||
writeMethod); | writeMethod); |
this.setMethod = setMethod; | this.setMethod = setMethod; | ||||
} | } | ||||
@Override | |||||
public Class<? extends T> getType() { | public Class<? extends T> getType() { | ||||
return type; | return type; | ||||
} | } | ||||
* | * | ||||
* @return the value of the Property | * @return the value of the Property | ||||
*/ | */ | ||||
@Override | |||||
public T getValue() { | public T getValue() { | ||||
try { | try { | ||||
Object object = instance; | Object object = instance; | ||||
* read-only mode. | * read-only mode. | ||||
* @see #invokeSetMethod(Object) | * @see #invokeSetMethod(Object) | ||||
*/ | */ | ||||
@Override | |||||
public void setValue(Object newValue) throws ReadOnlyException { | public void setValue(Object newValue) throws ReadOnlyException { | ||||
// Checks the mode | // Checks the mode | ||||
if (isReadOnly()) { | if (isReadOnly()) { |
this.propertyType = property.getType(); | this.propertyType = property.getType(); | ||||
} | } | ||||
@Override | |||||
public String getName() { | public String getName() { | ||||
return name; | return name; | ||||
} | } | ||||
@Override | |||||
public Class<?> getPropertyType() { | public Class<?> getPropertyType() { | ||||
return propertyType; | return propertyType; | ||||
} | } | ||||
@Override | |||||
public Property<?> createProperty(BT bean) { | public Property<?> createProperty(BT bean) { | ||||
return new NestedMethodProperty<Object>(bean, name); | return new NestedMethodProperty<Object>(bean, name); | ||||
} | } |
* | * | ||||
* @return type of the Property | * @return type of the Property | ||||
*/ | */ | ||||
@Override | |||||
public final Class<T> getType() { | public final Class<T> getType() { | ||||
return type; | return type; | ||||
} | } | ||||
* | * | ||||
* @return the value stored in the Property | * @return the value stored in the Property | ||||
*/ | */ | ||||
@Override | |||||
public T getValue() { | public T getValue() { | ||||
return value; | return value; | ||||
} | } | ||||
* @throws <code>Property.ReadOnlyException</code> if the object is in | * @throws <code>Property.ReadOnlyException</code> if the object is in | ||||
* read-only mode | * read-only mode | ||||
*/ | */ | ||||
@Override | |||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
public void setValue(Object newValue) throws Property.ReadOnlyException { | public void setValue(Object newValue) throws Property.ReadOnlyException { | ||||
* @return the current data source as a Property, or <code>null</code> if | * @return the current data source as a Property, or <code>null</code> if | ||||
* none defined. | * none defined. | ||||
*/ | */ | ||||
@Override | |||||
public Property<T> getPropertyDataSource() { | public Property<T> getPropertyDataSource() { | ||||
return dataSource; | return dataSource; | ||||
} | } | ||||
* @param newDataSource | * @param newDataSource | ||||
* the new data source Property. | * the new data source Property. | ||||
*/ | */ | ||||
@Override | |||||
public void setPropertyDataSource(Property newDataSource) { | public void setPropertyDataSource(Property newDataSource) { | ||||
boolean readOnly = false; | boolean readOnly = false; | ||||
} | } | ||||
/* Documented in the interface */ | /* Documented in the interface */ | ||||
@Override | |||||
public Class<String> getType() { | public Class<String> getType() { | ||||
return String.class; | return String.class; | ||||
} | } | ||||
* @return If the datasource returns null, this is null. Otherwise this is | * @return If the datasource returns null, this is null. Otherwise this is | ||||
* String given by format(). | * String given by format(). | ||||
*/ | */ | ||||
@Override | |||||
public String getValue() { | public String getValue() { | ||||
T value = dataSource == null ? null : dataSource.getValue(); | T value = dataSource == null ? null : dataSource.getValue(); | ||||
if (value == null) { | if (value == null) { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void setValue(Object newValue) throws ReadOnlyException { | public void setValue(Object newValue) throws ReadOnlyException { | ||||
if (dataSource == null) { | if (dataSource == null) { | ||||
return; | return; | ||||
* | * | ||||
* This should not be called directly. | * This should not be called directly. | ||||
*/ | */ | ||||
@Override | |||||
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { | public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { | ||||
fireValueChange(); | fireValueChange(); | ||||
} | } | ||||
* | * | ||||
* This should not be called directly. | * This should not be called directly. | ||||
*/ | */ | ||||
@Override | |||||
public void readOnlyStatusChange( | public void readOnlyStatusChange( | ||||
com.vaadin.data.Property.ReadOnlyStatusChangeEvent event) { | com.vaadin.data.Property.ReadOnlyStatusChangeEvent event) { | ||||
fireReadOnlyStatusChange(); | fireReadOnlyStatusChange(); |
* the identifier of the Property to get. | * the identifier of the Property to get. | ||||
* @return the Property with the given ID or <code>null</code> | * @return the Property with the given ID or <code>null</code> | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getItemProperty(Object id) { | public Property<?> getItemProperty(Object id) { | ||||
return map.get(id); | return map.get(id); | ||||
} | } | ||||
* @return unmodifiable collection containing IDs of the Properties stored | * @return unmodifiable collection containing IDs of the Properties stored | ||||
* the Item | * the Item | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getItemPropertyIds() { | public Collection<?> getItemPropertyIds() { | ||||
return Collections.unmodifiableCollection(list); | return Collections.unmodifiableCollection(list); | ||||
} | } | ||||
* @return <code>true</code> if the operation succeeded <code>false</code> | * @return <code>true</code> if the operation succeeded <code>false</code> | ||||
* if not | * if not | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItemProperty(Object id) { | public boolean removeItemProperty(Object id) { | ||||
// Cant remove missing properties | // Cant remove missing properties | ||||
* @return <code>true</code> if the operation succeeded, <code>false</code> | * @return <code>true</code> if the operation succeeded, <code>false</code> | ||||
* if not | * if not | ||||
*/ | */ | ||||
@Override | |||||
public boolean addItemProperty(Object id, Property property) { | public boolean addItemProperty(Object id, Property property) { | ||||
// Null ids are not accepted | // Null ids are not accepted | ||||
* | * | ||||
* @return source object of the event as an <code>Item</code> | * @return source object of the event as an <code>Item</code> | ||||
*/ | */ | ||||
@Override | |||||
public Item getItem() { | public Item getItem() { | ||||
return (Item) getSource(); | return (Item) getSource(); | ||||
} | } | ||||
* @param listener | * @param listener | ||||
* the new Listener to be registered. | * the new Listener to be registered. | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Item.PropertySetChangeListener listener) { | public void addListener(Item.PropertySetChangeListener listener) { | ||||
if (propertySetChangeListeners == null) { | if (propertySetChangeListeners == null) { | ||||
propertySetChangeListeners = new LinkedList<PropertySetChangeListener>(); | propertySetChangeListeners = new LinkedList<PropertySetChangeListener>(); | ||||
* @param listener | * @param listener | ||||
* the Listener to be removed. | * the Listener to be removed. | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Item.PropertySetChangeListener listener) { | public void removeListener(Item.PropertySetChangeListener listener) { | ||||
if (propertySetChangeListeners != null) { | if (propertySetChangeListeners != null) { | ||||
propertySetChangeListeners.remove(listener); | propertySetChangeListeners.remove(listener); |
* @return Item Id. | * @return Item Id. | ||||
*/ | */ | ||||
@Override | |||||
public Item getItem(Object id) { | public Item getItem(Object id) { | ||||
return new Row(id); | return new Row(id); | ||||
} | } | ||||
* @return Collection of Property ID. | * @return Collection of Property ID. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<String> getContainerPropertyIds() { | public Collection<String> getContainerPropertyIds() { | ||||
return propertyIds; | return propertyIds; | ||||
} | } | ||||
* | * | ||||
* @return collection of Item IDs | * @return collection of Item IDs | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getItemIds() { | public Collection<?> getItemIds() { | ||||
final Collection<Integer> c = new ArrayList<Integer>(size); | final Collection<Integer> c = new ArrayList<Integer>(size); | ||||
for (int i = 1; i <= size; i++) { | for (int i = 1; i <= size; i++) { | ||||
* otherwise. | * otherwise. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized Property<?> getContainerProperty(Object itemId, | public synchronized Property<?> getContainerProperty(Object itemId, | ||||
Object propertyId) { | Object propertyId) { | ||||
if (!(itemId instanceof Integer && propertyId instanceof String)) { | if (!(itemId instanceof Integer && propertyId instanceof String)) { | ||||
* @return data type of the Properties | * @return data type of the Properties | ||||
*/ | */ | ||||
@Override | |||||
public Class<?> getType(Object id) { | public Class<?> getType(Object id) { | ||||
return propertyTypes.get(id); | return propertyTypes.get(id); | ||||
} | } | ||||
* | * | ||||
* @return the number of items in the container. | * @return the number of items in the container. | ||||
*/ | */ | ||||
@Override | |||||
public int size() { | public int size() { | ||||
return size; | return size; | ||||
} | } | ||||
* @return <code>true</code> if given id is in the container; | * @return <code>true</code> if given id is in the container; | ||||
* <code>false</code> otherwise. | * <code>false</code> otherwise. | ||||
*/ | */ | ||||
@Override | |||||
public boolean containsId(Object id) { | public boolean containsId(Object id) { | ||||
if (!(id instanceof Integer)) { | if (!(id instanceof Integer)) { | ||||
return false; | return false; | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItem method is not supported. | * if the addItem method is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Item addItem(Object itemId) throws UnsupportedOperationException { | public Item addItem(Object itemId) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItem method is not supported. | * if the addItem method is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Object addItem() throws UnsupportedOperationException { | public Object addItem() throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeItem method is not supported. | * if the removeItem method is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItem(Object itemId) | public boolean removeItem(Object itemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addContainerProperty method is not supported. | * if the addContainerProperty method is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean addContainerProperty(Object propertyId, Class<?> type, | public boolean addContainerProperty(Object propertyId, Class<?> type, | ||||
Object defaultValue) throws UnsupportedOperationException { | Object defaultValue) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeContainerProperty method is not supported. | * if the removeContainerProperty method is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeContainerProperty(Object propertyId) | public boolean removeContainerProperty(Object propertyId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeAllItems method is not supported. | * if the removeAllItems method is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeAllItems() throws UnsupportedOperationException { | public boolean removeAllItems() throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItemAfter method is not supported. | * if the addItemAfter method is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Item addItemAfter(Object previousItemId, Object newItemId) | public Item addItemAfter(Object previousItemId, Object newItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItemAfter method is not supported. | * if the addItemAfter method is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Object addItemAfter(Object previousItemId) | public Object addItemAfter(Object previousItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* | * | ||||
* @return ID of the first Item in the list. | * @return ID of the first Item in the list. | ||||
*/ | */ | ||||
@Override | |||||
public Object firstItemId() { | public Object firstItemId() { | ||||
if (size < 1) { | if (size < 1) { | ||||
return null; | return null; | ||||
* @param id | * @param id | ||||
* ID of an Item in the Container. | * ID of an Item in the Container. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isFirstId(Object id) { | public boolean isFirstId(Object id) { | ||||
return size > 0 && (id instanceof Integer) | return size > 0 && (id instanceof Integer) | ||||
&& ((Integer) id).intValue() == 1; | && ((Integer) id).intValue() == 1; | ||||
* ID of an Item in the Container | * ID of an Item in the Container | ||||
* | * | ||||
*/ | */ | ||||
@Override | |||||
public boolean isLastId(Object id) { | public boolean isLastId(Object id) { | ||||
return size > 0 && (id instanceof Integer) | return size > 0 && (id instanceof Integer) | ||||
&& ((Integer) id).intValue() == size; | && ((Integer) id).intValue() == size; | ||||
* | * | ||||
* @return ID of the last Item. | * @return ID of the last Item. | ||||
*/ | */ | ||||
@Override | |||||
public Object lastItemId() { | public Object lastItemId() { | ||||
if (size < 1) { | if (size < 1) { | ||||
return null; | return null; | ||||
* ID of an Item in the Container. | * ID of an Item in the Container. | ||||
* @return ID of the next Item or null. | * @return ID of the next Item or null. | ||||
*/ | */ | ||||
@Override | |||||
public Object nextItemId(Object id) { | public Object nextItemId(Object id) { | ||||
if (size < 1 || !(id instanceof Integer)) { | if (size < 1 || !(id instanceof Integer)) { | ||||
return null; | return null; | ||||
* ID of an Item in the Container. | * ID of an Item in the Container. | ||||
* @return ID of the previous Item or null. | * @return ID of the previous Item or null. | ||||
*/ | */ | ||||
@Override | |||||
public Object prevItemId(Object id) { | public Object prevItemId(Object id) { | ||||
if (size < 1 || !(id instanceof Integer)) { | if (size < 1 || !(id instanceof Integer)) { | ||||
return null; | return null; | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItemProperty method is not supported. | * if the addItemProperty method is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean addItemProperty(Object id, Property property) | public boolean addItemProperty(Object id, Property property) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* identifier of the Property to get | * identifier of the Property to get | ||||
* @return the Property with the given ID or <code>null</code> | * @return the Property with the given ID or <code>null</code> | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getItemProperty(Object propertyId) { | public Property<?> getItemProperty(Object propertyId) { | ||||
return getContainerProperty(id, propertyId); | return getContainerProperty(id, propertyId); | ||||
} | } | ||||
* @return unmodifiable collection containing IDs of the Properties | * @return unmodifiable collection containing IDs of the Properties | ||||
* stored the Item. | * stored the Item. | ||||
*/ | */ | ||||
@Override | |||||
public Collection<String> getItemPropertyIds() { | public Collection<String> getItemPropertyIds() { | ||||
return propertyIds; | return propertyIds; | ||||
} | } | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the removeItemProperty is not supported. | * if the removeItemProperty is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItemProperty(Object id) | public boolean removeItemProperty(Object id) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* @throws UnsupportedOperationException | * @throws UnsupportedOperationException | ||||
* if the addItemAt is not supported. | * if the addItemAt is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Item addItemAt(int index, Object newItemId) | public Item addItemAt(int index, Object newItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* if the addItemAt is not supported. | * if the addItemAt is not supported. | ||||
*/ | */ | ||||
@Override | |||||
public Object addItemAt(int index) throws UnsupportedOperationException { | public Object addItemAt(int index) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
* Index Id. | * Index Id. | ||||
* @return ID in the given index. | * @return ID in the given index. | ||||
*/ | */ | ||||
@Override | |||||
public Object getIdByIndex(int index) { | public Object getIdByIndex(int index) { | ||||
if (size < 1 || index < 0 || index >= size) { | if (size < 1 || index < 0 || index >= size) { | ||||
return null; | return null; | ||||
* Item | * Item | ||||
*/ | */ | ||||
@Override | |||||
public int indexOfId(Object id) { | public int indexOfId(Object id) { | ||||
if (size < 1 || !(id instanceof Integer)) { | if (size < 1 || !(id instanceof Integer)) { | ||||
return -1; | return -1; |
* | * | ||||
* @see com.vaadin.data.Property#getType() | * @see com.vaadin.data.Property#getType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<String> getType() { | public Class<String> getType() { | ||||
return String.class; | return String.class; | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.Property#getValue() | * @see com.vaadin.data.Property#getValue() | ||||
*/ | */ | ||||
@Override | |||||
public String getValue() { | public String getValue() { | ||||
if (file == null) { | if (file == null) { | ||||
return null; | return null; | ||||
* | * | ||||
* @see com.vaadin.data.Property#setValue(java.lang.Object) | * @see com.vaadin.data.Property#setValue(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public void setValue(Object newValue) throws ReadOnlyException { | public void setValue(Object newValue) throws ReadOnlyException { | ||||
if (isReadOnly()) { | if (isReadOnly()) { | ||||
throw new ReadOnlyException(); | throw new ReadOnlyException(); |
((ValueChangeNotifier) wrappedProperty) | ((ValueChangeNotifier) wrappedProperty) | ||||
.addListener(new ValueChangeListener() { | .addListener(new ValueChangeListener() { | ||||
@Override | |||||
public void valueChange(ValueChangeEvent event) { | public void valueChange(ValueChangeEvent event) { | ||||
fireValueChange(); | fireValueChange(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public Class getType() { | public Class getType() { | ||||
return wrappedProperty.getType(); | return wrappedProperty.getType(); | ||||
} | } | ||||
@Override | |||||
public T getValue() { | public T getValue() { | ||||
return wrappedProperty.getValue(); | return wrappedProperty.getValue(); | ||||
} | } | ||||
@Override | |||||
public void setValue(Object newValue) throws ReadOnlyException { | public void setValue(Object newValue) throws ReadOnlyException { | ||||
// Causes a value change to be sent to this listener which in turn fires | // Causes a value change to be sent to this listener which in turn fires | ||||
// a new value change event for this property | // a new value change event for this property | ||||
wrappedProperty.setValue(newValue); | wrappedProperty.setValue(newValue); | ||||
} | } | ||||
@Override | |||||
public void startTransaction() { | public void startTransaction() { | ||||
inTransaction = true; | inTransaction = true; | ||||
valueBeforeTransaction = getValue(); | valueBeforeTransaction = getValue(); | ||||
} | } | ||||
@Override | |||||
public void commit() { | public void commit() { | ||||
endTransaction(); | endTransaction(); | ||||
} | } | ||||
@Override | |||||
public void rollback() { | public void rollback() { | ||||
try { | try { | ||||
wrappedProperty.setValue(valueBeforeTransaction); | wrappedProperty.setValue(valueBeforeTransaction); |
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | * com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | ||||
* java.util.Locale) | * java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public Long convertToModel(Date value, Locale locale) { | public Long convertToModel(Date value, Locale locale) { | ||||
if (value == null) { | if (value == null) { | ||||
return null; | return null; | ||||
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | * com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | ||||
* .Object, java.util.Locale) | * .Object, java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public Date convertToPresentation(Long value, Locale locale) { | public Date convertToPresentation(Long value, Locale locale) { | ||||
if (value == null) { | if (value == null) { | ||||
return null; | return null; | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getModelType() | * @see com.vaadin.data.util.converter.Converter#getModelType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<Long> getModelType() { | public Class<Long> getModelType() { | ||||
return Long.class; | return Long.class; | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getPresentationType() | * @see com.vaadin.data.util.converter.Converter#getPresentationType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<Date> getPresentationType() { | public Class<Date> getPresentationType() { | ||||
return Date.class; | return Date.class; | ||||
} | } |
private final static Logger log = Logger | private final static Logger log = Logger | ||||
.getLogger(DefaultConverterFactory.class.getName()); | .getLogger(DefaultConverterFactory.class.getName()); | ||||
@Override | |||||
public <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> createConverter( | public <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> createConverter( | ||||
Class<PRESENTATION> presentationType, Class<MODEL> modelType) { | Class<PRESENTATION> presentationType, Class<MODEL> modelType) { | ||||
Converter<PRESENTATION, MODEL> converter = findConverter( | Converter<PRESENTATION, MODEL> converter = findConverter( |
* @see com.vaadin.data.util.converter.Converter#convertToModel(java | * @see com.vaadin.data.util.converter.Converter#convertToModel(java | ||||
* .lang.Object, java.util.Locale) | * .lang.Object, java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public MODEL convertToModel(PRESENTATION value, Locale locale) | public MODEL convertToModel(PRESENTATION value, Locale locale) | ||||
throws com.vaadin.data.util.converter.Converter.ConversionException { | throws com.vaadin.data.util.converter.Converter.ConversionException { | ||||
return realConverter.convertToPresentation(value, locale); | return realConverter.convertToPresentation(value, locale); | ||||
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | * com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | ||||
* .Object, java.util.Locale) | * .Object, java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public PRESENTATION convertToPresentation(MODEL value, Locale locale) | public PRESENTATION convertToPresentation(MODEL value, Locale locale) | ||||
throws com.vaadin.data.util.converter.Converter.ConversionException { | throws com.vaadin.data.util.converter.Converter.ConversionException { | ||||
return realConverter.convertToModel(value, locale); | return realConverter.convertToModel(value, locale); | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getSourceType() | * @see com.vaadin.data.util.converter.Converter#getSourceType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<MODEL> getModelType() { | public Class<MODEL> getModelType() { | ||||
return realConverter.getPresentationType(); | return realConverter.getPresentationType(); | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getTargetType() | * @see com.vaadin.data.util.converter.Converter#getTargetType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<PRESENTATION> getPresentationType() { | public Class<PRESENTATION> getPresentationType() { | ||||
return realConverter.getModelType(); | return realConverter.getModelType(); | ||||
} | } |
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | * com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | ||||
* java.util.Locale) | * java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public Boolean convertToModel(String value, Locale locale) | public Boolean convertToModel(String value, Locale locale) | ||||
throws ConversionException { | throws ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | * com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | ||||
* .Object, java.util.Locale) | * .Object, java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public String convertToPresentation(Boolean value, Locale locale) | public String convertToPresentation(Boolean value, Locale locale) | ||||
throws ConversionException { | throws ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getModelType() | * @see com.vaadin.data.util.converter.Converter#getModelType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<Boolean> getModelType() { | public Class<Boolean> getModelType() { | ||||
return Boolean.class; | return Boolean.class; | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getPresentationType() | * @see com.vaadin.data.util.converter.Converter#getPresentationType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<String> getPresentationType() { | public Class<String> getPresentationType() { | ||||
return String.class; | return String.class; | ||||
} | } |
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | * com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | ||||
* java.util.Locale) | * java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public Date convertToModel(String value, Locale locale) | public Date convertToModel(String value, Locale locale) | ||||
throws com.vaadin.data.util.converter.Converter.ConversionException { | throws com.vaadin.data.util.converter.Converter.ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | * com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | ||||
* .Object, java.util.Locale) | * .Object, java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public String convertToPresentation(Date value, Locale locale) | public String convertToPresentation(Date value, Locale locale) | ||||
throws com.vaadin.data.util.converter.Converter.ConversionException { | throws com.vaadin.data.util.converter.Converter.ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getModelType() | * @see com.vaadin.data.util.converter.Converter#getModelType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<Date> getModelType() { | public Class<Date> getModelType() { | ||||
return Date.class; | return Date.class; | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getPresentationType() | * @see com.vaadin.data.util.converter.Converter#getPresentationType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<String> getPresentationType() { | public Class<String> getPresentationType() { | ||||
return String.class; | return String.class; | ||||
} | } |
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | * com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | ||||
* java.util.Locale) | * java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public Double convertToModel(String value, Locale locale) | public Double convertToModel(String value, Locale locale) | ||||
throws ConversionException { | throws ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | * com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | ||||
* .Object, java.util.Locale) | * .Object, java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public String convertToPresentation(Double value, Locale locale) | public String convertToPresentation(Double value, Locale locale) | ||||
throws ConversionException { | throws ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getModelType() | * @see com.vaadin.data.util.converter.Converter#getModelType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<Double> getModelType() { | public Class<Double> getModelType() { | ||||
return Double.class; | return Double.class; | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getPresentationType() | * @see com.vaadin.data.util.converter.Converter#getPresentationType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<String> getPresentationType() { | public Class<String> getPresentationType() { | ||||
return String.class; | return String.class; | ||||
} | } |
return NumberFormat.getIntegerInstance(locale); | return NumberFormat.getIntegerInstance(locale); | ||||
} | } | ||||
@Override | |||||
public Integer convertToModel(String value, Locale locale) | public Integer convertToModel(String value, Locale locale) | ||||
throws ConversionException { | throws ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
return parsedValue.intValue(); | return parsedValue.intValue(); | ||||
} | } | ||||
@Override | |||||
public String convertToPresentation(Integer value, Locale locale) | public String convertToPresentation(Integer value, Locale locale) | ||||
throws ConversionException { | throws ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
return getFormat(locale).format(value); | return getFormat(locale).format(value); | ||||
} | } | ||||
@Override | |||||
public Class<Integer> getModelType() { | public Class<Integer> getModelType() { | ||||
return Integer.class; | return Integer.class; | ||||
} | } | ||||
@Override | |||||
public Class<String> getPresentationType() { | public Class<String> getPresentationType() { | ||||
return String.class; | return String.class; | ||||
} | } |
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | * com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object, | ||||
* java.util.Locale) | * java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public Number convertToModel(String value, Locale locale) | public Number convertToModel(String value, Locale locale) | ||||
throws ConversionException { | throws ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | * com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang | ||||
* .Object, java.util.Locale) | * .Object, java.util.Locale) | ||||
*/ | */ | ||||
@Override | |||||
public String convertToPresentation(Number value, Locale locale) | public String convertToPresentation(Number value, Locale locale) | ||||
throws ConversionException { | throws ConversionException { | ||||
if (value == null) { | if (value == null) { | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getModelType() | * @see com.vaadin.data.util.converter.Converter#getModelType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<Number> getModelType() { | public Class<Number> getModelType() { | ||||
return Number.class; | return Number.class; | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.util.converter.Converter#getPresentationType() | * @see com.vaadin.data.util.converter.Converter#getPresentationType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<String> getPresentationType() { | public Class<String> getPresentationType() { | ||||
return String.class; | return String.class; | ||||
} | } |
* If there are no sub-filters, false is returned - override in subclasses | * If there are no sub-filters, false is returned - override in subclasses | ||||
* to change this behavior. | * to change this behavior. | ||||
*/ | */ | ||||
@Override | |||||
public boolean appliesToProperty(Object propertyId) { | public boolean appliesToProperty(Object propertyId) { | ||||
for (Filter filter : getFilters()) { | for (Filter filter : getFilters()) { | ||||
if (filter.appliesToProperty(propertyId)) { | if (filter.appliesToProperty(propertyId)) { |
super(filters); | super(filters); | ||||
} | } | ||||
@Override | |||||
public boolean passesFilter(Object itemId, Item item) | public boolean passesFilter(Object itemId, Item item) | ||||
throws UnsupportedFilterException { | throws UnsupportedFilterException { | ||||
for (Filter filter : getFilters()) { | for (Filter filter : getFilters()) { |
return endValue; | return endValue; | ||||
} | } | ||||
@Override | |||||
public boolean passesFilter(Object itemId, Item item) | public boolean passesFilter(Object itemId, Item item) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
Object value = item.getItemProperty(getPropertyId()).getValue(); | Object value = item.getItemProperty(getPropertyId()).getValue(); | ||||
return false; | return false; | ||||
} | } | ||||
@Override | |||||
public boolean appliesToProperty(Object propertyId) { | public boolean appliesToProperty(Object propertyId) { | ||||
return getPropertyId() != null && getPropertyId().equals(propertyId); | return getPropertyId() != null && getPropertyId().equals(propertyId); | ||||
} | } |
this.operation = operation; | this.operation = operation; | ||||
} | } | ||||
@Override | |||||
public boolean passesFilter(Object itemId, Item item) { | public boolean passesFilter(Object itemId, Item item) { | ||||
final Property<?> p = item.getItemProperty(getPropertyId()); | final Property<?> p = item.getItemProperty(getPropertyId()); | ||||
if (null == p) { | if (null == p) { | ||||
+ value1 + ", " + getValue()); | + value1 + ", " + getValue()); | ||||
} | } | ||||
@Override | |||||
public boolean appliesToProperty(Object propertyId) { | public boolean appliesToProperty(Object propertyId) { | ||||
return getPropertyId().equals(propertyId); | return getPropertyId().equals(propertyId); | ||||
} | } |
this.propertyId = propertyId; | this.propertyId = propertyId; | ||||
} | } | ||||
@Override | |||||
public boolean passesFilter(Object itemId, Item item) | public boolean passesFilter(Object itemId, Item item) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
final Property<?> p = item.getItemProperty(getPropertyId()); | final Property<?> p = item.getItemProperty(getPropertyId()); | ||||
return null == p.getValue(); | return null == p.getValue(); | ||||
} | } | ||||
@Override | |||||
public boolean appliesToProperty(Object propertyId) { | public boolean appliesToProperty(Object propertyId) { | ||||
return getPropertyId().equals(propertyId); | return getPropertyId().equals(propertyId); | ||||
} | } |
return caseSensitive; | return caseSensitive; | ||||
} | } | ||||
@Override | |||||
public boolean passesFilter(Object itemId, Item item) | public boolean passesFilter(Object itemId, Item item) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
if (!item.getItemProperty(getPropertyId()).getType() | if (!item.getItemProperty(getPropertyId()).getType() | ||||
return colValue.toUpperCase().matches(pattern.toUpperCase()); | return colValue.toUpperCase().matches(pattern.toUpperCase()); | ||||
} | } | ||||
@Override | |||||
public boolean appliesToProperty(Object propertyId) { | public boolean appliesToProperty(Object propertyId) { | ||||
return getPropertyId() != null && getPropertyId().equals(propertyId); | return getPropertyId() != null && getPropertyId().equals(propertyId); | ||||
} | } |
return filter; | return filter; | ||||
} | } | ||||
@Override | |||||
public boolean passesFilter(Object itemId, Item item) | public boolean passesFilter(Object itemId, Item item) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
return !filter.passesFilter(itemId, item); | return !filter.passesFilter(itemId, item); | ||||
* | * | ||||
* @return boolean | * @return boolean | ||||
*/ | */ | ||||
@Override | |||||
public boolean appliesToProperty(Object propertyId) { | public boolean appliesToProperty(Object propertyId) { | ||||
return filter.appliesToProperty(propertyId); | return filter.appliesToProperty(propertyId); | ||||
} | } |
super(filters); | super(filters); | ||||
} | } | ||||
@Override | |||||
public boolean passesFilter(Object itemId, Item item) | public boolean passesFilter(Object itemId, Item item) | ||||
throws UnsupportedFilterException { | throws UnsupportedFilterException { | ||||
for (Filter filter : getFilters()) { | for (Filter filter : getFilters()) { |
this.onlyMatchPrefix = onlyMatchPrefix; | this.onlyMatchPrefix = onlyMatchPrefix; | ||||
} | } | ||||
@Override | |||||
public boolean passesFilter(Object itemId, Item item) { | public boolean passesFilter(Object itemId, Item item) { | ||||
final Property<?> p = item.getItemProperty(propertyId); | final Property<?> p = item.getItemProperty(propertyId); | ||||
if (p == null) { | if (p == null) { | ||||
return true; | return true; | ||||
} | } | ||||
@Override | |||||
public boolean appliesToProperty(Object propertyId) { | public boolean appliesToProperty(Object propertyId) { | ||||
return this.propertyId.equals(propertyId); | return this.propertyId.equals(propertyId); | ||||
} | } |
this.readOnly = readOnly; | this.readOnly = readOnly; | ||||
} | } | ||||
@Override | |||||
public Object getValue() { | public Object getValue() { | ||||
if (isModified()) { | if (isModified()) { | ||||
return changedValue; | return changedValue; | ||||
return value; | return value; | ||||
} | } | ||||
@Override | |||||
public void setValue(Object newValue) throws ReadOnlyException { | public void setValue(Object newValue) throws ReadOnlyException { | ||||
if (newValue == null && !nullable) { | if (newValue == null && !nullable) { | ||||
throw new NotNullableException( | throw new NotNullableException( | ||||
|| newValue.equals(referenceValue); | || newValue.equals(referenceValue); | ||||
} | } | ||||
@Override | |||||
public Class<?> getType() { | public Class<?> getType() { | ||||
return type; | return type; | ||||
} | } | ||||
@Override | |||||
public boolean isReadOnly() { | public boolean isReadOnly() { | ||||
return readOnly; | return readOnly; | ||||
} | } | ||||
return allowReadOnlyChange; | return allowReadOnlyChange; | ||||
} | } | ||||
@Override | |||||
public void setReadOnly(boolean newStatus) { | public void setReadOnly(boolean newStatus) { | ||||
if (allowReadOnlyChange) { | if (allowReadOnlyChange) { | ||||
readOnly = newStatus; | readOnly = newStatus; |
this.id = id; | this.id = id; | ||||
} | } | ||||
@Override | |||||
public Property<?> getItemProperty(Object id) { | public Property<?> getItemProperty(Object id) { | ||||
if (id instanceof String && id != null) { | if (id instanceof String && id != null) { | ||||
for (ColumnProperty cp : properties) { | for (ColumnProperty cp : properties) { | ||||
return null; | return null; | ||||
} | } | ||||
@Override | |||||
public Collection<?> getItemPropertyIds() { | public Collection<?> getItemPropertyIds() { | ||||
Collection<String> ids = new ArrayList<String>(properties.size()); | Collection<String> ids = new ArrayList<String>(properties.size()); | ||||
for (ColumnProperty cp : properties) { | for (ColumnProperty cp : properties) { | ||||
* Adding properties is not supported. Properties are generated by | * Adding properties is not supported. Properties are generated by | ||||
* SQLContainer. | * SQLContainer. | ||||
*/ | */ | ||||
@Override | |||||
public boolean addItemProperty(Object id, Property property) | public boolean addItemProperty(Object id, Property property) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* Removing properties is not supported. Properties are generated by | * Removing properties is not supported. Properties are generated by | ||||
* SQLContainer. | * SQLContainer. | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItemProperty(Object id) | public boolean removeItemProperty(Object id) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); |
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
@Override | |||||
public Object addItem() throws UnsupportedOperationException { | public Object addItem() throws UnsupportedOperationException { | ||||
Object emptyKey[] = new Object[delegate.getPrimaryKeyColumns().size()]; | Object emptyKey[] = new Object[delegate.getPrimaryKeyColumns().size()]; | ||||
RowId itemId = new TemporaryRowId(emptyKey); | RowId itemId = new TemporaryRowId(emptyKey); | ||||
* @see com.vaadin.data.Container#containsId(java.lang.Object) | * @see com.vaadin.data.Container#containsId(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean containsId(Object itemId) { | public boolean containsId(Object itemId) { | ||||
if (itemId == null) { | if (itemId == null) { | ||||
return false; | return false; | ||||
* java.lang.Object) | * java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | public Property<?> getContainerProperty(Object itemId, Object propertyId) { | ||||
Item item = getItem(itemId); | Item item = getItem(itemId); | ||||
if (item == null) { | if (item == null) { | ||||
* @see com.vaadin.data.Container#getContainerPropertyIds() | * @see com.vaadin.data.Container#getContainerPropertyIds() | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getContainerPropertyIds() { | public Collection<?> getContainerPropertyIds() { | ||||
return Collections.unmodifiableCollection(propertyIds); | return Collections.unmodifiableCollection(propertyIds); | ||||
} | } | ||||
* @see com.vaadin.data.Container#getItem(java.lang.Object) | * @see com.vaadin.data.Container#getItem(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Item getItem(Object itemId) { | public Item getItem(Object itemId) { | ||||
if (!cachedItems.containsKey(itemId)) { | if (!cachedItems.containsKey(itemId)) { | ||||
int index = indexOfId(itemId); | int index = indexOfId(itemId); | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getItemIds() { | public Collection<?> getItemIds() { | ||||
updateCount(); | updateCount(); | ||||
ArrayList<RowId> ids = new ArrayList<RowId>(); | ArrayList<RowId> ids = new ArrayList<RowId>(); | ||||
* @see com.vaadin.data.Container#getType(java.lang.Object) | * @see com.vaadin.data.Container#getType(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Class<?> getType(Object propertyId) { | public Class<?> getType(Object propertyId) { | ||||
if (!propertyIds.contains(propertyId)) { | if (!propertyIds.contains(propertyId)) { | ||||
return null; | return null; | ||||
* @see com.vaadin.data.Container#size() | * @see com.vaadin.data.Container#size() | ||||
*/ | */ | ||||
@Override | |||||
public int size() { | public int size() { | ||||
updateCount(); | updateCount(); | ||||
return size + sizeOfAddedItems() - removedItems.size(); | return size + sizeOfAddedItems() - removedItems.size(); | ||||
* @see com.vaadin.data.Container#removeItem(java.lang.Object) | * @see com.vaadin.data.Container#removeItem(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeItem(Object itemId) | public boolean removeItem(Object itemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
if (!containsId(itemId)) { | if (!containsId(itemId)) { | ||||
* @see com.vaadin.data.Container#removeAllItems() | * @see com.vaadin.data.Container#removeAllItems() | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeAllItems() throws UnsupportedOperationException { | public boolean removeAllItems() throws UnsupportedOperationException { | ||||
if (autoCommit) { | if (autoCommit) { | ||||
/* Remove and commit instantly. */ | /* Remove and commit instantly. */ | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
@Override | |||||
public void addContainerFilter(Filter filter) | public void addContainerFilter(Filter filter) | ||||
throws UnsupportedFilterException { | throws UnsupportedFilterException { | ||||
// filter.setCaseSensitive(!ignoreCase); | // filter.setCaseSensitive(!ignoreCase); | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
@Override | |||||
public void removeContainerFilter(Filter filter) { | public void removeContainerFilter(Filter filter) { | ||||
filters.remove(filter); | filters.remove(filter); | ||||
} | } | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
@Override | |||||
public void removeAllContainerFilters() { | public void removeAllContainerFilters() { | ||||
filters.clear(); | filters.clear(); | ||||
refresh(); | refresh(); | ||||
* @see com.vaadin.data.Container.Indexed#indexOfId(java.lang.Object) | * @see com.vaadin.data.Container.Indexed#indexOfId(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public int indexOfId(Object itemId) { | public int indexOfId(Object itemId) { | ||||
// First check if the id is in the added items | // First check if the id is in the added items | ||||
for (int ix = 0; ix < addedItems.size(); ix++) { | for (int ix = 0; ix < addedItems.size(); ix++) { | ||||
* @see com.vaadin.data.Container.Indexed#getIdByIndex(int) | * @see com.vaadin.data.Container.Indexed#getIdByIndex(int) | ||||
*/ | */ | ||||
@Override | |||||
public Object getIdByIndex(int index) { | public Object getIdByIndex(int index) { | ||||
if (index < 0 || index > size() - 1) { | if (index < 0 || index > size() - 1) { | ||||
return null; | return null; | ||||
* @see com.vaadin.data.Container.Ordered#nextItemId(java.lang.Object) | * @see com.vaadin.data.Container.Ordered#nextItemId(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Object nextItemId(Object itemId) { | public Object nextItemId(Object itemId) { | ||||
return getIdByIndex(indexOfId(itemId) + 1); | return getIdByIndex(indexOfId(itemId) + 1); | ||||
} | } | ||||
* @see com.vaadin.data.Container.Ordered#prevItemId(java.lang.Object) | * @see com.vaadin.data.Container.Ordered#prevItemId(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Object prevItemId(Object itemId) { | public Object prevItemId(Object itemId) { | ||||
return getIdByIndex(indexOfId(itemId) - 1); | return getIdByIndex(indexOfId(itemId) - 1); | ||||
} | } | ||||
* @see com.vaadin.data.Container.Ordered#firstItemId() | * @see com.vaadin.data.Container.Ordered#firstItemId() | ||||
*/ | */ | ||||
@Override | |||||
public Object firstItemId() { | public Object firstItemId() { | ||||
updateCount(); | updateCount(); | ||||
if (size == 0) { | if (size == 0) { | ||||
* @see com.vaadin.data.Container.Ordered#lastItemId() | * @see com.vaadin.data.Container.Ordered#lastItemId() | ||||
*/ | */ | ||||
@Override | |||||
public Object lastItemId() { | public Object lastItemId() { | ||||
if (addedItems.isEmpty()) { | if (addedItems.isEmpty()) { | ||||
int lastIx = size() - 1; | int lastIx = size() - 1; | ||||
* @see com.vaadin.data.Container.Ordered#isFirstId(java.lang.Object) | * @see com.vaadin.data.Container.Ordered#isFirstId(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean isFirstId(Object itemId) { | public boolean isFirstId(Object itemId) { | ||||
return firstItemId().equals(itemId); | return firstItemId().equals(itemId); | ||||
} | } | ||||
* @see com.vaadin.data.Container.Ordered#isLastId(java.lang.Object) | * @see com.vaadin.data.Container.Ordered#isLastId(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean isLastId(Object itemId) { | public boolean isLastId(Object itemId) { | ||||
return lastItemId().equals(itemId); | return lastItemId().equals(itemId); | ||||
} | } | ||||
* boolean[]) | * boolean[]) | ||||
*/ | */ | ||||
@Override | |||||
public void sort(Object[] propertyId, boolean[] ascending) { | public void sort(Object[] propertyId, boolean[] ascending) { | ||||
sorters.clear(); | sorters.clear(); | ||||
if (propertyId == null || propertyId.length == 0) { | if (propertyId == null || propertyId.length == 0) { | ||||
* @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds() | * @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds() | ||||
*/ | */ | ||||
@Override | |||||
public Collection<?> getSortableContainerPropertyIds() { | public Collection<?> getSortableContainerPropertyIds() { | ||||
return getContainerPropertyIds(); | return getContainerPropertyIds(); | ||||
} | } | ||||
* java.lang.Class, java.lang.Object) | * java.lang.Class, java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean addContainerProperty(Object propertyId, Class<?> type, | public boolean addContainerProperty(Object propertyId, Class<?> type, | ||||
Object defaultValue) throws UnsupportedOperationException { | Object defaultValue) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* @see com.vaadin.data.Container#removeContainerProperty(java.lang.Object) | * @see com.vaadin.data.Container#removeContainerProperty(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeContainerProperty(Object propertyId) | public boolean removeContainerProperty(Object propertyId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* @see com.vaadin.data.Container#addItem(java.lang.Object) | * @see com.vaadin.data.Container#addItem(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Item addItem(Object itemId) throws UnsupportedOperationException { | public Item addItem(Object itemId) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
* java.lang.Object) | * java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Item addItemAfter(Object previousItemId, Object newItemId) | public Item addItemAfter(Object previousItemId, Object newItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* @see com.vaadin.data.Container.Indexed#addItemAt(int, java.lang.Object) | * @see com.vaadin.data.Container.Indexed#addItemAt(int, java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Item addItemAt(int index, Object newItemId) | public Item addItemAt(int index, Object newItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* @see com.vaadin.data.Container.Indexed#addItemAt(int) | * @see com.vaadin.data.Container.Indexed#addItemAt(int) | ||||
*/ | */ | ||||
@Override | |||||
public Object addItemAt(int index) throws UnsupportedOperationException { | public Object addItemAt(int index) throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
* @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object) | * @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public Object addItemAfter(Object previousItemId) | public Object addItemAfter(Object previousItemId) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
* .data.Container.ItemSetChangeListener) | * .data.Container.ItemSetChangeListener) | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Container.ItemSetChangeListener listener) { | public void addListener(Container.ItemSetChangeListener listener) { | ||||
if (itemSetChangeListeners == null) { | if (itemSetChangeListeners == null) { | ||||
itemSetChangeListeners = new LinkedList<Container.ItemSetChangeListener>(); | itemSetChangeListeners = new LinkedList<Container.ItemSetChangeListener>(); | ||||
* .data.Container.ItemSetChangeListener) | * .data.Container.ItemSetChangeListener) | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Container.ItemSetChangeListener listener) { | public void removeListener(Container.ItemSetChangeListener listener) { | ||||
if (itemSetChangeListeners != null) { | if (itemSetChangeListeners != null) { | ||||
itemSetChangeListeners.remove(listener); | itemSetChangeListeners.remove(listener); | ||||
super(source); | super(source); | ||||
} | } | ||||
@Override | |||||
public Container getContainer() { | public Container getContainer() { | ||||
return (Container) getSource(); | return (Container) getSource(); | ||||
} | } |
this.dataSourceJndiName = dataSourceJndiName; | this.dataSourceJndiName = dataSourceJndiName; | ||||
} | } | ||||
@Override | |||||
public Connection reserveConnection() throws SQLException { | public Connection reserveConnection() throws SQLException { | ||||
Connection conn = getDataSource().getConnection(); | Connection conn = getDataSource().getConnection(); | ||||
conn.setAutoCommit(false); | conn.setAutoCommit(false); | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void releaseConnection(Connection conn) { | public void releaseConnection(Connection conn) { | ||||
if (conn != null) { | if (conn != null) { | ||||
try { | try { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void destroy() { | public void destroy() { | ||||
dataSource = null; | dataSource = null; | ||||
} | } |
initialized = true; | initialized = true; | ||||
} | } | ||||
@Override | |||||
public synchronized Connection reserveConnection() throws SQLException { | public synchronized Connection reserveConnection() throws SQLException { | ||||
if (!initialized) { | if (!initialized) { | ||||
initializeConnections(); | initializeConnections(); | ||||
return c; | return c; | ||||
} | } | ||||
@Override | |||||
public synchronized void releaseConnection(Connection conn) { | public synchronized void releaseConnection(Connection conn) { | ||||
if (conn == null || !initialized) { | if (conn == null || !initialized) { | ||||
return; | return; | ||||
return c; | return c; | ||||
} | } | ||||
@Override | |||||
public void destroy() { | public void destroy() { | ||||
for (Connection c : availableConnections) { | for (Connection c : availableConnections) { | ||||
try { | try { |
* | * | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
@Override | |||||
public int getCount() throws SQLException { | public int getCount() throws SQLException { | ||||
// First try the delegate | // First try the delegate | ||||
int count = countByDelegate(); | int count = countByDelegate(); | ||||
* | * | ||||
* @see FreeformQueryDelegate#getQueryString(int, int) | * @see FreeformQueryDelegate#getQueryString(int, int) | ||||
*/ | */ | ||||
@Override | |||||
@SuppressWarnings("deprecation") | @SuppressWarnings("deprecation") | ||||
public ResultSet getResults(int offset, int pagelength) throws SQLException { | public ResultSet getResults(int offset, int pagelength) throws SQLException { | ||||
if (activeConnection == null) { | if (activeConnection == null) { | ||||
return rs; | return rs; | ||||
} | } | ||||
@Override | |||||
@SuppressWarnings("deprecation") | @SuppressWarnings("deprecation") | ||||
public boolean implementationRespectsPagingLimits() { | public boolean implementationRespectsPagingLimits() { | ||||
if (delegate == null) { | if (delegate == null) { | ||||
* com.vaadin.data.util.sqlcontainer.query.QueryDelegate#setFilters(java | * com.vaadin.data.util.sqlcontainer.query.QueryDelegate#setFilters(java | ||||
* .util.List) | * .util.List) | ||||
*/ | */ | ||||
@Override | |||||
public void setFilters(List<Filter> filters) | public void setFilters(List<Filter> filters) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
if (delegate != null) { | if (delegate != null) { | ||||
* com.vaadin.data.util.sqlcontainer.query.QueryDelegate#setOrderBy(java | * com.vaadin.data.util.sqlcontainer.query.QueryDelegate#setOrderBy(java | ||||
* .util.List) | * .util.List) | ||||
*/ | */ | ||||
@Override | |||||
public void setOrderBy(List<OrderBy> orderBys) | public void setOrderBy(List<OrderBy> orderBys) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
if (delegate != null) { | if (delegate != null) { | ||||
* com.vaadin.data.util.sqlcontainer.query.QueryDelegate#storeRow(com.vaadin | * com.vaadin.data.util.sqlcontainer.query.QueryDelegate#storeRow(com.vaadin | ||||
* .data.util.sqlcontainer.RowItem) | * .data.util.sqlcontainer.RowItem) | ||||
*/ | */ | ||||
@Override | |||||
public int storeRow(RowItem row) throws SQLException { | public int storeRow(RowItem row) throws SQLException { | ||||
if (activeConnection == null) { | if (activeConnection == null) { | ||||
throw new IllegalStateException("No transaction is active!"); | throw new IllegalStateException("No transaction is active!"); | ||||
* com.vaadin.data.util.sqlcontainer.query.QueryDelegate#removeRow(com.vaadin | * com.vaadin.data.util.sqlcontainer.query.QueryDelegate#removeRow(com.vaadin | ||||
* .data.util.sqlcontainer.RowItem) | * .data.util.sqlcontainer.RowItem) | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeRow(RowItem row) throws SQLException { | public boolean removeRow(RowItem row) throws SQLException { | ||||
if (activeConnection == null) { | if (activeConnection == null) { | ||||
throw new IllegalStateException("No transaction is active!"); | throw new IllegalStateException("No transaction is active!"); | ||||
* @see | * @see | ||||
* com.vaadin.data.util.sqlcontainer.query.QueryDelegate#beginTransaction() | * com.vaadin.data.util.sqlcontainer.query.QueryDelegate#beginTransaction() | ||||
*/ | */ | ||||
@Override | |||||
public synchronized void beginTransaction() | public synchronized void beginTransaction() | ||||
throws UnsupportedOperationException, SQLException { | throws UnsupportedOperationException, SQLException { | ||||
if (activeConnection != null) { | if (activeConnection != null) { | ||||
* | * | ||||
* @see com.vaadin.data.util.sqlcontainer.query.QueryDelegate#commit() | * @see com.vaadin.data.util.sqlcontainer.query.QueryDelegate#commit() | ||||
*/ | */ | ||||
@Override | |||||
public synchronized void commit() throws UnsupportedOperationException, | public synchronized void commit() throws UnsupportedOperationException, | ||||
SQLException { | SQLException { | ||||
if (activeConnection == null) { | if (activeConnection == null) { | ||||
* | * | ||||
* @see com.vaadin.data.util.sqlcontainer.query.QueryDelegate#rollback() | * @see com.vaadin.data.util.sqlcontainer.query.QueryDelegate#rollback() | ||||
*/ | */ | ||||
@Override | |||||
public synchronized void rollback() throws UnsupportedOperationException, | public synchronized void rollback() throws UnsupportedOperationException, | ||||
SQLException { | SQLException { | ||||
if (activeConnection == null) { | if (activeConnection == null) { | ||||
* com.vaadin.data.util.sqlcontainer.query.QueryDelegate#getPrimaryKeyColumns | * com.vaadin.data.util.sqlcontainer.query.QueryDelegate#getPrimaryKeyColumns | ||||
* () | * () | ||||
*/ | */ | ||||
@Override | |||||
public List<String> getPrimaryKeyColumns() { | public List<String> getPrimaryKeyColumns() { | ||||
return primaryKeyColumns; | return primaryKeyColumns; | ||||
} | } | ||||
* @see FreeformQueryDelegate#getContainsRowQueryString(Object...) | * @see FreeformQueryDelegate#getContainsRowQueryString(Object...) | ||||
* | * | ||||
*/ | */ | ||||
@Override | |||||
@SuppressWarnings("deprecation") | @SuppressWarnings("deprecation") | ||||
public boolean containsRowWithKey(Object... keys) throws SQLException { | public boolean containsRowWithKey(Object... keys) throws SQLException { | ||||
String query = null; | String query = null; |
* | * | ||||
* @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#getCount() | * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#getCount() | ||||
*/ | */ | ||||
@Override | |||||
public int getCount() throws SQLException { | public int getCount() throws SQLException { | ||||
getLogger().log(Level.FINE, "Fetching count..."); | getLogger().log(Level.FINE, "Fetching count..."); | ||||
StatementHelper sh = sqlGenerator.generateSelectQuery(tableName, | StatementHelper sh = sqlGenerator.generateSelectQuery(tableName, | ||||
* @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#getResults(int, | * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#getResults(int, | ||||
* int) | * int) | ||||
*/ | */ | ||||
@Override | |||||
public ResultSet getResults(int offset, int pagelength) throws SQLException { | public ResultSet getResults(int offset, int pagelength) throws SQLException { | ||||
StatementHelper sh; | StatementHelper sh; | ||||
/* | /* | ||||
* @see com.vaadin.addon.sqlcontainer.query.QueryDelegate# | * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate# | ||||
* implementationRespectsPagingLimits() | * implementationRespectsPagingLimits() | ||||
*/ | */ | ||||
@Override | |||||
public boolean implementationRespectsPagingLimits() { | public boolean implementationRespectsPagingLimits() { | ||||
return true; | return true; | ||||
} | } | ||||
* com.vaadin.addon.sqlcontainer.query.QueryDelegate#storeRow(com.vaadin | * com.vaadin.addon.sqlcontainer.query.QueryDelegate#storeRow(com.vaadin | ||||
* .addon.sqlcontainer.RowItem) | * .addon.sqlcontainer.RowItem) | ||||
*/ | */ | ||||
@Override | |||||
public int storeRow(RowItem row) throws UnsupportedOperationException, | public int storeRow(RowItem row) throws UnsupportedOperationException, | ||||
SQLException { | SQLException { | ||||
if (row == null) { | if (row == null) { | ||||
* com.vaadin.addon.sqlcontainer.query.QueryDelegate#setFilters(java.util | * com.vaadin.addon.sqlcontainer.query.QueryDelegate#setFilters(java.util | ||||
* .List) | * .List) | ||||
*/ | */ | ||||
@Override | |||||
public void setFilters(List<Filter> filters) | public void setFilters(List<Filter> filters) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
if (filters == null) { | if (filters == null) { | ||||
* com.vaadin.addon.sqlcontainer.query.QueryDelegate#setOrderBy(java.util | * com.vaadin.addon.sqlcontainer.query.QueryDelegate#setOrderBy(java.util | ||||
* .List) | * .List) | ||||
*/ | */ | ||||
@Override | |||||
public void setOrderBy(List<OrderBy> orderBys) | public void setOrderBy(List<OrderBy> orderBys) | ||||
throws UnsupportedOperationException { | throws UnsupportedOperationException { | ||||
if (orderBys == null) { | if (orderBys == null) { | ||||
* | * | ||||
* @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#beginTransaction() | * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#beginTransaction() | ||||
*/ | */ | ||||
@Override | |||||
public void beginTransaction() throws UnsupportedOperationException, | public void beginTransaction() throws UnsupportedOperationException, | ||||
SQLException { | SQLException { | ||||
if (transactionOpen && activeConnection != null) { | if (transactionOpen && activeConnection != null) { | ||||
* | * | ||||
* @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#commit() | * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#commit() | ||||
*/ | */ | ||||
@Override | |||||
public void commit() throws UnsupportedOperationException, SQLException { | public void commit() throws UnsupportedOperationException, SQLException { | ||||
if (transactionOpen && activeConnection != null) { | if (transactionOpen && activeConnection != null) { | ||||
getLogger().log(Level.FINE, "DB -> commit"); | getLogger().log(Level.FINE, "DB -> commit"); | ||||
* | * | ||||
* @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#rollback() | * @see com.vaadin.addon.sqlcontainer.query.QueryDelegate#rollback() | ||||
*/ | */ | ||||
@Override | |||||
public void rollback() throws UnsupportedOperationException, SQLException { | public void rollback() throws UnsupportedOperationException, SQLException { | ||||
if (transactionOpen && activeConnection != null) { | if (transactionOpen && activeConnection != null) { | ||||
getLogger().log(Level.FINE, "DB -> rollback"); | getLogger().log(Level.FINE, "DB -> rollback"); | ||||
* @see | * @see | ||||
* com.vaadin.addon.sqlcontainer.query.QueryDelegate#getPrimaryKeyColumns() | * com.vaadin.addon.sqlcontainer.query.QueryDelegate#getPrimaryKeyColumns() | ||||
*/ | */ | ||||
@Override | |||||
public List<String> getPrimaryKeyColumns() { | public List<String> getPrimaryKeyColumns() { | ||||
return Collections.unmodifiableList(primaryKeyColumns); | return Collections.unmodifiableList(primaryKeyColumns); | ||||
} | } | ||||
* com.vaadin.addon.sqlcontainer.query.QueryDelegate#removeRow(com.vaadin | * com.vaadin.addon.sqlcontainer.query.QueryDelegate#removeRow(com.vaadin | ||||
* .addon.sqlcontainer.RowItem) | * .addon.sqlcontainer.RowItem) | ||||
*/ | */ | ||||
@Override | |||||
public boolean removeRow(RowItem row) throws UnsupportedOperationException, | public boolean removeRow(RowItem row) throws UnsupportedOperationException, | ||||
SQLException { | SQLException { | ||||
getLogger().log(Level.FINE, | getLogger().log(Level.FINE, | ||||
* com.vaadin.addon.sqlcontainer.query.QueryDelegate#containsRowWithKey( | * com.vaadin.addon.sqlcontainer.query.QueryDelegate#containsRowWithKey( | ||||
* java.lang.Object[]) | * java.lang.Object[]) | ||||
*/ | */ | ||||
@Override | |||||
public boolean containsRowWithKey(Object... keys) throws SQLException { | public boolean containsRowWithKey(Object... keys) throws SQLException { | ||||
ArrayList<Filter> filtersAndKeys = new ArrayList<Filter>(); | ArrayList<Filter> filtersAndKeys = new ArrayList<Filter>(); | ||||
if (filters != null) { | if (filters != null) { | ||||
this.newId = newId; | this.newId = newId; | ||||
} | } | ||||
@Override | |||||
public RowId getNewRowId() { | public RowId getNewRowId() { | ||||
return newId; | return newId; | ||||
} | } | ||||
@Override | |||||
public RowId getOldRowId() { | public RowId getOldRowId() { | ||||
return oldId; | return oldId; | ||||
} | } | ||||
/** | /** | ||||
* Adds RowIdChangeListener to this query | * Adds RowIdChangeListener to this query | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(RowIdChangeListener listener) { | public void addListener(RowIdChangeListener listener) { | ||||
if (rowIdChangeListeners == null) { | if (rowIdChangeListeners == null) { | ||||
rowIdChangeListeners = new LinkedList<QueryDelegate.RowIdChangeListener>(); | rowIdChangeListeners = new LinkedList<QueryDelegate.RowIdChangeListener>(); | ||||
/** | /** | ||||
* Removes the given RowIdChangeListener from this query | * Removes the given RowIdChangeListener from this query | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(RowIdChangeListener listener) { | public void removeListener(RowIdChangeListener listener) { | ||||
if (rowIdChangeListeners != null) { | if (rowIdChangeListeners != null) { | ||||
rowIdChangeListeners.remove(listener); | rowIdChangeListeners.remove(listener); |
* generateSelectQuery(java.lang.String, java.util.List, java.util.List, | * generateSelectQuery(java.lang.String, java.util.List, java.util.List, | ||||
* int, int, java.lang.String) | * int, int, java.lang.String) | ||||
*/ | */ | ||||
@Override | |||||
public StatementHelper generateSelectQuery(String tableName, | public StatementHelper generateSelectQuery(String tableName, | ||||
List<Filter> filters, List<OrderBy> orderBys, int offset, | List<Filter> filters, List<OrderBy> orderBys, int offset, | ||||
int pagelength, String toSelect) { | int pagelength, String toSelect) { | ||||
* generateUpdateQuery(java.lang.String, | * generateUpdateQuery(java.lang.String, | ||||
* com.vaadin.addon.sqlcontainer.RowItem) | * com.vaadin.addon.sqlcontainer.RowItem) | ||||
*/ | */ | ||||
@Override | |||||
public StatementHelper generateUpdateQuery(String tableName, RowItem item) { | public StatementHelper generateUpdateQuery(String tableName, RowItem item) { | ||||
if (tableName == null || tableName.trim().equals("")) { | if (tableName == null || tableName.trim().equals("")) { | ||||
throw new IllegalArgumentException("Table name must be given."); | throw new IllegalArgumentException("Table name must be given."); | ||||
* generateInsertQuery(java.lang.String, | * generateInsertQuery(java.lang.String, | ||||
* com.vaadin.addon.sqlcontainer.RowItem) | * com.vaadin.addon.sqlcontainer.RowItem) | ||||
*/ | */ | ||||
@Override | |||||
public StatementHelper generateInsertQuery(String tableName, RowItem item) { | public StatementHelper generateInsertQuery(String tableName, RowItem item) { | ||||
if (tableName == null || tableName.trim().equals("")) { | if (tableName == null || tableName.trim().equals("")) { | ||||
throw new IllegalArgumentException("Table name must be given."); | throw new IllegalArgumentException("Table name must be given."); | ||||
* generateDeleteQuery(java.lang.String, | * generateDeleteQuery(java.lang.String, | ||||
* com.vaadin.addon.sqlcontainer.RowItem) | * com.vaadin.addon.sqlcontainer.RowItem) | ||||
*/ | */ | ||||
@Override | |||||
public StatementHelper generateDeleteQuery(String tableName, | public StatementHelper generateDeleteQuery(String tableName, | ||||
List<String> primaryKeyColumns, String versionColumn, RowItem item) { | List<String> primaryKeyColumns, String versionColumn, RowItem item) { | ||||
if (tableName == null || tableName.trim().equals("")) { | if (tableName == null || tableName.trim().equals("")) { |
public class AndTranslator implements FilterTranslator { | public class AndTranslator implements FilterTranslator { | ||||
@Override | |||||
public boolean translatesFilter(Filter filter) { | public boolean translatesFilter(Filter filter) { | ||||
return filter instanceof And; | return filter instanceof And; | ||||
} | } | ||||
@Override | |||||
public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | ||||
return QueryBuilder.group(QueryBuilder.getJoinedFilterString( | return QueryBuilder.group(QueryBuilder.getJoinedFilterString( | ||||
((And) filter).getFilters(), "AND", sh)); | ((And) filter).getFilters(), "AND", sh)); |
public class BetweenTranslator implements FilterTranslator { | public class BetweenTranslator implements FilterTranslator { | ||||
@Override | |||||
public boolean translatesFilter(Filter filter) { | public boolean translatesFilter(Filter filter) { | ||||
return filter instanceof Between; | return filter instanceof Between; | ||||
} | } | ||||
@Override | |||||
public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | ||||
Between between = (Between) filter; | Between between = (Between) filter; | ||||
sh.addParameterValue(between.getStartValue()); | sh.addParameterValue(between.getStartValue()); |
public class CompareTranslator implements FilterTranslator { | public class CompareTranslator implements FilterTranslator { | ||||
@Override | |||||
public boolean translatesFilter(Filter filter) { | public boolean translatesFilter(Filter filter) { | ||||
return filter instanceof Compare; | return filter instanceof Compare; | ||||
} | } | ||||
@Override | |||||
public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | ||||
Compare compare = (Compare) filter; | Compare compare = (Compare) filter; | ||||
sh.addParameterValue(compare.getValue()); | sh.addParameterValue(compare.getValue()); |
public class IsNullTranslator implements FilterTranslator { | public class IsNullTranslator implements FilterTranslator { | ||||
@Override | |||||
public boolean translatesFilter(Filter filter) { | public boolean translatesFilter(Filter filter) { | ||||
return filter instanceof IsNull; | return filter instanceof IsNull; | ||||
} | } | ||||
@Override | |||||
public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | ||||
IsNull in = (IsNull) filter; | IsNull in = (IsNull) filter; | ||||
return QueryBuilder.quote(in.getPropertyId()) + " IS NULL"; | return QueryBuilder.quote(in.getPropertyId()) + " IS NULL"; |
public class LikeTranslator implements FilterTranslator { | public class LikeTranslator implements FilterTranslator { | ||||
@Override | |||||
public boolean translatesFilter(Filter filter) { | public boolean translatesFilter(Filter filter) { | ||||
return filter instanceof Like; | return filter instanceof Like; | ||||
} | } | ||||
@Override | |||||
public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | ||||
Like like = (Like) filter; | Like like = (Like) filter; | ||||
if (like.isCaseSensitive()) { | if (like.isCaseSensitive()) { |
public class NotTranslator implements FilterTranslator { | public class NotTranslator implements FilterTranslator { | ||||
@Override | |||||
public boolean translatesFilter(Filter filter) { | public boolean translatesFilter(Filter filter) { | ||||
return filter instanceof Not; | return filter instanceof Not; | ||||
} | } | ||||
@Override | |||||
public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | ||||
Not not = (Not) filter; | Not not = (Not) filter; | ||||
if (not.getFilter() instanceof IsNull) { | if (not.getFilter() instanceof IsNull) { |
public class OrTranslator implements FilterTranslator { | public class OrTranslator implements FilterTranslator { | ||||
@Override | |||||
public boolean translatesFilter(Filter filter) { | public boolean translatesFilter(Filter filter) { | ||||
return filter instanceof Or; | return filter instanceof Or; | ||||
} | } | ||||
@Override | |||||
public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | ||||
return QueryBuilder.group(QueryBuilder.getJoinedFilterString( | return QueryBuilder.group(QueryBuilder.getJoinedFilterString( | ||||
((Or) filter).getFilters(), "OR", sh)); | ((Or) filter).getFilters(), "OR", sh)); |
public class SimpleStringTranslator implements FilterTranslator { | public class SimpleStringTranslator implements FilterTranslator { | ||||
@Override | |||||
public boolean translatesFilter(Filter filter) { | public boolean translatesFilter(Filter filter) { | ||||
return filter instanceof SimpleStringFilter; | return filter instanceof SimpleStringFilter; | ||||
} | } | ||||
@Override | |||||
public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | public String getWhereStringForFilter(Filter filter, StatementHelper sh) { | ||||
SimpleStringFilter ssf = (SimpleStringFilter) filter; | SimpleStringFilter ssf = (SimpleStringFilter) filter; | ||||
// Create a Like filter based on the SimpleStringFilter and execute the | // Create a Like filter based on the SimpleStringFilter and execute the |
*/ | */ | ||||
protected abstract boolean isValidValue(T value); | protected abstract boolean isValidValue(T value); | ||||
@Override | |||||
public void validate(Object value) throws InvalidValueException { | public void validate(Object value) throws InvalidValueException { | ||||
// isValidType ensures that value can safely be cast to TYPE | // isValidType ensures that value can safely be cast to TYPE | ||||
if (!isValidType(value) || !isValidValue((T) value)) { | if (!isValidType(value) || !isValidValue((T) value)) { |
this.descriptor = descriptor; | this.descriptor = descriptor; | ||||
} | } | ||||
@Override | |||||
public ConstraintDescriptor<?> getConstraintDescriptor() { | public ConstraintDescriptor<?> getConstraintDescriptor() { | ||||
return descriptor; | return descriptor; | ||||
} | } | ||||
@Override | |||||
public Object getValidatedValue() { | public Object getValidatedValue() { | ||||
return value; | return value; | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.data.Validator#validate(java.lang.Object) | * @see com.vaadin.data.Validator#validate(java.lang.Object) | ||||
*/ | */ | ||||
@Override | |||||
public void validate(final Object value) throws InvalidValueException { | public void validate(final Object value) throws InvalidValueException { | ||||
Set<?> violations = getJavaxBeanValidator().validateValue(beanClass, | Set<?> violations = getJavaxBeanValidator().validateValue(beanClass, | ||||
propertyName, value); | propertyName, value); |
* @throws Validator.InvalidValueException | * @throws Validator.InvalidValueException | ||||
* if the value is not valid. | * if the value is not valid. | ||||
*/ | */ | ||||
@Override | |||||
public void validate(Object value) throws Validator.InvalidValueException { | public void validate(Object value) throws Validator.InvalidValueException { | ||||
switch (mode) { | switch (mode) { | ||||
case AND: | case AND: |
* @throws Validator.InvalidValueException | * @throws Validator.InvalidValueException | ||||
* if the value was invalid. | * if the value was invalid. | ||||
*/ | */ | ||||
@Override | |||||
public void validate(Object value) throws Validator.InvalidValueException { | public void validate(Object value) throws Validator.InvalidValueException { | ||||
if ((onlyNullAllowed && value != null) | if ((onlyNullAllowed && value != null) | ||||
|| (!onlyNullAllowed && value == null)) { | || (!onlyNullAllowed && value == null)) { |
requestRepaint(); // this goes to the new viewer | requestRepaint(); // this goes to the new viewer | ||||
} | } | ||||
@Override | |||||
public <T extends Action & Action.Listener> void addAction(T action) { | public <T extends Action & Action.Listener> void addAction(T action) { | ||||
if (ownActions == null) { | if (ownActions == null) { | ||||
ownActions = new HashSet<Action>(); | ownActions = new HashSet<Action>(); | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public <T extends Action & Action.Listener> void removeAction(T action) { | public <T extends Action & Action.Listener> void removeAction(T action) { | ||||
if (ownActions != null) { | if (ownActions != null) { | ||||
if (ownActions.remove(action)) { | if (ownActions.remove(action)) { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void addActionHandler(Handler actionHandler) { | public void addActionHandler(Handler actionHandler) { | ||||
if (actionHandler == this) { | if (actionHandler == this) { | ||||
// don't add the actionHandler to itself | // don't add the actionHandler to itself | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public void removeActionHandler(Action.Handler actionHandler) { | public void removeActionHandler(Action.Handler actionHandler) { | ||||
if (actionHandlers != null && actionHandlers.contains(actionHandler)) { | if (actionHandlers != null && actionHandlers.contains(actionHandler)) { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public Action[] getActions(Object target, Object sender) { | public Action[] getActions(Object target, Object sender) { | ||||
HashSet<Action> actions = new HashSet<Action>(); | HashSet<Action> actions = new HashSet<Action>(); | ||||
if (ownActions != null) { | if (ownActions != null) { | ||||
return actions.toArray(new Action[actions.size()]); | return actions.toArray(new Action[actions.size()]); | ||||
} | } | ||||
@Override | |||||
public void handleAction(Action action, Object sender, Object target) { | public void handleAction(Action action, Object sender, Object target) { | ||||
if (actionHandlers != null) { | if (actionHandlers != null) { | ||||
Handler[] array = actionHandlers.toArray(new Handler[actionHandlers | Handler[] array = actionHandlers.toArray(new Handler[actionHandlers |
* events generated by this component. Don't add a JavaDoc comment here, we | * events generated by this component. Don't add a JavaDoc comment here, we | ||||
* use the default documentation from implemented interface. | * use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Class<?> eventType, Object object, Method method) { | public void addListener(Class<?> eventType, Object object, Method method) { | ||||
if (listenerList == null) { | if (listenerList == null) { | ||||
listenerList = new LinkedHashSet<ListenerMethod>(); | listenerList = new LinkedHashSet<ListenerMethod>(); | ||||
* listen events generated by this component. Don't add a JavaDoc comment | * listen events generated by this component. Don't add a JavaDoc comment | ||||
* here, we use the default documentation from implemented interface. | * here, we use the default documentation from implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public void addListener(Class<?> eventType, Object object, String methodName) { | public void addListener(Class<?> eventType, Object object, String methodName) { | ||||
if (listenerList == null) { | if (listenerList == null) { | ||||
listenerList = new LinkedHashSet<ListenerMethod>(); | listenerList = new LinkedHashSet<ListenerMethod>(); | ||||
* a JavaDoc comment here, we use the default documentation from implemented | * a JavaDoc comment here, we use the default documentation from implemented | ||||
* interface. | * interface. | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Class<?> eventType, Object target) { | public void removeListener(Class<?> eventType, Object target) { | ||||
if (listenerList != null) { | if (listenerList != null) { | ||||
final Iterator<ListenerMethod> i = listenerList.iterator(); | final Iterator<ListenerMethod> i = listenerList.iterator(); | ||||
* Don't add a JavaDoc comment here, we use the default documentation from | * Don't add a JavaDoc comment here, we use the default documentation from | ||||
* implemented interface. | * implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Class<?> eventType, Object target, Method method) { | public void removeListener(Class<?> eventType, Object target, Method method) { | ||||
if (listenerList != null) { | if (listenerList != null) { | ||||
final Iterator<ListenerMethod> i = listenerList.iterator(); | final Iterator<ListenerMethod> i = listenerList.iterator(); | ||||
* Don't add a JavaDoc comment here, we use the default documentation from | * Don't add a JavaDoc comment here, we use the default documentation from | ||||
* implemented interface. | * implemented interface. | ||||
*/ | */ | ||||
@Override | |||||
public void removeListener(Class<?> eventType, Object target, | public void removeListener(Class<?> eventType, Object target, | ||||
String methodName) { | String methodName) { | ||||
protected abstract void fireEvent(Event event); | protected abstract void fireEvent(Event event); | ||||
@Override | |||||
public void blur() { | public void blur() { | ||||
fireEvent(new BlurEvent(component)); | fireEvent(new BlurEvent(component)); | ||||
} | } | ||||
@Override | |||||
public void focus() { | public void focus() { | ||||
fireEvent(new FocusEvent(component)); | fireEvent(new FocusEvent(component)); | ||||
} | } |
super(shorthandCaption); | super(shorthandCaption); | ||||
} | } | ||||
@Override | |||||
abstract public void handleAction(Object sender, Object target); | abstract public void handleAction(Object sender, Object target); | ||||
} | } |
this.rawVariables = rawVariables; | this.rawVariables = rawVariables; | ||||
} | } | ||||
@Override | |||||
public Component getSourceComponent() { | public Component getSourceComponent() { | ||||
return sourceComponent; | return sourceComponent; | ||||
} | } | ||||
@Override | |||||
public Object getData(String dataFlavor) { | public Object getData(String dataFlavor) { | ||||
return rawVariables.get(dataFlavor); | return rawVariables.get(dataFlavor); | ||||
} | } | ||||
@Override | |||||
public void setData(String dataFlavor, Object value) { | public void setData(String dataFlavor, Object value) { | ||||
rawVariables.put(dataFlavor, value); | rawVariables.put(dataFlavor, value); | ||||
} | } | ||||
@Override | |||||
public Collection<String> getDataFlavors() { | public Collection<String> getDataFlavors() { | ||||
return rawVariables.keySet(); | return rawVariables.keySet(); | ||||
} | } |
this.dropTarget = dropTarget; | this.dropTarget = dropTarget; | ||||
} | } | ||||
@Override | |||||
public Object getData(String key) { | public Object getData(String key) { | ||||
return data.get(key); | return data.get(key); | ||||
} | } | ||||
return data.put(key, value); | return data.put(key, value); | ||||
} | } | ||||
@Override | |||||
public DropTarget getTarget() { | public DropTarget getTarget() { | ||||
return dropTarget; | return dropTarget; | ||||
} | } |
return singleton; | return singleton; | ||||
} | } | ||||
@Override | |||||
public boolean accept(DragAndDropEvent dragEvent) { | public boolean accept(DragAndDropEvent dragEvent) { | ||||
return true; | return true; | ||||
} | } |
} | } | ||||
} | } | ||||
@Override | |||||
public boolean accept(DragAndDropEvent dragEvent) { | public boolean accept(DragAndDropEvent dragEvent) { | ||||
for (ClientSideCriterion crit : criteria) { | for (ClientSideCriterion crit : criteria) { | ||||
if (!crit.accept(dragEvent)) { | if (!crit.accept(dragEvent)) { |
* com.vaadin.event.dd.acceptCriteria.AcceptCriterion#isClientSideVerifiable | * com.vaadin.event.dd.acceptCriteria.AcceptCriterion#isClientSideVerifiable | ||||
* () | * () | ||||
*/ | */ | ||||
@Override | |||||
public final boolean isClientSideVerifiable() { | public final boolean isClientSideVerifiable() { | ||||
return true; | return true; | ||||
} | } | ||||
@Override | |||||
public void paint(PaintTarget target) throws PaintException { | public void paint(PaintTarget target) throws PaintException { | ||||
target.startTag("-ac"); | target.startTag("-ac"); | ||||
target.addAttribute("name", getIdentifier()); | target.addAttribute("name", getIdentifier()); | ||||
return getClass().getCanonicalName(); | return getClass().getCanonicalName(); | ||||
} | } | ||||
@Override | |||||
public final void paintResponse(PaintTarget target) throws PaintException { | public final void paintResponse(PaintTarget target) throws PaintException { | ||||
// NOP, nothing to do as this is client side verified criterion | // NOP, nothing to do as this is client side verified criterion | ||||
} | } |
target.addAttribute("p", dataFlavorId); | target.addAttribute("p", dataFlavorId); | ||||
} | } | ||||
@Override | |||||
public boolean accept(DragAndDropEvent dragEvent) { | public boolean accept(DragAndDropEvent dragEvent) { | ||||
return dragEvent.getTransferable().getDataFlavors() | return dragEvent.getTransferable().getDataFlavors() | ||||
.contains(dataFlavorId); | .contains(dataFlavorId); |
acceptCriterion.paint(target); | acceptCriterion.paint(target); | ||||
} | } | ||||
@Override | |||||
public boolean accept(DragAndDropEvent dragEvent) { | public boolean accept(DragAndDropEvent dragEvent) { | ||||
return !acceptCriterion.accept(dragEvent); | return !acceptCriterion.accept(dragEvent); | ||||
} | } |
} | } | ||||
} | } | ||||
@Override | |||||
public boolean accept(DragAndDropEvent dragEvent) { | public boolean accept(DragAndDropEvent dragEvent) { | ||||
for (AcceptCriterion crit : criteria) { | for (AcceptCriterion crit : criteria) { | ||||
if (crit.accept(dragEvent)) { | if (crit.accept(dragEvent)) { |
private static final long serialVersionUID = 2128510128911628902L; | private static final long serialVersionUID = 2128510128911628902L; | ||||
@Override | |||||
public final boolean isClientSideVerifiable() { | public final boolean isClientSideVerifiable() { | ||||
return false; | return false; | ||||
} | } | ||||
@Override | |||||
public void paint(PaintTarget target) throws PaintException { | public void paint(PaintTarget target) throws PaintException { | ||||
target.startTag("-ac"); | target.startTag("-ac"); | ||||
target.addAttribute("name", getIdentifier()); | target.addAttribute("name", getIdentifier()); | ||||
public void paintContent(PaintTarget target) { | public void paintContent(PaintTarget target) { | ||||
} | } | ||||
@Override | |||||
public void paintResponse(PaintTarget target) throws PaintException { | public void paintResponse(PaintTarget target) throws PaintException { | ||||
} | } | ||||
target.addAttribute("c", paintedComponents); | target.addAttribute("c", paintedComponents); | ||||
} | } | ||||
@Override | |||||
public boolean accept(DragAndDropEvent dragEvent) { | public boolean accept(DragAndDropEvent dragEvent) { | ||||
if (dragEvent.getTransferable() instanceof TransferableImpl) { | if (dragEvent.getTransferable() instanceof TransferableImpl) { | ||||
Component sourceComponent = ((TransferableImpl) dragEvent | Component sourceComponent = ((TransferableImpl) dragEvent |
private SourceIsTarget() { | private SourceIsTarget() { | ||||
} | } | ||||
@Override | |||||
public boolean accept(DragAndDropEvent dragEvent) { | public boolean accept(DragAndDropEvent dragEvent) { | ||||
if (dragEvent.getTransferable() instanceof TransferableImpl) { | if (dragEvent.getTransferable() instanceof TransferableImpl) { | ||||
Component sourceComponent = ((TransferableImpl) dragEvent | Component sourceComponent = ((TransferableImpl) dragEvent |
} | } | ||||
} | } | ||||
@Override | |||||
public boolean accept(DragAndDropEvent dragEvent) { | public boolean accept(DragAndDropEvent dragEvent) { | ||||
Object data = dragEvent.getTargetDetails().getData(propertyName); | Object data = dragEvent.getTargetDetails().getData(propertyName); | ||||
return value.equals(data); | return value.equals(data); |
this.cause = cause; | this.cause = cause; | ||||
} | } | ||||
@Override | |||||
public Throwable getCause() { | public Throwable getCause() { | ||||
return this.cause; | return this.cause; | ||||
} | } |
* | * | ||||
* @return The JSON text. | * @return The JSON text. | ||||
*/ | */ | ||||
@Override | |||||
public String toString() { | public String toString() { | ||||
return this.mode == 'd' ? this.writer.toString() : null; | return this.mode == 'd' ? this.writer.toString() : null; | ||||
} | } |
setHeight("0px"); | setHeight("0px"); | ||||
} | } | ||||
@Override | |||||
public void navigateTo(String fragmentParameters) { | public void navigateTo(String fragmentParameters) { | ||||
// nothing to do | // nothing to do | ||||
} | } | ||||
page.addListener(this); | page.addListener(this); | ||||
} | } | ||||
@Override | |||||
public String getFragment() { | public String getFragment() { | ||||
return page.getFragment(); | return page.getFragment(); | ||||
} | } | ||||
@Override | |||||
public void setFragment(String fragment) { | public void setFragment(String fragment) { | ||||
page.setFragment(fragment, false); | page.setFragment(fragment, false); | ||||
} | } | ||||
@Override | |||||
public void fragmentChanged(FragmentChangedEvent event) { | public void fragmentChanged(FragmentChangedEvent event) { | ||||
UriFragmentManager.this.navigator.navigateTo(getFragment()); | UriFragmentManager.this.navigator.navigateTo(getFragment()); | ||||
} | } | ||||
setSizeFull(); | setSizeFull(); | ||||
} | } | ||||
@Override | |||||
public void showView(View view) { | public void showView(View view) { | ||||
if (view instanceof Component) { | if (view instanceof Component) { | ||||
setCompositionRoot((Component) view); | setCompositionRoot((Component) view); | ||||
this.container = container; | this.container = container; | ||||
} | } | ||||
@Override | |||||
public void showView(View view) { | public void showView(View view) { | ||||
if (view instanceof Component) { | if (view instanceof Component) { | ||||
container.removeAllComponents(); | container.removeAllComponents(); | ||||
this.view = view; | this.view = view; | ||||
} | } | ||||
@Override | |||||
public String getViewName(String viewAndParameters) { | public String getViewName(String viewAndParameters) { | ||||
if (null == viewAndParameters) { | if (null == viewAndParameters) { | ||||
return null; | return null; | ||||
return null; | return null; | ||||
} | } | ||||
@Override | |||||
public View getView(String viewName) { | public View getView(String viewName) { | ||||
if (this.viewName.equals(viewName)) { | if (this.viewName.equals(viewName)) { | ||||
return view; | return view; | ||||
this.viewClass = viewClass; | this.viewClass = viewClass; | ||||
} | } | ||||
@Override | |||||
public String getViewName(String viewAndParameters) { | public String getViewName(String viewAndParameters) { | ||||
if (null == viewAndParameters) { | if (null == viewAndParameters) { | ||||
return null; | return null; | ||||
return null; | return null; | ||||
} | } | ||||
@Override | |||||
public View getView(String viewName) { | public View getView(String viewName) { | ||||
if (this.viewName.equals(viewName)) { | if (this.viewName.equals(viewName)) { | ||||
try { | try { |
private ClientConnector parent; | private ClientConnector parent; | ||||
/* Documentation copied from interface */ | /* Documentation copied from interface */ | ||||
@Override | |||||
public void requestRepaint() { | public void requestRepaint() { | ||||
Root root = getRoot(); | Root root = getRoot(); | ||||
if (root != null) { | if (root != null) { | ||||
registerRpc(implementation, type); | registerRpc(implementation, type); | ||||
} | } | ||||
@Override | |||||
public SharedState getState() { | public SharedState getState() { | ||||
if (null == sharedState) { | if (null == sharedState) { | ||||
sharedState = createState(); | sharedState = createState(); | ||||
* | * | ||||
* @see com.vaadin.terminal.gwt.server.ClientConnector#getStateType() | * @see com.vaadin.terminal.gwt.server.ClientConnector#getStateType() | ||||
*/ | */ | ||||
@Override | |||||
public Class<? extends SharedState> getStateType() { | public Class<? extends SharedState> getStateType() { | ||||
try { | try { | ||||
Method m = getClass().getMethod("getState", (Class[]) null); | Method m = getClass().getMethod("getState", (Class[]) null); | ||||
this.connector = connector; | this.connector = connector; | ||||
} | } | ||||
@Override | |||||
public Iterator<ClientConnector> iterator() { | public Iterator<ClientConnector> iterator() { | ||||
CombinedIterator<ClientConnector> iterator = new CombinedIterator<ClientConnector>(); | CombinedIterator<ClientConnector> iterator = new CombinedIterator<ClientConnector>(); | ||||
iterator.addIterator(connector.getExtensions().iterator()); | iterator.addIterator(connector.getExtensions().iterator()); | ||||
rpcInterfaceName = rpcInterface.getName().replaceAll("\\$", "."); | rpcInterfaceName = rpcInterface.getName().replaceAll("\\$", "."); | ||||
} | } | ||||
@Override | |||||
public Object invoke(Object proxy, Method method, Object[] args) | public Object invoke(Object proxy, Method method, Object[] args) | ||||
throws Throwable { | throws Throwable { | ||||
addMethodInvocationToQueue(rpcInterfaceName, method, args); | addMethodInvocationToQueue(rpcInterfaceName, method, args); | ||||
* | * | ||||
* @since 7.0 | * @since 7.0 | ||||
*/ | */ | ||||
@Override | |||||
public RpcManager getRpcManager(Class<?> rpcInterface) { | public RpcManager getRpcManager(Class<?> rpcInterface) { | ||||
return rpcManagerMap.get(rpcInterface); | return rpcManagerMap.get(rpcInterface); | ||||
} | } | ||||
@Override | |||||
public List<ClientMethodInvocation> retrievePendingRpcCalls() { | public List<ClientMethodInvocation> retrievePendingRpcCalls() { | ||||
if (pendingInvocations.isEmpty()) { | if (pendingInvocations.isEmpty()) { | ||||
return Collections.emptyList(); | return Collections.emptyList(); | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public String getConnectorId() { | public String getConnectorId() { | ||||
if (connectorId == null) { | if (connectorId == null) { | ||||
if (getApplication() == null) { | if (getApplication() == null) { | ||||
* @return the Root ancestor of this connector, or <code>null</code> if none | * @return the Root ancestor of this connector, or <code>null</code> if none | ||||
* is found. | * is found. | ||||
*/ | */ | ||||
@Override | |||||
public Root getRoot() { | public Root getRoot() { | ||||
ClientConnector connector = this; | ClientConnector connector = this; | ||||
while (connector != null) { | while (connector != null) { | ||||
return Logger.getLogger(AbstractClientConnector.class.getName()); | return Logger.getLogger(AbstractClientConnector.class.getName()); | ||||
} | } | ||||
@Override | |||||
public void requestRepaintAll() { | public void requestRepaintAll() { | ||||
requestRepaint(); | requestRepaint(); | ||||
iterators.add(iterator); | iterators.add(iterator); | ||||
} | } | ||||
@Override | |||||
public boolean hasNext() { | public boolean hasNext() { | ||||
for (Iterator<? extends T> i : iterators) { | for (Iterator<? extends T> i : iterators) { | ||||
if (i.hasNext()) { | if (i.hasNext()) { | ||||
return false; | return false; | ||||
} | } | ||||
@Override | |||||
public T next() { | public T next() { | ||||
for (Iterator<? extends T> i : iterators) { | for (Iterator<? extends T> i : iterators) { | ||||
if (i.hasNext()) { | if (i.hasNext()) { | ||||
throw new NoSuchElementException(); | throw new NoSuchElementException(); | ||||
} | } | ||||
@Override | |||||
public void remove() { | public void remove() { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
return new AllChildrenIterable(connector); | return new AllChildrenIterable(connector); | ||||
} | } | ||||
@Override | |||||
public Collection<Extension> getExtensions() { | public Collection<Extension> getExtensions() { | ||||
return Collections.unmodifiableCollection(extensions); | return Collections.unmodifiableCollection(extensions); | ||||
} | } | ||||
requestRepaint(); | requestRepaint(); | ||||
} | } | ||||
@Override | |||||
public void removeExtension(Extension extension) { | public void removeExtension(Extension extension) { | ||||
extension.setParent(null); | extension.setParent(null); | ||||
extensions.remove(extension); | extensions.remove(extension); | ||||
requestRepaint(); | requestRepaint(); | ||||
} | } | ||||
@Override | |||||
public void setParent(ClientConnector parent) { | public void setParent(ClientConnector parent) { | ||||
// If the parent is not changed, don't do anything | // If the parent is not changed, don't do anything | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public ClientConnector getParent() { | public ClientConnector getParent() { | ||||
return parent; | return parent; | ||||
} | } | ||||
@Override | |||||
public void attach() { | public void attach() { | ||||
requestRepaint(); | requestRepaint(); | ||||
* <code>null</code> after this method is called. | * <code>null</code> after this method is called. | ||||
* </p> | * </p> | ||||
*/ | */ | ||||
@Override | |||||
public void detach() { | public void detach() { | ||||
for (ClientConnector connector : getAllChildrenIterable(this)) { | for (ClientConnector connector : getAllChildrenIterable(this)) { | ||||
connector.detach(); | connector.detach(); | ||||
getRoot().getConnectorTracker().unregisterConnector(this); | getRoot().getConnectorTracker().unregisterConnector(this); | ||||
} | } | ||||
@Override | |||||
public boolean isConnectorEnabled() { | public boolean isConnectorEnabled() { | ||||
if (getParent() == null) { | if (getParent() == null) { | ||||
// No parent -> the component cannot receive updates from the client | // No parent -> the component cannot receive updates from the client |
} | } | ||||
/* Documented in interface */ | /* Documented in interface */ | ||||
@Override | |||||
public ErrorLevel getErrorLevel() { | public ErrorLevel getErrorLevel() { | ||||
return level; | return level; | ||||
} | } | ||||
causes.add(cause); | causes.add(cause); | ||||
} | } | ||||
@Override | |||||
public String getFormattedHtmlMessage() { | public String getFormattedHtmlMessage() { | ||||
String result = null; | String result = null; | ||||
switch (getMode()) { | switch (getMode()) { |
* | * | ||||
* @see com.vaadin.terminal.Resource#getMIMEType() | * @see com.vaadin.terminal.Resource#getMIMEType() | ||||
*/ | */ | ||||
@Override | |||||
public String getMIMEType() { | public String getMIMEType() { | ||||
return FileTypeResolver.getMIMEType(resourceName); | return FileTypeResolver.getMIMEType(resourceName); | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.terminal.ApplicationResource#getApplication() | * @see com.vaadin.terminal.ApplicationResource#getApplication() | ||||
*/ | */ | ||||
@Override | |||||
public Application getApplication() { | public Application getApplication() { | ||||
return application; | return application; | ||||
} | } | ||||
* @return the file name associated to this resource. | * @return the file name associated to this resource. | ||||
* @see com.vaadin.terminal.ApplicationResource#getFilename() | * @see com.vaadin.terminal.ApplicationResource#getFilename() | ||||
*/ | */ | ||||
@Override | |||||
public String getFilename() { | public String getFilename() { | ||||
int index = 0; | int index = 0; | ||||
int next = 0; | int next = 0; | ||||
* | * | ||||
* @see com.vaadin.terminal.ApplicationResource#getStream() | * @see com.vaadin.terminal.ApplicationResource#getStream() | ||||
*/ | */ | ||||
@Override | |||||
public DownloadStream getStream() { | public DownloadStream getStream() { | ||||
final DownloadStream ds = new DownloadStream( | final DownloadStream ds = new DownloadStream( | ||||
associatedClass.getResourceAsStream(resourceName), | associatedClass.getResourceAsStream(resourceName), | ||||
} | } | ||||
/* documented in superclass */ | /* documented in superclass */ | ||||
@Override | |||||
public int getBufferSize() { | public int getBufferSize() { | ||||
return bufferSize; | return bufferSize; | ||||
} | } | ||||
} | } | ||||
/* documented in superclass */ | /* documented in superclass */ | ||||
@Override | |||||
public long getCacheTime() { | public long getCacheTime() { | ||||
return cacheTime; | return cacheTime; | ||||
} | } |
} | } | ||||
@Override | |||||
public String getParameter(String parameter) { | public String getParameter(String parameter) { | ||||
String[] strings = getParameterMap().get(parameter); | String[] strings = getParameterMap().get(parameter); | ||||
if (strings == null || strings.length == 0) { | if (strings == null || strings.length == 0) { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public Map<String, String[]> getParameterMap() { | public Map<String, String[]> getParameterMap() { | ||||
return parameterMap; | return parameterMap; | ||||
} | } | ||||
@Override | |||||
public int getContentLength() { | public int getContentLength() { | ||||
return secondRequest.getContentLength(); | return secondRequest.getContentLength(); | ||||
} | } | ||||
@Override | |||||
public InputStream getInputStream() throws IOException { | public InputStream getInputStream() throws IOException { | ||||
return secondRequest.getInputStream(); | return secondRequest.getInputStream(); | ||||
} | } | ||||
@Override | |||||
public Object getAttribute(String name) { | public Object getAttribute(String name) { | ||||
return secondRequest.getAttribute(name); | return secondRequest.getAttribute(name); | ||||
} | } | ||||
@Override | |||||
public void setAttribute(String name, Object value) { | public void setAttribute(String name, Object value) { | ||||
secondRequest.setAttribute(name, value); | secondRequest.setAttribute(name, value); | ||||
} | } | ||||
@Override | |||||
public String getRequestPathInfo() { | public String getRequestPathInfo() { | ||||
return secondRequest.getParameter("initialPath"); | return secondRequest.getParameter("initialPath"); | ||||
} | } | ||||
@Override | |||||
public int getSessionMaxInactiveInterval() { | public int getSessionMaxInactiveInterval() { | ||||
return secondRequest.getSessionMaxInactiveInterval(); | return secondRequest.getSessionMaxInactiveInterval(); | ||||
} | } | ||||
@Override | |||||
public Object getSessionAttribute(String name) { | public Object getSessionAttribute(String name) { | ||||
return secondRequest.getSessionAttribute(name); | return secondRequest.getSessionAttribute(name); | ||||
} | } | ||||
@Override | |||||
public void setSessionAttribute(String name, Object attribute) { | public void setSessionAttribute(String name, Object attribute) { | ||||
secondRequest.setSessionAttribute(name, attribute); | secondRequest.setSessionAttribute(name, attribute); | ||||
} | } | ||||
@Override | |||||
public String getContentType() { | public String getContentType() { | ||||
return secondRequest.getContentType(); | return secondRequest.getContentType(); | ||||
} | } | ||||
@Override | |||||
public BrowserDetails getBrowserDetails() { | public BrowserDetails getBrowserDetails() { | ||||
return new BrowserDetails() { | return new BrowserDetails() { | ||||
@Override | |||||
public String getUriFragment() { | public String getUriFragment() { | ||||
String fragment = secondRequest.getParameter("fr"); | String fragment = secondRequest.getParameter("fr"); | ||||
if (fragment == null) { | if (fragment == null) { | ||||
} | } | ||||
} | } | ||||
@Override | |||||
public String getWindowName() { | public String getWindowName() { | ||||
return secondRequest.getParameter("wn"); | return secondRequest.getParameter("wn"); | ||||
} | } | ||||
@Override | |||||
public WebBrowser getWebBrowser() { | public WebBrowser getWebBrowser() { | ||||
WebApplicationContext context = (WebApplicationContext) Application | WebApplicationContext context = (WebApplicationContext) Application | ||||
.getCurrent().getContext(); | .getCurrent().getContext(); | ||||
return secondRequest; | return secondRequest; | ||||
} | } | ||||
@Override | |||||
public Locale getLocale() { | public Locale getLocale() { | ||||
return secondRequest.getLocale(); | return secondRequest.getLocale(); | ||||
} | } | ||||
@Override | |||||
public String getRemoteAddr() { | public String getRemoteAddr() { | ||||
return secondRequest.getRemoteAddr(); | return secondRequest.getRemoteAddr(); | ||||
} | } | ||||
@Override | |||||
public boolean isSecure() { | public boolean isSecure() { | ||||
return secondRequest.isSecure(); | return secondRequest.isSecure(); | ||||
} | } | ||||
@Override | |||||
public String getHeader(String name) { | public String getHeader(String name) { | ||||
return secondRequest.getHeader(name); | return secondRequest.getHeader(name); | ||||
} | } | ||||
@Override | |||||
public DeploymentConfiguration getDeploymentConfiguration() { | public DeploymentConfiguration getDeploymentConfiguration() { | ||||
return secondRequest.getDeploymentConfiguration(); | return secondRequest.getDeploymentConfiguration(); | ||||
} | } |
* | * | ||||
* @see com.vaadin.terminal.Resource#getMIMEType() | * @see com.vaadin.terminal.Resource#getMIMEType() | ||||
*/ | */ | ||||
@Override | |||||
public String getMIMEType() { | public String getMIMEType() { | ||||
if (mimeType == null) { | if (mimeType == null) { | ||||
mimeType = FileTypeResolver.getMIMEType(getURL().toString()); | mimeType = FileTypeResolver.getMIMEType(getURL().toString()); |
* | * | ||||
* @see com.vaadin.terminal.ApplicationResource#getStream() | * @see com.vaadin.terminal.ApplicationResource#getStream() | ||||
*/ | */ | ||||
@Override | |||||
public DownloadStream getStream() { | public DownloadStream getStream() { | ||||
try { | try { | ||||
final DownloadStream ds = new DownloadStream(new FileInputStream( | final DownloadStream ds = new DownloadStream(new FileInputStream( | ||||
// Log the exception using the application error handler | // Log the exception using the application error handler | ||||
getApplication().getErrorHandler().terminalError(new ErrorEvent() { | getApplication().getErrorHandler().terminalError(new ErrorEvent() { | ||||
@Override | |||||
public Throwable getThrowable() { | public Throwable getThrowable() { | ||||
return e; | return e; | ||||
} | } | ||||
/** | /** | ||||
* @see com.vaadin.terminal.ApplicationResource#getApplication() | * @see com.vaadin.terminal.ApplicationResource#getApplication() | ||||
*/ | */ | ||||
@Override | |||||
public Application getApplication() { | public Application getApplication() { | ||||
return application; | return application; | ||||
} | } | ||||
/** | /** | ||||
* @see com.vaadin.terminal.ApplicationResource#getFilename() | * @see com.vaadin.terminal.ApplicationResource#getFilename() | ||||
*/ | */ | ||||
@Override | |||||
public String getFilename() { | public String getFilename() { | ||||
return sourceFile.getName(); | return sourceFile.getName(); | ||||
} | } | ||||
/** | /** | ||||
* @see com.vaadin.terminal.Resource#getMIMEType() | * @see com.vaadin.terminal.Resource#getMIMEType() | ||||
*/ | */ | ||||
@Override | |||||
public String getMIMEType() { | public String getMIMEType() { | ||||
return FileTypeResolver.getMIMEType(sourceFile); | return FileTypeResolver.getMIMEType(sourceFile); | ||||
} | } | ||||
* | * | ||||
* @return Cache time in milliseconds. | * @return Cache time in milliseconds. | ||||
*/ | */ | ||||
@Override | |||||
public long getCacheTime() { | public long getCacheTime() { | ||||
return cacheTime; | return cacheTime; | ||||
} | } | ||||
} | } | ||||
/* documented in superclass */ | /* documented in superclass */ | ||||
@Override | |||||
public int getBufferSize() { | public int getBufferSize() { | ||||
return bufferSize; | return bufferSize; | ||||
} | } |
private void ensureRpc() { | private void ensureRpc() { | ||||
if (javascriptCallbackRpc == null) { | if (javascriptCallbackRpc == null) { | ||||
javascriptCallbackRpc = new JavaScriptCallbackRpc() { | javascriptCallbackRpc = new JavaScriptCallbackRpc() { | ||||
@Override | |||||
public void call(String name, JSONArray arguments) { | public void call(String name, JSONArray arguments) { | ||||
JavaScriptCallback callback = callbacks.get(name); | JavaScriptCallback callback = callbacks.get(name); | ||||
try { | try { |
/** | /** | ||||
* @see com.vaadin.terminal.Resource#getMIMEType() | * @see com.vaadin.terminal.Resource#getMIMEType() | ||||
*/ | */ | ||||
@Override | |||||
public String getMIMEType() { | public String getMIMEType() { | ||||
if (MIMEType != null) { | if (MIMEType != null) { | ||||
return MIMEType; | return MIMEType; | ||||
* | * | ||||
* @return the filename. | * @return the filename. | ||||
*/ | */ | ||||
@Override | |||||
public String getFilename() { | public String getFilename() { | ||||
return filename; | return filename; | ||||
} | } | ||||
/** | /** | ||||
* @see com.vaadin.terminal.ApplicationResource#getApplication() | * @see com.vaadin.terminal.ApplicationResource#getApplication() | ||||
*/ | */ | ||||
@Override | |||||
public Application getApplication() { | public Application getApplication() { | ||||
return application; | return application; | ||||
} | } | ||||
/** | /** | ||||
* @see com.vaadin.terminal.ApplicationResource#getStream() | * @see com.vaadin.terminal.ApplicationResource#getStream() | ||||
*/ | */ | ||||
@Override | |||||
public DownloadStream getStream() { | public DownloadStream getStream() { | ||||
final StreamSource ss = getStreamSource(); | final StreamSource ss = getStreamSource(); | ||||
if (ss == null) { | if (ss == null) { | ||||
} | } | ||||
/* documented in superclass */ | /* documented in superclass */ | ||||
@Override | |||||
public int getBufferSize() { | public int getBufferSize() { | ||||
return bufferSize; | return bufferSize; | ||||
} | } | ||||
} | } | ||||
/* documented in superclass */ | /* documented in superclass */ | ||||
@Override | |||||
public long getCacheTime() { | public long getCacheTime() { | ||||
return cacheTime; | return cacheTime; | ||||
} | } |
/** | /** | ||||
* @see com.vaadin.terminal.Resource#getMIMEType() | * @see com.vaadin.terminal.Resource#getMIMEType() | ||||
*/ | */ | ||||
@Override | |||||
public String getMIMEType() { | public String getMIMEType() { | ||||
return FileTypeResolver.getMIMEType(getResourceId()); | return FileTypeResolver.getMIMEType(getResourceId()); | ||||
} | } |
* | * | ||||
* @see com.vaadin.terminal.gwt.client.ComponentState#getTabIndex() | * @see com.vaadin.terminal.gwt.client.ComponentState#getTabIndex() | ||||
*/ | */ | ||||
@Override | |||||
public int getTabIndex() { | public int getTabIndex() { | ||||
return tabIndex; | return tabIndex; | ||||
} | } | ||||
* | * | ||||
* @see com.vaadin.terminal.gwt.client.ui.TabIndexState#setTabIndex(int) | * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#setTabIndex(int) | ||||
*/ | */ | ||||
@Override | |||||
public void setTabIndex(int tabIndex) { | public void setTabIndex(int tabIndex) { | ||||
this.tabIndex = tabIndex; | this.tabIndex = tabIndex; | ||||
} | } |
public static void startApplication(final String applicationId) { | public static void startApplication(final String applicationId) { | ||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() { | Scheduler.get().scheduleDeferred(new ScheduledCommand() { | ||||
@Override | |||||
public void execute() { | public void execute() { | ||||
ApplicationConfiguration appConf = getConfigFromDOM(applicationId); | ApplicationConfiguration appConf = getConfigFromDOM(applicationId); | ||||
ApplicationConnection a = GWT | ApplicationConnection a = GWT | ||||
private static DeferredWidgetLoader deferredWidgetLoader; | private static DeferredWidgetLoader deferredWidgetLoader; | ||||
@Override | |||||
public void onModuleLoad() { | public void onModuleLoad() { | ||||
// Prepare VConsole for debugging | // Prepare VConsole for debugging | ||||
*/ | */ | ||||
GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { | GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { | ||||
@Override | |||||
public void onUncaughtException(Throwable e) { | public void onUncaughtException(Throwable e) { | ||||
/* | /* | ||||
* Note in case of null console (without ?debug) we eat | * Note in case of null console (without ?debug) we eat |
* | * | ||||
* @see com.vaadin.terminal.gwt.client.VPaintable#getState() | * @see com.vaadin.terminal.gwt.client.VPaintable#getState() | ||||
*/ | */ | ||||
@Override | |||||
public ComponentState getState(); | public ComponentState getState(); | ||||
/** | /** |
public void init() { | public void init() { | ||||
connector.addStateChangeHandler(new StateChangeHandler() { | connector.addStateChangeHandler(new StateChangeHandler() { | ||||
@Override | |||||
public void onStateChanged(StateChangeEvent stateChangeEvent) { | public void onStateChanged(StateChangeEvent stateChangeEvent) { | ||||
JavaScriptObject wrapper = getConnectorWrapper(); | JavaScriptObject wrapper = getConnectorWrapper(); | ||||
JavaScriptConnectorState state = getConnectorState(); | JavaScriptConnectorState state = getConnectorState(); |
helper.init(); | helper.init(); | ||||
} | } | ||||
@Override | |||||
public JavaScriptConnectorHelper getJavascriptConnectorHelper() { | public JavaScriptConnectorHelper getJavascriptConnectorHelper() { | ||||
return helper; | return helper; | ||||
} | } |
private Set<String> callbackNames = new HashSet<String>(); | private Set<String> callbackNames = new HashSet<String>(); | ||||
private Map<String, Set<String>> rpcInterfaces = new HashMap<String, Set<String>>(); | private Map<String, Set<String>> rpcInterfaces = new HashMap<String, Set<String>>(); | ||||
@Override | |||||
public Set<String> getCallbackNames() { | public Set<String> getCallbackNames() { | ||||
return callbackNames; | return callbackNames; | ||||
} | } | ||||
this.callbackNames = callbackNames; | this.callbackNames = callbackNames; | ||||
} | } | ||||
@Override | |||||
public Map<String, Set<String>> getRpcInterfaces() { | public Map<String, Set<String>> getRpcInterfaces() { | ||||
return rpcInterfaces; | return rpcInterfaces; | ||||
} | } |
*/ | */ | ||||
public class NullConsole implements Console { | public class NullConsole implements Console { | ||||
@Override | |||||
public void dirUIDL(ValueMap u, ApplicationConfiguration cnf) { | public void dirUIDL(ValueMap u, ApplicationConfiguration cnf) { | ||||
} | } | ||||
@Override | |||||
public void error(String msg) { | public void error(String msg) { | ||||
GWT.log(msg); | GWT.log(msg); | ||||
} | } | ||||
@Override | |||||
public void log(String msg) { | public void log(String msg) { | ||||
GWT.log(msg); | GWT.log(msg); | ||||
} | } | ||||
@Override | |||||
public void printObject(Object msg) { | public void printObject(Object msg) { | ||||
GWT.log(msg.toString()); | GWT.log(msg.toString()); | ||||
} | } | ||||
@Override | |||||
public void printLayoutProblems(ValueMap meta, | public void printLayoutProblems(ValueMap meta, | ||||
ApplicationConnection applicationConnection, | ApplicationConnection applicationConnection, | ||||
Set<ComponentConnector> zeroHeightComponents, | Set<ComponentConnector> zeroHeightComponents, | ||||
Set<ComponentConnector> zeroWidthComponents) { | Set<ComponentConnector> zeroWidthComponents) { | ||||
} | } | ||||
@Override | |||||
public void log(Throwable e) { | public void log(Throwable e) { | ||||
GWT.log(e.getMessage(), e); | GWT.log(e.getMessage(), e); | ||||
} | } | ||||
@Override | |||||
public void error(Throwable e) { | public void error(Throwable e) { | ||||
// Borrow exception handling from VDebugConsole | // Borrow exception handling from VDebugConsole | ||||
VDebugConsole.handleError(e, this); | VDebugConsole.handleError(e, this); | ||||
} | } | ||||
@Override | |||||
public void setQuietMode(boolean quietDebugMode) { | public void setQuietMode(boolean quietDebugMode) { | ||||
} | } | ||||
@Override | |||||
public void init() { | public void init() { | ||||
} | } | ||||
if (preloadListeners.containsKey(url)) { | if (preloadListeners.containsKey(url)) { | ||||
// Preload going on, continue when preloaded | // Preload going on, continue when preloaded | ||||
preloadResource(url, new ResourceLoadListener() { | preloadResource(url, new ResourceLoadListener() { | ||||
@Override | |||||
public void onLoad(ResourceLoadEvent event) { | public void onLoad(ResourceLoadEvent event) { | ||||
loadScript(url, resourceLoadListener); | loadScript(url, resourceLoadListener); | ||||
} | } | ||||
@Override | |||||
public void onError(ResourceLoadEvent event) { | public void onError(ResourceLoadEvent event) { | ||||
// Preload failed -> signal error to own listener | // Preload failed -> signal error to own listener | ||||
if (resourceLoadListener != null) { | if (resourceLoadListener != null) { | ||||
scriptTag.setSrc(url); | scriptTag.setSrc(url); | ||||
scriptTag.setType("text/javascript"); | scriptTag.setType("text/javascript"); | ||||
addOnloadHandler(scriptTag, new ResourceLoadListener() { | addOnloadHandler(scriptTag, new ResourceLoadListener() { | ||||
@Override | |||||
public void onLoad(ResourceLoadEvent event) { | public void onLoad(ResourceLoadEvent event) { | ||||
fireLoad(event); | fireLoad(event); | ||||
} | } | ||||
@Override | |||||
public void onError(ResourceLoadEvent event) { | public void onError(ResourceLoadEvent event) { | ||||
fireError(event); | fireError(event); | ||||
} | } | ||||
Element element = getPreloadElement(url); | Element element = getPreloadElement(url); | ||||
addOnloadHandler(element, new ResourceLoadListener() { | addOnloadHandler(element, new ResourceLoadListener() { | ||||
@Override | |||||
public void onLoad(ResourceLoadEvent event) { | public void onLoad(ResourceLoadEvent event) { | ||||
fireLoad(event); | fireLoad(event); | ||||
} | } | ||||
@Override | |||||
public void onError(ResourceLoadEvent event) { | public void onError(ResourceLoadEvent event) { | ||||
fireError(event); | fireError(event); | ||||
} | } | ||||
if (preloadListeners.containsKey(url)) { | if (preloadListeners.containsKey(url)) { | ||||
// Preload going on, continue when preloaded | // Preload going on, continue when preloaded | ||||
preloadResource(url, new ResourceLoadListener() { | preloadResource(url, new ResourceLoadListener() { | ||||
@Override | |||||
public void onLoad(ResourceLoadEvent event) { | public void onLoad(ResourceLoadEvent event) { | ||||
loadStylesheet(url, resourceLoadListener); | loadStylesheet(url, resourceLoadListener); | ||||
} | } | ||||
@Override | |||||
public void onError(ResourceLoadEvent event) { | public void onError(ResourceLoadEvent event) { | ||||
// Preload failed -> signal error to own listener | // Preload failed -> signal error to own listener | ||||
if (resourceLoadListener != null) { | if (resourceLoadListener != null) { | ||||
Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() { | Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() { | ||||
private final Duration duration = new Duration(); | private final Duration duration = new Duration(); | ||||
@Override | |||||
public boolean execute() { | public boolean execute() { | ||||
int styleSheetLength = getStyleSheetLength(url); | int styleSheetLength = getStyleSheetLength(url); | ||||
if (getStyleSheetLength(url) > 0) { | if (getStyleSheetLength(url) > 0) { | ||||
}, 10); | }, 10); | ||||
} else { | } else { | ||||
addOnloadHandler(linkElement, new ResourceLoadListener() { | addOnloadHandler(linkElement, new ResourceLoadListener() { | ||||
@Override | |||||
public void onLoad(ResourceLoadEvent event) { | public void onLoad(ResourceLoadEvent event) { | ||||
// Chrome && IE fires load for errors, must check | // Chrome && IE fires load for errors, must check | ||||
// stylesheet data | // stylesheet data | ||||
fireLoad(event); | fireLoad(event); | ||||
} | } | ||||
@Override | |||||
public void onError(ResourceLoadEvent event) { | public void onError(ResourceLoadEvent event) { | ||||
fireError(event); | fireError(event); | ||||
} | } |
* @return The parent of this connector, as set by | * @return The parent of this connector, as set by | ||||
* {@link #setParent(ServerConnector)}. | * {@link #setParent(ServerConnector)}. | ||||
*/ | */ | ||||
@Override | |||||
public ServerConnector getParent(); | public ServerConnector getParent(); | ||||
/** | /** |