summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-03-13 20:39:00 +0200
committerArtur Signell <artur@vaadin.com>2012-03-14 16:00:53 +0200
commit4a3f767d1cd330b4dc83531f349e2d6408b202da (patch)
tree396c85400d52211a800893203919db3695dd705c /src/com
parentf38942e05bbb46c2d4db0cd964bf83f5bc171100 (diff)
downloadvaadin-framework-4a3f767d1cd330b4dc83531f349e2d6408b202da.tar.gz
vaadin-framework-4a3f767d1cd330b4dc83531f349e2d6408b202da.zip
Made TabSheet work again and removed TabSheet tab caching for now
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/TabsheetBaseConnector.java11
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java3
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java7
-rw-r--r--src/com/vaadin/ui/AbstractComponent.java13
-rw-r--r--src/com/vaadin/ui/TabSheet.java45
5 files changed, 28 insertions, 51 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/TabsheetBaseConnector.java b/src/com/vaadin/terminal/gwt/client/ui/TabsheetBaseConnector.java
index 0c44068cf5..bca4163185 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/TabsheetBaseConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/TabsheetBaseConnector.java
@@ -9,7 +9,6 @@ import java.util.Iterator;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ComponentConnector;
-import com.vaadin.terminal.gwt.client.ConnectorMap;
import com.vaadin.terminal.gwt.client.UIDL;
public abstract class TabsheetBaseConnector extends
@@ -37,7 +36,7 @@ public abstract class TabsheetBaseConnector extends
// Render content
final UIDL tabs = uidl.getChildUIDL(0);
- // Paintables in the TabSheet before update
+ // Widgets in the TabSheet before update
ArrayList<Widget> oldWidgets = new ArrayList<Widget>();
for (Iterator<Widget> iterator = getWidget().getWidgetIterator(); iterator
.hasNext();) {
@@ -75,23 +74,19 @@ public abstract class TabsheetBaseConnector extends
for (int i = 0; i < getWidget().getTabCount(); i++) {
ComponentConnector p = getWidget().getTab(i);
- // During the initial rendering the paintable might be null (this is
- // weird...)
+ // null for PlaceHolder widgets
if (p != null) {
oldWidgets.remove(p.getWidget());
}
}
- // Perform unregister for any paintables removed during update
+ // Detach any old tab widget, should be max 1
for (Iterator<Widget> iterator = oldWidgets.iterator(); iterator
.hasNext();) {
Widget oldWidget = iterator.next();
- ComponentConnector oldPaintable = ConnectorMap.get(client)
- .getConnector(oldWidget);
if (oldWidget.isAttached()) {
oldWidget.removeFromParent();
}
- ConnectorMap.get(client).unregisterConnector(oldPaintable);
}
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
index b30483c2cd..67bdddce20 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
@@ -896,9 +896,10 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
private void renderContent(final UIDL contentUIDL) {
final ComponentConnector content = client.getPaintable(contentUIDL);
+ Widget newWidget = content.getWidget();
if (tp.getWidgetCount() > activeTabIndex) {
Widget old = tp.getWidget(activeTabIndex);
- if (old != content) {
+ if (old != newWidget) {
tp.remove(activeTabIndex);
ConnectorMap paintableMap = ConnectorMap.get(client);
if (paintableMap.isConnector(old)) {
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 615112168b..c509cbb33e 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -951,8 +951,7 @@ public abstract class AbstractCommunicationManager implements
JSONArray children = new JSONArray();
for (Component child : getChildComponents(parent)) {
- if (child.getState().isVisible()
- && parent.isComponentVisible(child)) {
+ if (child.isVisible()) {
String childConnectorId = getPaintableId(child);
children.put(childConnectorId);
}
@@ -962,8 +961,8 @@ public abstract class AbstractCommunicationManager implements
} catch (JSONException e) {
throw new PaintException(
"Failed to send hierarchy information about "
- + parentConnectorId + " to the client: "
- + e.getMessage());
+ + parentConnectorId
+ + " to the client: " + e.getMessage());
}
}
}
diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java
index 5791ff21cd..b9e8f18368 100644
--- a/src/com/vaadin/ui/AbstractComponent.java
+++ b/src/com/vaadin/ui/AbstractComponent.java
@@ -409,8 +409,12 @@ public abstract class AbstractComponent implements Component, MethodEventSource
* @see com.vaadin.ui.Component#isVisible()
*/
public boolean isVisible() {
- return getState().isVisible()
- && (getParent() == null || getParent().isVisible());
+ if (getParent() == null) {
+ return getState().isVisible();
+ } else {
+ return getState().isVisible() && getParent().isVisible()
+ && ((HasComponents) getParent()).isComponentVisible(this);
+ }
}
/*
@@ -1699,4 +1703,9 @@ public abstract class AbstractComponent implements Component, MethodEventSource
return Collections.unmodifiableList(result);
}
}
+
+ public String getConnectorId() {
+ throw new RuntimeException(
+ "TODO: Move connector id handling to AbstractComponent");
+ }
}
diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java
index 96e9feb6d3..59f3386732 100644
--- a/src/com/vaadin/ui/TabSheet.java
+++ b/src/com/vaadin/ui/TabSheet.java
@@ -7,10 +7,8 @@ package com.vaadin.ui;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@@ -28,7 +26,6 @@ import com.vaadin.terminal.Resource;
import com.vaadin.terminal.gwt.client.ui.TabsheetBaseConnector;
import com.vaadin.terminal.gwt.client.ui.TabsheetConnector;
import com.vaadin.terminal.gwt.client.ui.VTabsheet;
-import com.vaadin.terminal.gwt.server.CommunicationManager;
import com.vaadin.ui.Component.Focusable;
import com.vaadin.ui.themes.Reindeer;
import com.vaadin.ui.themes.Runo;
@@ -95,11 +92,6 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
private boolean tabsHidden;
/**
- * Tabs that have been shown to the user (have been painted as selected).
- */
- private HashSet<Component> paintedTabs = new HashSet<Component>();
-
- /**
* Handler to be called when a tab is closed.
*/
private CloseHandler closeHandler;
@@ -380,13 +372,9 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
target.startTag("tabs");
- Collection<Component> orphaned = new HashSet<Component>(paintedTabs);
-
for (final Iterator<Component> i = getComponentIterator(); i.hasNext();) {
final Component component = i.next();
- orphaned.remove(component);
-
Tab tab = tabs.get(component);
target.startTag("tab");
@@ -436,17 +424,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
target.addAttribute("key", keyMapper.key(component));
if (component.equals(selected)) {
target.addAttribute("selected", true);
- if (!paintedTabs.contains(component)) {
- // Ensure the component is painted if it hasn't already been
- // painted in this tabsheet
- component.requestRepaint();
- paintedTabs.add(component);
- }
component.paint(target);
- } else if (paintedTabs.contains(component)) {
- component.paint(target);
- } else {
- component.requestRepaintRequests();
}
target.endTag("tab");
}
@@ -457,10 +435,6 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
target.addVariable(this, "selected", keyMapper.key(selected));
}
- // clean possibly orphaned entries in paintedTabs
- for (Component component2 : orphaned) {
- paintedTabs.remove(component2);
- }
}
/**
@@ -599,6 +573,15 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
updateSelection();
fireSelectedTabChange();
requestRepaint();
+ // Repaint of the selected component is needed as only the selected
+ // component is communicated to the client. Otherwise this will be a
+ // "cached" update even though the client knows nothing about the
+ // connector
+ if (selected instanceof ComponentContainer) {
+ ((ComponentContainer) selected).requestRepaintAll();
+ } else {
+ selected.requestRepaint();
+ }
}
}
@@ -880,16 +863,6 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
fireEvent(new SelectedTabChangeEvent(this));
}
- @Override
- public void removeListener(RepaintRequestListener listener) {
- super.removeListener(listener);
- if (listener instanceof CommunicationManager) {
- // clean the paintedTabs here instead of detach to avoid subtree
- // caching issues when detached-attached without render
- paintedTabs.clear();
- }
- }
-
/**
* Tab meta-data for a component in a {@link TabSheet}.
*