From: John Ahlroos Date: Fri, 7 Sep 2012 05:51:58 +0000 (+0300) Subject: Applied CSSLayout patch for #9357 X-Git-Tag: 7.0.0.beta1~155 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=33626d382db8dec4bec3d51795321476e5321fea;p=vaadin-framework.git Applied CSSLayout patch for #9357 --- diff --git a/client/src/com/vaadin/client/ComponentLocator.java b/client/src/com/vaadin/client/ComponentLocator.java index 42b1f06d20..68c97badfb 100644 --- a/client/src/com/vaadin/client/ComponentLocator.java +++ b/client/src/com/vaadin/client/ComponentLocator.java @@ -26,6 +26,7 @@ import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ui.SubPartAware; +import com.vaadin.client.ui.csslayout.VCssLayout; import com.vaadin.client.ui.gridlayout.VGridLayout; import com.vaadin.client.ui.orderedlayout.VOrderedLayout; import com.vaadin.client.ui.tabsheet.VTabsheetPanel; @@ -507,6 +508,14 @@ public class ComponentLocator { continue; } + // FlowPane in CSSLayout has been removed -> skip it + if (w instanceof VCssLayout + && "VCssLayout$FlowPane".equals(widgetClassName)) { + continue; + } + + // ChildComponentContainer has been removed and replaced with + // VOrderLayout.Slot's if (w instanceof VOrderedLayout && "ChildComponentContainer".equals(widgetClassName)) { widgetClassName = "VOrderedLayout$Slot"; diff --git a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java index cc1d15e026..4fdd10de34 100644 --- a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java @@ -30,13 +30,16 @@ import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractLayoutConnector; import com.vaadin.client.ui.LayoutClickEventHandler; -import com.vaadin.client.ui.csslayout.VCssLayout.FlowPane; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.LayoutClickRpc; import com.vaadin.shared.ui.csslayout.CssLayoutServerRpc; import com.vaadin.shared.ui.csslayout.CssLayoutState; import com.vaadin.ui.CssLayout; +/** + * Connects the server side widget {@link CssLayout} with the client side + * counterpart {@link VCssLayout} + */ @Connect(CssLayout.class) public class CssLayoutConnector extends AbstractLayoutConnector { @@ -59,17 +62,34 @@ public class CssLayoutConnector extends AbstractLayoutConnector { private Map childToCaption = new HashMap(); + /* + * (non-Javadoc) + * + * @see com.vaadin.client.ui.AbstractComponentConnector#init() + */ @Override protected void init() { super.init(); rpc = RpcProxy.create(CssLayoutServerRpc.class, this); } + /* + * (non-Javadoc) + * + * @see com.vaadin.client.ui.AbstractLayoutConnector#getState() + */ @Override public CssLayoutState getState() { return (CssLayoutState) super.getState(); } + /* + * (non-Javadoc) + * + * @see + * com.vaadin.client.ui.AbstractComponentConnector#onStateChanged(com.vaadin + * .client.communication.StateChangeEvent) + */ @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); @@ -94,6 +114,13 @@ public class CssLayoutConnector extends AbstractLayoutConnector { } + /* + * (non-Javadoc) + * + * @see com.vaadin.client.ui.AbstractComponentContainerConnector# + * onConnectorHierarchyChange + * (com.vaadin.client.ConnectorHierarchyChangeEvent) + */ @Override public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { super.onConnectorHierarchyChange(event); @@ -101,13 +128,12 @@ public class CssLayoutConnector extends AbstractLayoutConnector { clickEventHandler.handleEventHandlerRegistration(); int index = 0; - FlowPane cssLayoutWidgetContainer = getWidget().panel; for (ComponentConnector child : getChildComponents()) { VCaption childCaption = childToCaption.get(child); if (childCaption != null) { - cssLayoutWidgetContainer.addOrMove(childCaption, index++); + getWidget().addOrMove(childCaption, index++); } - cssLayoutWidgetContainer.addOrMove(child.getWidget(), index++); + getWidget().addOrMove(child.getWidget(), index++); } // Detach old child widgets and possibly their caption @@ -116,14 +142,21 @@ public class CssLayoutConnector extends AbstractLayoutConnector { // Skip current children continue; } - cssLayoutWidgetContainer.remove(child.getWidget()); + getWidget().remove(child.getWidget()); VCaption vCaption = childToCaption.remove(child); if (vCaption != null) { - cssLayoutWidgetContainer.remove(vCaption); + getWidget().remove(vCaption); } } } + /** + * Converts a css property string to CamelCase + * + * @param cssProperty + * The property string + * @return A string converted to camelcase + */ private static final String makeCamelCase(String cssProperty) { // TODO this might be cleaner to implement with regexp while (cssProperty.contains("-")) { @@ -142,17 +175,27 @@ public class CssLayoutConnector extends AbstractLayoutConnector { return cssProperty; } + /* + * (non-Javadoc) + * + * @see com.vaadin.client.ui.AbstractComponentConnector#getWidget() + */ @Override public VCssLayout getWidget() { return (VCssLayout) super.getWidget(); } + /* + * (non-Javadoc) + * + * @see + * com.vaadin.client.ComponentContainerConnector#updateCaption(com.vaadin + * .client.ComponentConnector) + */ @Override public void updateCaption(ComponentConnector child) { Widget childWidget = child.getWidget(); - FlowPane cssLayoutWidgetContainer = getWidget().panel; - int widgetPosition = cssLayoutWidgetContainer - .getWidgetIndex(childWidget); + int widgetPosition = getWidget().getWidgetIndex(childWidget); VCaption caption = childToCaption.get(child); if (VCaption.isNeeded(child.getState())) { @@ -162,13 +205,12 @@ public class CssLayoutConnector extends AbstractLayoutConnector { } if (!caption.isAttached()) { // Insert caption at widget index == before widget - cssLayoutWidgetContainer.insert(caption, widgetPosition); + getWidget().insert(caption, widgetPosition); } caption.updateCaption(); } else if (caption != null) { childToCaption.remove(child); - cssLayoutWidgetContainer.remove(caption); + getWidget().remove(caption); } } - } diff --git a/client/src/com/vaadin/client/ui/csslayout/VCssLayout.java b/client/src/com/vaadin/client/ui/csslayout/VCssLayout.java index 2aeec53e27..b4db3d00e6 100644 --- a/client/src/com/vaadin/client/ui/csslayout/VCssLayout.java +++ b/client/src/com/vaadin/client/ui/csslayout/VCssLayout.java @@ -16,52 +16,40 @@ package com.vaadin.client.ui.csslayout; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.ui.themes.BaseTheme; -public class VCssLayout extends SimplePanel { - public static final String TAGNAME = "csslayout"; - public static final String CLASSNAME = "v-" + TAGNAME; - - FlowPane panel = new FlowPane(); +/** + * VCCSlayout is a layout which supports configuring it's children with CSS + * selectors + */ +public class VCssLayout extends FlowPanel { - Element margin = DOM.createDiv(); + public static final String CLASSNAME = "v-csslayout"; + /** + * Default constructor + */ public VCssLayout() { super(); - getElement().appendChild(margin); setStyleName(BaseTheme.UI_LAYOUT); addStyleName(CLASSNAME); - margin.setClassName(CLASSNAME + "-margin"); - setWidget(panel); } - @Override - protected Element getContainerElement() { - return margin; - } - - public class FlowPane extends FlowPanel { - - public FlowPane() { - super(); - setStyleName(CLASSNAME + "-container"); - } - - void addOrMove(Widget child, int index) { - if (child.getParent() == this) { - int currentIndex = getWidgetIndex(child); - if (index == currentIndex) { - return; - } + /** + * Add or move a child in the + * + * @param child + * @param index + */ + void addOrMove(Widget child, int index) { + if (child.getParent() == this) { + int currentIndex = getWidgetIndex(child); + if (index == currentIndex) { + return; } - insert(child, index); } - + insert(child, index); } - } diff --git a/uitest/eclipse-run-selected-test.properties b/uitest/eclipse-run-selected-test.properties index 49925925bc..8f05438ff6 100644 --- a/uitest/eclipse-run-selected-test.properties +++ b/uitest/eclipse-run-selected-test.properties @@ -1,12 +1,12 @@ ; Location where vaadin-testbench jar can be found -com.vaadin.testbench.lib.dir= +com.vaadin.testbench.lib.dir=/home2/vaadin-testbench-2.4.3.development.201208101302/vaadin-testbench-2.4.3.development.201208101302 ; Deployment url to use for testing. Context path must be / -com.vaadin.testbench.deployment.url=http://:8888/ +com.vaadin.testbench.deployment.url=http://192.168.2.51:8080/ ; Location of the screenshot directory. ; This is the directory that contains the "references" directory -com.vaadin.testbench.screenshot.directory= +com.vaadin.testbench.screenshot.directory=/home/john/Repositories/vaadin/vaadin-screenshots ; Run the whole test even if com.vaadin.testbench.screenshot.softfail=true