Closed vaadin-bot closed 9 years ago
Originally by _personalsoftfabiano
I would like to have this listener, too
Originally by S73417H
This seems like a feature that should have been implemented by now. Our application also requires the ability to transparently persist user interface state. We would like to do this without the use of timers.
I've voted on this feature using our pro account. Hopefully it gets some traction soon as its been sitting here a while. Would very much like to see this in Vaadin 6.x.
Originally by @jdahlstrom
This is one of our most voted feature requests, and wouldn't be that hard to implement. We seriously considered it for 7.1 but unfortunately didn't have enough time in the end. Hopefully it does make it into Vaadin 7.2. However, the Vaadin 6 series is in maintenance mode and is not expected to get new features at this point.
Originally by santeriv-profit
Here is a more an idea or a comment than a real workaround because the UI cannot actually be updated during paintContent as seen in comments, if somebody tries to create a workaround for this .. (vaadin 7.1)
MyTreeTable extends TreeTable
//
..
//
public static interface ColumnCollapsedEventListener extends Serializable {
/**
- Triggered when collapsed columns amount changes
-
- @param newCollapsedColumns
- - List of collapsed propertyIds
-/
void collapsedColumnsChanged(List<Object> newCollapsedColumns);
}
private ColumnCollapsedEventListener columnCollapsedEventListener;
private List<Object> collapsedColumns = Lists.newArrayList();
@Override
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
// For workaround of TreeTable/Table 'bug' to inform about collapse
// event of columns
List<Object> collapsedColumnPropertyIds = getCollapsedColumns();
if (collapsedColumns.size() != collapsedColumnPropertyIds.size()) {
LOGGER.debug("paintContent collapsedColumnsChanged");
// then there was change in collapsed columns
collapsedColumns = collapsedColumnPropertyIds;
if (columnCollapsedEventListener != null) {
//TODO: Because paintContent is part of uidl write response, we should wait until UI is ready
/*
java.lang.IllegalStateException: A connector should not be marked as dirty while a response is being written.
at com.vaadin.ui.ConnectorTracker.markDirty(ConnectorTracker.java:346)
-/
//writing response is not done
columnCollapsedEventListener.collapsedColumnsChanged(collapsedColumns);
}
}
}
// would be nice if visibleColumns would read collapsedColumns also
public List<Object> getCollapsedColumns() {
List<Object> collapsedColumnPropertyIds = Lists.newArrayList();
List<Object> propertyIds = Lists.newArrayList(getContainerPropertyIds());
for (Object propertyId : propertyIds) {
if (isColumnCollapsed(propertyId)) {
collapsedColumnPropertyIds.add(propertyId);
}
}
return collapsedColumnPropertyIds;
}
Originally by geert3
Here is a more an idea or a comment than a real workaround because the UI cannot actually be updated during paintContent as seen in comments, if somebody tries to create a workaround for this .. (vaadin 7.1)
Your solution actually works quite well. To avoid the exception all you need is to wrap the event firing in "access()", like this:
if (columnCollapsedEventListener != null) {
VaadinSession.getCurrent().access(new Runnable() {
@Override
public void run() {
columnCollapsedEventListener.collapsedColumnsChanged(collapsedColumns);
}
});
}
Originally by @Artur-
API:
Should be fired after a column has been collapsed/uncollapsed
Use case: Store Table configuration for the user
Split from #6187
Imported from https://dev.vaadin.com/ issue #6914