Просмотр исходного кода

Updated Panel to no longer use child painted with the UIDL

tags/7.0.0.alpha2
Artur Signell 12 лет назад
Родитель
Сommit
ae3478bc2e
21 измененных файлов: 184 добавлений и 282 удалений
  1. 5
    55
      src/com/vaadin/terminal/Scrollable.java
  2. 10
    14
      src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
  3. 3
    3
      src/com/vaadin/terminal/gwt/client/ComponentContainerConnector.java
  4. 4
    4
      src/com/vaadin/terminal/gwt/client/ConnectorHierarchyChangedEvent.java
  5. 6
    10
      src/com/vaadin/terminal/gwt/client/ConnectorMap.java
  6. 5
    5
      src/com/vaadin/terminal/gwt/client/ui/AbstractComponentContainerConnector.java
  7. 86
    22
      src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java
  8. 0
    3
      src/com/vaadin/terminal/gwt/client/ui/VPanel.java
  9. 24
    2
      src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
  10. 30
    143
      src/com/vaadin/ui/Panel.java
  11. 5
    1
      src/com/vaadin/ui/Window.java
  12. 0
    1
      tests/testbench/com/vaadin/tests/components/panel/BasicPanelTest.java
  13. 0
    1
      tests/testbench/com/vaadin/tests/components/panel/PanelShouldNotScroll.java
  14. 0
    1
      tests/testbench/com/vaadin/tests/components/tree/TreeScrollingOnSelection.java
  15. 0
    1
      tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java
  16. 6
    10
      tests/testbench/com/vaadin/tests/tickets/Ticket1710.java
  17. 0
    1
      tests/testbench/com/vaadin/tests/tickets/Ticket1804.java
  18. 0
    1
      tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java
  19. 0
    2
      tests/testbench/com/vaadin/tests/tickets/Ticket1869.java
  20. 0
    1
      tests/testbench/com/vaadin/tests/tickets/Ticket1923.java
  21. 0
    1
      tests/testbench/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java

+ 5
- 55
src/com/vaadin/terminal/Scrollable.java Просмотреть файл

@@ -9,8 +9,7 @@ import java.io.Serializable;
/**
* <p>
* This interface is implemented by all visual objects that can be scrolled
* programmatically from the server-side, or for which it is possible to know
* the scroll position on the server-side. The unit of scrolling is pixel.
* programmatically from the server-side. The unit of scrolling is pixel.
* </p>
*
* @author Vaadin Ltd.
@@ -40,17 +39,10 @@ public interface Scrollable extends Serializable {
* scrolled right.
* </p>
*
* <p>
* The method only has effect if programmatic scrolling is enabled for the
* scrollable. Some implementations may require enabling programmatic before
* this method can be used. See {@link #setScrollable(boolean)} for more
* information.
* </p>
*
* @param pixelsScrolled
* @param scrollLeft
* the xOffset.
*/
public void setScrollLeft(int pixelsScrolled);
public void setScrollLeft(int scrollLeft);

/**
* Gets scroll top offset.
@@ -73,13 +65,6 @@ public interface Scrollable extends Serializable {
* </p>
*
* <p>
* The method only has effect if programmatic scrolling is enabled for the
* scrollable. Some implementations may require enabling programmatic before
* this method can be used. See {@link #setScrollable(boolean)} for more
* information.
* </p>
*
* <p>
* The scrolling position is limited by the current height of the content
* area. If the position is below the height, it is scrolled to the bottom.
* However, if the same response also adds height to the content area,
@@ -87,44 +72,9 @@ public interface Scrollable extends Serializable {
* area.
* </p>
*
* @param pixelsScrolled
* @param scrollTop
* the yOffset.
*/
public void setScrollTop(int pixelsScrolled);

/**
* Is programmatic scrolling enabled.
*
* <p>
* Whether programmatic scrolling with {@link #setScrollLeft(int)} and
* {@link #setScrollTop(int)} is enabled.
* </p>
*
* @return <code>true</code> if the scrolling is enabled, otherwise
* <code>false</code>.
*/
public boolean isScrollable();

/**
* Enables or disables programmatic scrolling.
*
* <p>
* Enables setting the scroll position with {@link #setScrollLeft(int)} and
* {@link #setScrollTop(int)}. Implementations of the interface may have
* programmatic scrolling disabled by default, in which case you need to
* enable it to use the mentioned methods.
* </p>
*
* <p>
* Notice that this does <i>not</i> control whether scroll bars are shown
* for a scrollable component. That normally happens automatically when the
* content grows too big for the component, relying on the "overflow: auto"
* property in CSS.
* </p>
*
* @param isScrollingEnabled
* true if the scrolling is allowed.
*/
public void setScrollable(boolean isScrollingEnabled);
public void setScrollTop(int scrollTop);

}

+ 10
- 14
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java Просмотреть файл

@@ -1103,26 +1103,22 @@ public class ApplicationConnection {
private void createConnectorsIfNeeded(ValueMap json) {
VConsole.log(" * Creating connectors (if needed)");

JsArray<ValueMap> changes = json.getJSValueMapArray("changes");
// FIXME: This should be based on shared state, not the old
// "changes"
int length = changes.length();
for (int i = 0; i < length; i++) {
ValueMap types = json.getValueMap("types");
JsArrayString keyArray = types.getKeyArray();
for (int i = 0; i < keyArray.length(); i++) {
try {
final UIDL change = changes.get(i).cast();
final UIDL uidl = change.getChildUIDL(0);
String connectorId = uidl.getId();
String connectorId = keyArray.get(i);
String connectorType = types.getString(connectorId);
Connector connector = connectorMap
.getConnector(connectorId);
if (connector != null) {
continue;
}

// Connector does not exist so we must create it
if (!uidl.getTag().equals(
configuration.getEncodedWindowTag())) {
if (!connectorType.equals(configuration
.getEncodedWindowTag())) {
// create, initialize and register the paintable
getConnector(uidl.getId(), uidl.getTag());
getConnector(connectorId, connectorType);
} else {
// First RootConnector update. Before this the
// RootConnector has been created but not
@@ -1258,7 +1254,7 @@ public class ApplicationConnection {
// TODO This check should be done on the server side in
// the future so the hierarchy update is only sent when
// something actually has changed
Collection<ComponentConnector> oldChildren = ccc
List<ComponentConnector> oldChildren = ccc
.getChildren();
boolean actuallyChanged = !Util.collectionsEquals(
oldChildren, newChildren);
@@ -1272,7 +1268,7 @@ public class ApplicationConnection {
.create(ConnectorHierarchyChangedEvent.class);
event.setOldChildren(oldChildren);
event.setParent(ccc);
ccc.setChildren((Collection) newChildren);
ccc.setChildren((List) newChildren);
events.add(event);
} catch (final Throwable e) {
VConsole.error(e);

+ 3
- 3
src/com/vaadin/terminal/gwt/client/ComponentContainerConnector.java Просмотреть файл

@@ -4,7 +4,7 @@

package com.vaadin.terminal.gwt.client;

import java.util.Collection;
import java.util.List;

import com.google.gwt.user.client.ui.HasWidgets;

@@ -42,7 +42,7 @@ public interface ComponentContainerConnector extends ComponentConnector {
* @return A collection of children for this connector. An empty collection
* if there are no children. Never returns null.
*/
public Collection<ComponentConnector> getChildren();
public List<ComponentConnector> getChildren();

/**
* Sets the children for this connector. This method should only be called
@@ -57,7 +57,7 @@ public interface ComponentContainerConnector extends ComponentConnector {
* @param children
* The new child connectors
*/
public void setChildren(Collection<ComponentConnector> children);
public void setChildren(List<ComponentConnector> children);

/**
* Called when the child connector hierarchy of this connector has changed.

+ 4
- 4
src/com/vaadin/terminal/gwt/client/ConnectorHierarchyChangedEvent.java Просмотреть файл

@@ -1,6 +1,6 @@
package com.vaadin.terminal.gwt.client;

import java.util.Collection;
import java.util.List;

/**
* Event for containing data related to a change in the {@link Connector}
@@ -14,7 +14,7 @@ import java.util.Collection;
*
*/
public class ConnectorHierarchyChangedEvent {
Collection<ComponentConnector> oldChildren;
List<ComponentConnector> oldChildren;
private ComponentContainerConnector parent;

public ConnectorHierarchyChangedEvent() {
@@ -26,7 +26,7 @@ public class ConnectorHierarchyChangedEvent {
*
* @return A collection of old child connectors. Never returns null.
*/
public Collection<ComponentConnector> getOldChildren() {
public List<ComponentConnector> getOldChildren() {
return oldChildren;
}

@@ -36,7 +36,7 @@ public class ConnectorHierarchyChangedEvent {
* @param oldChildren
* The old child connectors. Must not be null.
*/
public void setOldChildren(Collection<ComponentConnector> oldChildren) {
public void setOldChildren(List<ComponentConnector> oldChildren) {
this.oldChildren = oldChildren;
}


+ 6
- 10
src/com/vaadin/terminal/gwt/client/ConnectorMap.java Просмотреть файл

@@ -188,15 +188,9 @@ public class ConnectorMap {
}

if (id == null) {
/*
* Uncomment the following to debug unregistring components. No
* paintables with null id should end here. At least one exception
* is our VScrollTableRow, that is hacked to fake it self as a
* Paintable to build support for sizing easier.
*/
// if (!(p instanceof VScrollTableRow)) {
// VConsole.log("Trying to unregister Paintable not created by Application Connection.");
// }
VConsole.log("Tried to unregister a "
+ connector.getClass().getName() + " (" + id
+ ") which was not registered");
} else {
unregistryBag.add(id);
}
@@ -212,7 +206,7 @@ public class ConnectorMap {
for (Connector connector : getConnectors()) {
if (connector instanceof ComponentConnector) {
ComponentConnector componentConnector = (ComponentConnector) connector;
if (!unregistryBag.contains(getConnectorId(connector))) {
if (!unregistryBag.contains(connector.getId())) {
result.add(componentConnector);
}
}
@@ -237,6 +231,8 @@ public class ConnectorMap {
+ ") that is never registered (or already unregistered)");
continue;
}
VConsole.log("Unregistering connector "
+ connector.getClass().getName() + " " + connectorId);
Widget widget = null;
if (connector instanceof ComponentConnector) {
widget = ((ComponentConnector) connector).getWidget();

+ 5
- 5
src/com/vaadin/terminal/gwt/client/ui/AbstractComponentContainerConnector.java Просмотреть файл

@@ -3,8 +3,8 @@
*/
package com.vaadin.terminal.gwt.client.ui;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.ComponentContainerConnector;
@@ -14,7 +14,7 @@ import com.vaadin.terminal.gwt.client.Util;
public abstract class AbstractComponentContainerConnector extends
AbstractComponentConnector implements ComponentContainerConnector {

Collection<ComponentConnector> children;
List<ComponentConnector> children;

/**
* Default constructor
@@ -28,7 +28,7 @@ public abstract class AbstractComponentContainerConnector extends
* @see
* com.vaadin.terminal.gwt.client.ComponentContainerConnector#getChildren()
*/
public Collection<ComponentConnector> getChildren() {
public List<ComponentConnector> getChildren() {
if (children == null) {
return new LinkedList<ComponentConnector>();
}
@@ -43,7 +43,7 @@ public abstract class AbstractComponentContainerConnector extends
* com.vaadin.terminal.gwt.client.ComponentContainerConnector#setChildren
* (java.util.Collection)
*/
public void setChildren(Collection<ComponentConnector> children) {
public void setChildren(List<ComponentConnector> children) {
this.children = children;
}

@@ -55,7 +55,7 @@ public abstract class AbstractComponentContainerConnector extends
* (com.vaadin.terminal.gwt.client.ConnectorHierarchyChangedEvent)
*/
public void connectorHierarchyChanged(ConnectorHierarchyChangedEvent event) {
//TODO Remove debug info
// TODO Remove debug info
System.out.println("Hierarchy changed for " + Util.getSimpleName(this));
System.out.println("* Old children: " + event.getOldChildren());
System.out.println("* New children: " + getChildren());

+ 86
- 22
src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java Просмотреть файл

@@ -12,12 +12,44 @@ import com.google.gwt.event.shared.HandlerRegistration;
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.ComponentState;
import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangedEvent;
import com.vaadin.terminal.gwt.client.LayoutManager;
import com.vaadin.terminal.gwt.client.UIDL;

public class PanelConnector extends AbstractComponentContainerConnector
implements SimpleManagedLayout, PostLayoutListener {

public static class PanelState extends ComponentState {
private int tabIndex;
private int scrollLeft, scrollTop;

public int getTabIndex() {
return tabIndex;
}

public void setTabIndex(int tabIndex) {
this.tabIndex = tabIndex;
}

public int getScrollLeft() {
return scrollLeft;
}

public void setScrollLeft(int scrollLeft) {
this.scrollLeft = scrollLeft;
}

public int getScrollTop() {
return scrollTop;
}

public void setScrollTop(int scrollTop) {
this.scrollTop = scrollTop;
}

}

public static final String CLICK_EVENT_IDENTIFIER = "click";

private Integer uidlScrollTop;
@@ -113,21 +145,21 @@ public class PanelConnector extends AbstractComponentContainerConnector
getWidget().handleError(uidl);

// Render content
final UIDL layoutUidl = uidl.getChildUIDL(0);
final ComponentConnector newLayout = client.getPaintable(layoutUidl);
if (newLayout != getWidget().layout) {
if (getWidget().layout != null) {
client.unregisterPaintable(getWidget().layout);
}
getWidget().setWidget(newLayout.getWidget());
getWidget().layout = newLayout;
}
getWidget().layout.updateFromUIDL(layoutUidl, client);
// final UIDL layoutUidl = uidl.getChildUIDL(0);
// final ComponentConnector newLayout = client.getPaintable(layoutUidl);
// if (newLayout != getWidget().layout) {
// if (getWidget().layout != null) {
// client.unregisterPaintable(getWidget().layout);
// }
// getWidget().setWidget(newLayout.getWidget());
// getWidget().layout = newLayout;
// }
// getWidget().layout.updateFromUIDL(layoutUidl, client);

// We may have actions attached to this panel
if (uidl.getChildCount() > 1) {
if (uidl.getChildCount() > 0) {
final int cnt = uidl.getChildCount();
for (int i = 1; i < cnt; i++) {
for (int i = 0; i < cnt; i++) {
UIDL childUidl = uidl.getChildUIDL(i);
if (childUidl.getTag().equals("actions")) {
if (getWidget().shortcutHandler == null) {
@@ -139,25 +171,20 @@ public class PanelConnector extends AbstractComponentContainerConnector
}
}

if (uidl.hasVariable("scrollTop")
&& uidl.getIntVariable("scrollTop") != getWidget().scrollTop) {
if (getState().getScrollTop() != getWidget().scrollTop) {
// Sizes are not yet up to date, so changing the scroll position
// is deferred to after the layout phase
uidlScrollTop = new Integer(uidl.getIntVariable("scrollTop"));
uidlScrollTop = getState().getScrollTop();
}

if (uidl.hasVariable("scrollLeft")
&& uidl.getIntVariable("scrollLeft") != getWidget().scrollLeft) {
if (getState().getScrollLeft() != getWidget().scrollLeft) {
// Sizes are not yet up to date, so changing the scroll position
// is deferred to after the layout phase
uidlScrollLeft = new Integer(uidl.getIntVariable("scrollLeft"));
uidlScrollLeft = getState().getScrollLeft();
}

// And apply tab index
if (uidl.hasVariable("tabindex")) {
getWidget().contentNode
.setTabIndex(uidl.getIntVariable("tabindex"));
}
getWidget().contentNode.setTabIndex(getState().getTabIndex());
}

public void updateCaption(ComponentConnector component, UIDL uidl) {
@@ -231,4 +258,41 @@ public class PanelConnector extends AbstractComponentContainerConnector
}
}

@Override
public PanelState getState() {
return (PanelState) super.getState();
}

@Override
protected PanelState createState() {
return GWT.create(PanelState.class);
}

@Override
public void connectorHierarchyChanged(ConnectorHierarchyChangedEvent event) {
super.connectorHierarchyChanged(event);

possiblyUnregisterOldChild(event);

// We always have 0 or 1 child
ComponentConnector newChild = null;
if (getChildren().size() != 0) {
// We now have one child
newChild = getChildren().get(0);
}

getWidget().setWidget(newChild.getWidget());
}

private void possiblyUnregisterOldChild(ConnectorHierarchyChangedEvent event) {
// Did we have a child that needs to be unregistered?
if (event.getOldChildren().size() != 0) {
ComponentConnector oldChild = event.getOldChildren().get(0);
// We had a child, unregister it
// TODO Should be handled by the framework
if (oldChild.getParent() == null) {
getConnection().unregisterPaintable(oldChild);
}
}
}
}

+ 0
- 3
src/com/vaadin/terminal/gwt/client/ui/VPanel.java Просмотреть файл

@@ -13,7 +13,6 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.SimplePanel;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.Focusable;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
@@ -39,8 +38,6 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner,

private Element errorIndicatorElement;

ComponentConnector layout;

ShortcutActionHandler shortcutHandler;

private String width = "";

+ 24
- 2
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java Просмотреть файл

@@ -814,6 +814,7 @@ public abstract class AbstractCommunicationManager implements
LinkedList<Paintable> stateQueue = new LinkedList<Paintable>();
LinkedList<Paintable> rpcPendingQueue = new LinkedList<Paintable>();
LinkedList<Paintable> hierarchyPendingQueue = new LinkedList<Paintable>();
LinkedList<Paintable> connectorTypeQueue = new LinkedList<Paintable>();

if (paintables != null) {

@@ -825,6 +826,9 @@ public abstract class AbstractCommunicationManager implements
final Paintable p = paintQueue.removeFirst();
// for now, all painted components may need a state refresh
stateQueue.push(p);
// TODO This should be optimized. The type only needs to be sent
// once for each connector id + on refresh
connectorTypeQueue.push(p);
// also a hierarchy update
hierarchyPendingQueue.push(p);
// ... and RPC calls to be sent
@@ -911,6 +915,24 @@ public abstract class AbstractCommunicationManager implements
outWriter.append(sharedStates.toString());
outWriter.print(", "); // close states
}
if (!connectorTypeQueue.isEmpty()) {
JSONObject connectorTypes = new JSONObject();
while (!connectorTypeQueue.isEmpty()) {
final Paintable p = connectorTypeQueue.pop();
String paintableId = getPaintableId(p);
String connectorType = paintTarget.getTag(p);
try {
connectorTypes.put(paintableId, connectorType);
} catch (JSONException e) {
throw new PaintException(
"Failed to send connector type for paintable "
+ paintableId + ": " + e.getMessage());
}
}
outWriter.print("\"types\":");
outWriter.append(connectorTypes.toString());
outWriter.print(", "); // close states
}
if (!hierarchyPendingQueue.isEmpty()) {
// Send update hierarchy information to the client.

@@ -932,7 +954,7 @@ public abstract class AbstractCommunicationManager implements
while (iterator.hasNext()) {
Component child = iterator.next();
if (child.getState().isVisible()) {
String childConnectorId = paintableIdMap.get(child);
String childConnectorId = getPaintableId(child);
children.put(childConnectorId);
}
}
@@ -947,7 +969,7 @@ public abstract class AbstractCommunicationManager implements
}
}
outWriter.append(hierarchyInfo.toString());
outWriter.print(", "); // close states
outWriter.print(", "); // close hierarchy

}


+ 30
- 143
src/com/vaadin/ui/Panel.java Просмотреть файл

@@ -17,9 +17,8 @@ import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Scrollable;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.ui.PanelConnector;
import com.vaadin.terminal.gwt.client.ui.PanelConnector.PanelState;
import com.vaadin.ui.Component.Focusable;
import com.vaadin.ui.themes.Reindeer;
import com.vaadin.ui.themes.Runo;

/**
* Panel - a simple single component container.
@@ -37,51 +36,17 @@ public class Panel extends AbstractComponentContainer implements Scrollable,

private static final String CLICK_EVENT = PanelConnector.CLICK_EVENT_IDENTIFIER;

/**
* Removes extra decorations from the Panel.
*
* @deprecated this style is no longer part of the core framework and this
* component, even though most built-in themes implement this
* style. Use the constant specified in the theme class file
* that you're using, if it provides one, e.g.
* {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT} .
*/
@Deprecated
public static final String STYLE_LIGHT = "light";

/**
* Content of the panel.
*/
private ComponentContainer content;

/**
* Scroll X position.
*/
private int scrollOffsetX = 0;

/**
* Scroll Y position.
*/
private int scrollOffsetY = 0;

/**
* Scrolling mode.
*/
private boolean scrollable = false;

/**
* Keeps track of the Actions added to this component, and manages the
* painting and handling as well.
*/
protected ActionManager actionManager;

/**
* By default the Panel is not in the normal document focus flow and can
* only be focused by using the focus()-method. Change this to 0 if you want
* to have the Panel in the normal focus flow.
*/
private int tabIndex = -1;

/**
* Creates a new empty panel. A VerticalLayout is used as content.
*/
@@ -98,7 +63,8 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
*/
public Panel(ComponentContainer content) {
setContent(content);
setWidth(100, UNITS_PERCENTAGE);
setWidth(100, Unit.PERCENTAGE);
getState().setTabIndex(-1);
}

/**
@@ -254,15 +220,9 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
*/
@Override
public void paintContent(PaintTarget target) throws PaintException {
// This is needed for now for paint to be ever run for the child
content.paint(target);

target.addVariable(this, "tabindex", getTabIndex());

if (isScrollable()) {
target.addVariable(this, "scrollLeft", getScrollLeft());
target.addVariable(this, "scrollTop", getScrollTop());
}

if (actionManager != null) {
actionManager.paintActions(null, target);
}
@@ -346,11 +306,11 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
final Integer newScrollY = (Integer) variables.get("scrollTop");
if (newScrollX != null && newScrollX.intValue() != getScrollLeft()) {
// set internally, not to fire request repaint
scrollOffsetX = newScrollX.intValue();
getState().setScrollLeft(newScrollX.intValue());
}
if (newScrollY != null && newScrollY.intValue() != getScrollTop()) {
// set internally, not to fire request repaint
scrollOffsetY = newScrollY.intValue();
getState().setScrollTop(newScrollY.intValue());
}

// Actions
@@ -368,15 +328,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
* @see com.vaadin.terminal.Scrollable#setScrollable(boolean)
*/
public int getScrollLeft() {
return scrollOffsetX;
}

/**
* @deprecated use {@link #getScrollLeft()} instead
*/
@Deprecated
public int getScrollOffsetX() {
return getScrollLeft();
return getState().getScrollLeft();
}

/*
@@ -385,110 +337,35 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
* @see com.vaadin.terminal.Scrollable#setScrollable(boolean)
*/
public int getScrollTop() {
return scrollOffsetY;
}

/**
* @deprecated use {@link #getScrollTop()} instead
*/
@Deprecated
public int getScrollOffsetY() {
return getScrollTop();
return getState().getScrollTop();
}

/*
* (non-Javadoc)
*
* @see com.vaadin.terminal.Scrollable#setScrollable(boolean)
*/
public boolean isScrollable() {
return scrollable;
}

/**
* Sets the panel as programmatically scrollable.
*
* <p>
* Panel is by default not scrollable programmatically with
* {@link #setScrollLeft(int)} and {@link #setScrollTop(int)}, so if you use
* those methods, you need to enable scrolling with this method. Components
* that extend Panel may have a different default for the programmatic
* scrollability.
* </p>
*
* @see com.vaadin.terminal.Scrollable#setScrollable(boolean)
*/
public void setScrollable(boolean isScrollingEnabled) {
if (scrollable != isScrollingEnabled) {
scrollable = isScrollingEnabled;
requestRepaint();
}
}

/**
* Sets the horizontal scroll position.
*
* <p>
* Setting the horizontal scroll position with this method requires that
* programmatic scrolling of the component has been enabled. For Panel it is
* disabled by default, so you have to call {@link #setScrollable(boolean)}.
* Components extending Panel may have a different default for programmatic
* scrollability.
* </p>
*
* @see com.vaadin.terminal.Scrollable#setScrollLeft(int)
* @see #setScrollable(boolean)
*/
public void setScrollLeft(int pixelsScrolled) {
if (pixelsScrolled < 0) {
public void setScrollLeft(int scrollLeft) {
if (scrollLeft < 0) {
throw new IllegalArgumentException(
"Scroll offset must be at least 0");
}
if (scrollOffsetX != pixelsScrolled) {
scrollOffsetX = pixelsScrolled;
requestRepaint();
}
}

/**
* @deprecated use setScrollLeft() method instead
*/
@Deprecated
public void setScrollOffsetX(int pixels) {
setScrollLeft(pixels);
getState().setScrollLeft(scrollLeft);
requestRepaint();
}

/**
* Sets the vertical scroll position.
*
* <p>
* Setting the vertical scroll position with this method requires that
* programmatic scrolling of the component has been enabled. For Panel it is
* disabled by default, so you have to call {@link #setScrollable(boolean)}.
* Components extending Panel may have a different default for programmatic
* scrollability.
* </p>
/*
* (non-Javadoc)
*
* @see com.vaadin.terminal.Scrollable#setScrollTop(int)
* @see #setScrollable(boolean)
*/
public void setScrollTop(int pixelsScrolledDown) {
if (pixelsScrolledDown < 0) {
public void setScrollTop(int scrollTop) {
if (scrollTop < 0) {
throw new IllegalArgumentException(
"Scroll offset must be at least 0");
}
if (scrollOffsetY != pixelsScrolledDown) {
scrollOffsetY = pixelsScrolledDown;
requestRepaint();
}
}

/**
* @deprecated use setScrollTop() method instead
*/
@Deprecated
public void setScrollOffsetY(int pixels) {
setScrollTop(pixels);
getState().setScrollTop(scrollTop);
requestRepaint();
}

/* Documented in superclass */
@@ -641,14 +518,14 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
* {@inheritDoc}
*/
public int getTabIndex() {
return tabIndex;
return getState().getTabIndex();
}

/**
* {@inheritDoc}
*/
public void setTabIndex(int tabIndex) {
this.tabIndex = tabIndex;
getState().setTabIndex(tabIndex);
requestRepaint();
}

@@ -670,4 +547,14 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
// This is so wrong... (#2924)
return content.getComponentCount();
}

@Override
public PanelState getState() {
return (PanelState) super.getState();
}

@Override
protected PanelState createState() {
return new PanelState();
}
}

+ 5
- 1
src/com/vaadin/ui/Window.java Просмотреть файл

@@ -21,6 +21,7 @@ import com.vaadin.event.ShortcutAction.ModifierKey;
import com.vaadin.event.ShortcutListener;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.gwt.client.ui.PanelConnector.PanelState;
import com.vaadin.terminal.gwt.client.ui.VView;
import com.vaadin.terminal.gwt.client.ui.WindowConnector;

@@ -73,6 +74,10 @@ import com.vaadin.terminal.gwt.client.ui.WindowConnector;
@ClientWidget(WindowConnector.class)
public class Window extends Panel implements FocusNotifier, BlurNotifier {

public class WindowState extends PanelState {

}

/**
* <b>Sub window only</b>. Top offset in pixels for the sub window (relative
* to the parent application window) or -1 if unspecified.
@@ -139,7 +144,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier {
*/
public Window(String caption, ComponentContainer content) {
super(caption, content);
setScrollable(true);
setSizeUndefined();
}


+ 0
- 1
tests/testbench/com/vaadin/tests/components/panel/BasicPanelTest.java Просмотреть файл

@@ -62,7 +62,6 @@ public class BasicPanelTest extends TestBase {
getLayout().addComponent(panel);
getLayout().setExpandRatio(panel, 1);

panel.setScrollable(true);
panel.setScrollTop(50);
panel.setScrollLeft(50);
panel.setImmediate(true);

+ 0
- 1
tests/testbench/com/vaadin/tests/components/panel/PanelShouldNotScroll.java Просмотреть файл

@@ -18,7 +18,6 @@ public class PanelShouldNotScroll extends TestBase {
@Override
protected void setup() {
final Panel p = new Panel(new CssLayout());
p.setScrollable(true);
p.setSizeFull();
p.setHeight("600px");
p.addComponent(foo());

+ 0
- 1
tests/testbench/com/vaadin/tests/components/tree/TreeScrollingOnSelection.java Просмотреть файл

@@ -36,7 +36,6 @@ public class TreeScrollingOnSelection extends TestBase {
tree.setImmediate(true);

Panel panel = new Panel();
panel.setScrollable(true);
panel.addComponent(tree);
panel.setWidth("200px");
panel.setHeight("300px");

+ 0
- 1
tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java Просмотреть файл

@@ -75,7 +75,6 @@ public class WindowScrollingComponentIntoView extends AbstractTestCase {

Panel panel = new Panel("scrollable panel");
panel.setHeight(400, Panel.UNITS_PIXELS);
panel.setScrollable(true);
panel.setScrollLeft(50);
panel.setScrollTop(50);
panel.getContent().setSizeUndefined();

+ 6
- 10
tests/testbench/com/vaadin/tests/tickets/Ticket1710.java Просмотреть файл

@@ -99,7 +99,6 @@ public class Ticket1710 extends com.vaadin.Application.LegacyApplication {
cb.setImmediate(true);
hidingControls.addComponent(cb);
elhp.setVisible(false);
elhp.setScrollable(true);
elh.setWidth("2000px");
elh.setHeight("100px");
addFields(elh);
@@ -251,7 +250,6 @@ public class Ticket1710 extends com.vaadin.Application.LegacyApplication {
Panel controlWrapper = new Panel();
controlWrapper.addComponent(controls);
controlWrapper.setWidth("100%");
controlWrapper.setScrollable(true);
controlWrapper.setStyleName("controls");
internalLayout.addComponent(controlWrapper);
Panel testPanel = new Panel(testPanelLayout);
@@ -392,15 +390,13 @@ public class Ticket1710 extends com.vaadin.Application.LegacyApplication {
}

private void updateMarginsAndSpacing() {
testedLayout.setMargin(
((Boolean) marginTop.getValue()).booleanValue(),
((Boolean) marginRight.getValue()).booleanValue(),
((Boolean) marginBottom.getValue()).booleanValue(),
((Boolean) marginLeft.getValue()).booleanValue());
testedLayout.setMargin(marginTop.getValue().booleanValue(),
marginRight.getValue().booleanValue(), marginBottom
.getValue().booleanValue(), marginLeft.getValue()
.booleanValue());
if (testedLayout instanceof Layout.SpacingHandler) {
((Layout.SpacingHandler) testedLayout)
.setSpacing(((Boolean) spacing.getValue())
.booleanValue());
((Layout.SpacingHandler) testedLayout).setSpacing(spacing
.getValue().booleanValue());
}
}


+ 0
- 1
tests/testbench/com/vaadin/tests/tickets/Ticket1804.java Просмотреть файл

@@ -107,7 +107,6 @@ public class Ticket1804 extends com.vaadin.Application.LegacyApplication {
}
Window w = new Window("Status of the fields");
w.setModal(true);
w.setScrollable(true);
w.setHeight("80%");
w.addComponent(new Label(msg.toString(), ContentMode.XHTML));
main.addWindow(w);

+ 0
- 1
tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java Просмотреть файл

@@ -69,7 +69,6 @@ public class Ticket1834PanelScrolling extends
main.addComponent(b);

p = new Panel("TestPanel");
p.setScrollable(true);

for (int i = 0; i < ROWS; i++) {
p.addComponent(new Label(

+ 0
- 2
tests/testbench/com/vaadin/tests/tickets/Ticket1869.java Просмотреть файл

@@ -32,7 +32,6 @@ public class Ticket1869 extends com.vaadin.Application.LegacyApplication {
lo.addComponent(elp);
elp.setWidth("300px");
elp.setHeight("300px");
elp.setScrollable(true);

HorizontalLayout elh = new HorizontalLayout();
Panel elph = new Panel(
@@ -49,7 +48,6 @@ public class Ticket1869 extends com.vaadin.Application.LegacyApplication {
lo.addComponent(elph);
elph.setWidth("300px");
elph.setHeight("300px");
elph.setScrollable(true);

}
}

+ 0
- 1
tests/testbench/com/vaadin/tests/tickets/Ticket1923.java Просмотреть файл

@@ -19,7 +19,6 @@ public class Ticket1923 extends com.vaadin.Application.LegacyApplication {

p = new Panel("TestPanel 250x300");
// p.getLayout().setWidth("100%");
p.setScrollable(true);
// p.setContent(new GridLayout(1, 100));
for (int i = 0; i < ROWS; i++) {
p.addComponent(new Label(

+ 0
- 1
tests/testbench/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java Просмотреть файл

@@ -45,7 +45,6 @@ public class EmptyFieldErrorIndicators extends TestBase {
panel.setSizeFull();
panel.setStyleName(Reindeer.PANEL_LIGHT);
panel.addComponent(hl);
panel.setScrollable(true);
addComponent(panel);
}


Загрузка…
Отмена
Сохранить