Browse Source

Only run sizeInit after the actual layout (#8313)

tags/7.0.0.alpha2
Leif Åstrand 12 years ago
parent
commit
80a249b758

+ 6
- 2
src/com/vaadin/terminal/gwt/client/ui/TableConnector.java View File

@@ -16,7 +16,7 @@ import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;

public class TableConnector extends AbstractComponentContainerConnector
implements DirectionalManagedLayout {
implements DirectionalManagedLayout, PostLayoutListener {

/*
* (non-Javadoc)
@@ -256,6 +256,10 @@ public class TableConnector extends AbstractComponentContainerConnector
}

public void layoutHorizontally() {
getWidget().updateWidth();
// getWidget().updateWidth();
}

public void postLayout() {
getWidget().sizeInit();
}
}

+ 19
- 15
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java View File

@@ -456,6 +456,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
int serverCacheFirst = -1;
int serverCacheLast = -1;

private boolean sizeNeedsInit = true;

public VScrollTable() {
setMultiSelectMode(MULTISELECT_MODE_DEFAULT);

@@ -838,9 +840,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
tFoot.setHorizontalScrollPosition(0);

initialContentReceived = true;
if (isAttached()) {
sizeInit();
}
sizeNeedsInit = true;
scrollBody.restoreRowVisibility();
}

@@ -965,7 +965,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,

if (oldPageLength != pageLength && initializedAndAttached) {
// page length changed, need to update size
sizeInit();
sizeNeedsInit = true;
}
}

@@ -1580,14 +1580,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
}
}

@Override
protected void onAttach() {
super.onAttach();
if (initialContentReceived) {
sizeInit();
}
}

@Override
protected void onDetach() {
rowRequestHandler.cancel();
@@ -1611,7 +1603,11 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
*
* * Makes deferred request to get some cache rows
*/
private void sizeInit() {
void sizeInit() {
if (!sizeNeedsInit) {
return;
}
sizeNeedsInit = false;
/*
* We will use browsers table rendering algorithm to find proper column
* widths. If content and header take less space than available, we will
@@ -5521,6 +5517,15 @@ public class VScrollTable extends FlowPanel implements HasWidgets,

}

@Override
public void setWidth(String width) {
String oldWidth = getElement().getStyle().getWidth();
if (!oldWidth.equals(width)) {
super.setWidth(width);
updateWidth();
}
}

void updateWidth() {
if (!isVisible()) {
/*
@@ -5543,8 +5548,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,

} else {

// Readjust size of table
sizeInit();
sizeNeedsInit = true;

// readjust undefined width columns
triggerLazyColumnAdjustment(false);

Loading…
Cancel
Save