From a99be9d622681366b9896dde6dc75f79b5ce6f4c Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 14 Mar 2012 09:54:18 +0200 Subject: [PATCH] Fixed NPE when changing tab --- .../terminal/gwt/client/ui/VTabsheet.java | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java index 67bdddce20..57510dcdc2 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java @@ -10,6 +10,7 @@ import java.util.List; import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.dom.client.TableCellElement; import com.google.gwt.dom.client.TableElement; import com.google.gwt.event.dom.client.BlurEvent; @@ -551,13 +552,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable, boolean waitingForResponse; - /** - * Previous visible widget is set invisible with CSS (not display: none, but - * visibility: hidden), to avoid flickering during render process. Normal - * visibility must be returned later when new widget is rendered. - */ - private Widget previousVisibleWidget; - private String currentStyle; /** @@ -579,18 +573,14 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } addStyleDependentName("loading"); - // run updating variables in deferred command to bypass some FF - // optimization issues - Scheduler.get().scheduleDeferred(new Command() { - public void execute() { - previousVisibleWidget = tp.getWidget(tp.getVisibleWidget()); - DOM.setStyleAttribute( - DOM.getParent(previousVisibleWidget.getElement()), - "visibility", "hidden"); - client.updateVariable(id, "selected", tabKeys.get(tabIndex) - .toString(), true); - } - }); + // Hide the current contents so a loading indicator can be shown + // instead + Widget currentlyDisplayedWidget = tp.getWidget(tp + .getVisibleWidget()); + currentlyDisplayedWidget.getElement().getParentElement().getStyle() + .setVisibility(Visibility.HIDDEN); + client.updateVariable(id, "selected", tabKeys.get(tabIndex) + .toString(), true); waitingForResponse = true; return true; @@ -925,12 +915,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } updateOpenTabSize(); VTabsheet.this.removeStyleDependentName("loading"); - if (previousVisibleWidget != null) { - DOM.setStyleAttribute( - DOM.getParent(previousVisibleWidget.getElement()), - "visibility", ""); - previousVisibleWidget = null; - } } void updateContentNodeHeight() { -- 2.39.5