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
// 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();) {
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);
}
}
* @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);
+ }
}
/*
return Collections.unmodifiableList(result);
}
}
+
+ public String getConnectorId() {
+ throw new RuntimeException(
+ "TODO: Move connector id handling to AbstractComponent");
+ }
}
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;
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;
*/
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.
*/
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");
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");
}
target.addVariable(this, "selected", keyMapper.key(selected));
}
- // clean possibly orphaned entries in paintedTabs
- for (Component component2 : orphaned) {
- paintedTabs.remove(component2);
- }
}
/**
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();
+ }
}
}
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}.
*