eventIdentifier);
}
- private boolean layoutScheduled = false;
+ private boolean layoutPending = false;
private ScheduledCommand layoutCommand = new ScheduledCommand() {
public void execute() {
- layoutScheduled = false;
-
- layoutManager.doLayout();
+ /*
+ * Layout again if a new layout is requested while the current one
+ * is running.
+ */
+ while (layoutPending) {
+ layoutPending = false;
+ layoutManager.doLayout();
+ }
}
};
public void doLayout(boolean lazy) {
+ layoutPending = true;
if (!lazy) {
layoutCommand.execute();
- } else if (!layoutScheduled) {
- layoutScheduled = true;
- Scheduler.get().scheduleDeferred(layoutCommand);
+ } else if (!layoutPending) {
+ /*
+ * Current layoutCommand will do layouts again if layoutScheduled is
+ * set to true -> no need to schedule another command
+ */
+ if (!layoutManager.isLayoutRunning()) {
+ Scheduler.get().scheduleDeferred(layoutCommand);
+ }
}
}
private final ApplicationConnection connection;
private final Set<Element> nonPaintableElements = new HashSet<Element>();
private final MeasuredSize nullSize = new MeasuredSize();
+ private boolean layoutRunning = false;
public LayoutManager(ApplicationConnection connection) {
this.connection = connection;
}
}
+ public boolean isLayoutRunning() {
+ return layoutRunning;
+ }
+
public void doLayout() {
+ if (layoutRunning) {
+ throw new IllegalStateException(
+ "Can't start a new layout phase before the previous layout phase ends.");
+ }
VConsole.log("Starting layout phase");
+ layoutRunning = true;
ConnectorMap paintableMap = connection.getConnectorMap();
ComponentConnector[] paintableWidgets = paintableMap
}
}
+ layoutRunning = false;
VConsole.log("Total layout phase time: "
+ totalDuration.elapsedMillis() + "ms");
}