public void setVisible(boolean visible) {
if (getState().isVisible() != visible) {
getState().setVisible(visible);
- // Instead of requesting repaint normally we
- // fire the event directly to assure that the
- // event goes through event in the component might
- // now be invisible
- fireRequestRepaintEvent(null);
+ requestRepaint();
+ if (getParent() != null) {
+ // Must always repaint the parent (at least the hierarchy) when
+ // visibility of a child component changes.
+ getParent().requestRepaint();
+ }
}
}
public void attach() {
getRoot().componentAttached(this);
requestRepaint();
- if (!getState().isVisible()) {
- /*
- * Bypass the repaint optimization in childRequestedRepaint method
- * when attaching. When reattaching (possibly moving) -> must
- * repaint
- */
- fireRequestRepaintEvent(null);
- }
if (delayedFocus) {
focus();
}
/* Documentation copied from interface */
public void requestRepaint() {
-
- // The effect of the repaint request is identical to case where a
- // child requests repaint
- childRequestedRepaint(null);
- }
-
- /* Documentation copied from interface */
- public void childRequestedRepaint(
- Collection<RepaintRequestListener> alreadyNotified) {
// Invisible components (by flag in this particular component) do not
// need repaints
if (!getState().isVisible()) {
return;
}
- fireRequestRepaintEvent(alreadyNotified);
+ fireRequestRepaintEvent();
}
/**
*
* @param alreadyNotified
*/
- private void fireRequestRepaintEvent(
- Collection<RepaintRequestListener> alreadyNotified) {
- // Notify listeners only once
+ // Notify listeners only once
+ private void fireRequestRepaintEvent() {
// Notify the listeners
if (repaintRequestListeners != null
&& !repaintRequestListeners.isEmpty()) {
final Object[] listeners = repaintRequestListeners.toArray();
final RepaintRequestEvent event = new RepaintRequestEvent(this);
for (int i = 0; i < listeners.length; i++) {
- if (alreadyNotified == null) {
- alreadyNotified = new LinkedList<RepaintRequestListener>();
- }
- if (!alreadyNotified.contains(listeners[i])) {
- ((RepaintRequestListener) listeners[i])
- .repaintRequested(event);
- alreadyNotified.add((RepaintRequestListener) listeners[i]);
- }
+ ((RepaintRequestListener) listeners[i]).repaintRequested(event);
}
}
-
- // Notify the parent
- final Component parent = getParent();
- if (parent != null) {
- parent.childRequestedRepaint(alreadyNotified);
- }
}
/* Documentation copied from interface */
package com.vaadin.ui;
import java.io.Serializable;
-import java.util.Collection;
import java.util.EventListener;
import java.util.EventObject;
import java.util.Locale;
*/
public ComponentState getState();
- /**
- * The child components of the component must call this method when they
- * need repainting. The call must be made even in the case in which the
- * children sent the repaint request themselves.
- *
- * <p>
- * A repaint request is ignored if the component is invisible.
- * </p>
- *
- * <p>
- * This method is called automatically by {@link AbstractComponent}, which
- * also provides a default implementation of it. As this is a somewhat
- * internal feature, it is rarely necessary to reimplement this or call it
- * explicitly.
- * </p>
- *
- * @param alreadyNotified
- * the collection of repaint request listeners that have been
- * already notified by the child. This component should not
- * re-notify the listed listeners again. The container given as
- * parameter must be modifiable as the component might modify it
- * and pass it forward. A {@code null} parameter is interpreted
- * as an empty collection.
- */
- public void childRequestedRepaint(
- Collection<RepaintRequestListener> alreadyNotified);
-
/* Component event framework */
/**