From 9da1979af798324cbe1eea2b6adde0886774f73b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Tue, 19 Feb 2013 11:04:55 +0200 Subject: [PATCH] Properly detach old connectors for repaintAll response (#11067) Change-Id: I6491a9b30ea4c0e4ff141497b9bd78e5d1c4c98c --- .../vaadin/client/ApplicationConnection.java | 36 +++++++++++++++-- .../debug/HierarchyAfterAnalyzeLayouts.html | 37 +++++++++++++++++ .../debug/HierarchyAfterAnalyzeLayouts.java | 40 +++++++++++++++++++ 3 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.html create mode 100644 uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.java diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 3157bd0685..8ecc90bdd5 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -1395,15 +1395,12 @@ public class ApplicationConnection { Profiler.leave("Handling locales"); Profiler.enter("Handling meta information"); - boolean repaintAll = false; ValueMap meta = null; if (json.containsKey("meta")) { VConsole.log(" * Handling meta information"); meta = json.getValueMap("meta"); if (meta.containsKey("repaintAll")) { - repaintAll = true; - uIConnector.getWidget().clear(); - getConnectorMap().clear(); + prepareRepaintAll(); if (meta.containsKey("invalidLayouts")) { validatingLayouts = true; } @@ -1532,6 +1529,37 @@ public class ApplicationConnection { } + /** + * Properly clean up any old stuff to ensure everything is properly + * reinitialized. + */ + private void prepareRepaintAll() { + String uiConnectorId = uIConnector.getConnectorId(); + if (uiConnectorId == null) { + // Nothing to clear yet + return; + } + + // Create fake server response that says that the uiConnector + // has no children + JSONObject fakeHierarchy = new JSONObject(); + fakeHierarchy.put(uiConnectorId, new JSONArray()); + JSONObject fakeJson = new JSONObject(); + fakeJson.put("hierarchy", fakeHierarchy); + ValueMap fakeValueMap = fakeJson.getJavaScriptObject().cast(); + + // Update hierarchy based on the fake response + ConnectorHierarchyUpdateResult connectorHierarchyUpdateResult = updateConnectorHierarchy(fakeValueMap); + + // Send hierarchy events based on the fake update + sendHierarchyChangeEvents(connectorHierarchyUpdateResult.events); + + // Unregister all the old connectors that have now been removed + unregisterRemovedConnectors(); + + getLayoutManager().cleanMeasuredSizes(); + } + private void updateCaptions( Collection pendingStateChangeEvents, Collection parentChanged) { diff --git a/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.html b/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.html new file mode 100644 index 0000000000..03d8f34651 --- /dev/null +++ b/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.html @@ -0,0 +1,37 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.debug.HierarchyAfterAnalyzeLayouts?restartApplication&debug
mouseClickvaadin=runcomvaadintestsdebugHierarchyAfterAnalyzeLayouts::Root/VDebugConsole[0]/FlowPanel[0]/HorizontalPanel[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]18,9
assertTextPresentLayouts analyzed on server, total top level problems: 0
assertElementPresentvaadin=runcomvaadintestsdebugHierarchyAfterAnalyzeLayouts::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]
+ + diff --git a/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.java b/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.java new file mode 100644 index 0000000000..6f55e050c0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.debug; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; + +public class HierarchyAfterAnalyzeLayouts extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + addComponent(new Label("This is a label")); + } + + @Override + protected String getTestDescription() { + return "The connector hierarchy should be in order after clicking AL in the debug console"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(11067); + } + +} -- 2.39.5