Change-Id: Iad410f26ed7f20bb03f15c46673f6f18081261d9tags/7.2.0
@@ -43,6 +43,7 @@ import com.vaadin.client.ComponentConnector; | |||
import com.vaadin.client.Util; | |||
import com.vaadin.client.VCaptionWrapper; | |||
import com.vaadin.client.VConsole; | |||
import com.vaadin.client.communication.StateChangeEvent; | |||
import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; | |||
import com.vaadin.client.ui.popupview.VisibilityChangeEvent; | |||
import com.vaadin.client.ui.popupview.VisibilityChangeHandler; | |||
@@ -193,7 +194,8 @@ public class VPopupView extends HTML implements Iterable<Widget> { | |||
* (other than it being a VOverlay) is to be considered private and | |||
* potentially subject to change. | |||
*/ | |||
public class CustomPopup extends VOverlay { | |||
public class CustomPopup extends VOverlay implements | |||
StateChangeEvent.StateChangeHandler { | |||
private ComponentConnector popupComponentConnector = null; | |||
@@ -333,7 +335,9 @@ public class VPopupView extends HTML implements Iterable<Widget> { | |||
@Override | |||
public boolean remove(Widget w) { | |||
if (popupComponentConnector != null) { | |||
popupComponentConnector.removeStateChangeHandler(this); | |||
} | |||
popupComponentConnector = null; | |||
popupComponentWidget = null; | |||
captionWrapper = null; | |||
@@ -344,10 +348,15 @@ public class VPopupView extends HTML implements Iterable<Widget> { | |||
public void setPopupConnector(ComponentConnector newPopupComponent) { | |||
if (newPopupComponent != popupComponentConnector) { | |||
if (popupComponentConnector != null) { | |||
popupComponentConnector.removeStateChangeHandler(this); | |||
} | |||
Widget newWidget = newPopupComponent.getWidget(); | |||
setWidget(newWidget); | |||
popupComponentWidget = newWidget; | |||
popupComponentConnector = newPopupComponent; | |||
popupComponentConnector.addStateChangeHandler("height", this); | |||
popupComponentConnector.addStateChangeHandler("width", this); | |||
} | |||
} | |||
@@ -361,6 +370,11 @@ public class VPopupView extends HTML implements Iterable<Widget> { | |||
return super.getContainerElement(); | |||
} | |||
@Override | |||
public void onStateChanged(StateChangeEvent stateChangeEvent) { | |||
positionOrSizeUpdated(); | |||
} | |||
}// class CustomPopup | |||
public HandlerRegistration addVisibilityChangeHandler( |
@@ -83,6 +83,8 @@ | |||
<dependency org="junit" name="junit" rev="4.11" | |||
conf="build,ide -> default" /> | |||
<dependency org="org.hamcrest" name="hamcrest-all" rev="1.3" | |||
conf="build,ide->default" /> | |||
<dependency org="com.jcraft" name="jsch" rev="0.1.50" | |||
conf="ide, build->default" /> | |||
<dependency org="commons-codec" name="commons-codec" |
@@ -0,0 +1,73 @@ | |||
/* | |||
* Copyright 2000-2013 Vaadin Ltd. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | |||
* use this file except in compliance with the License. You may obtain a copy of | |||
* the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.components.popupview; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.Component; | |||
import com.vaadin.ui.PopupView; | |||
import com.vaadin.ui.VerticalLayout; | |||
/** | |||
* Resizing PopupView's popup component while it is visible should also resize | |||
* the drop shadow of the overlay. | |||
* | |||
* @author Vaadin Ltd | |||
*/ | |||
public class PopupViewResizeWhileOpen extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
PopupView pv = new PopupView(new PopupView.Content() { | |||
@Override | |||
public Component getPopupComponent() { | |||
final VerticalLayout popupComponent = new VerticalLayout(); | |||
popupComponent.setId("content-vl"); | |||
popupComponent.setWidth("640px"); | |||
popupComponent.setHeight("480px"); | |||
Button button = new Button("Change height!", | |||
new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(Button.ClickEvent event) { | |||
popupComponent.setHeight("320px"); | |||
} | |||
}); | |||
popupComponent.addComponent(button); | |||
return popupComponent; | |||
} | |||
@Override | |||
public String getMinimizedValueAsHTML() { | |||
return "Click me!"; | |||
} | |||
}); | |||
pv.setHideOnMouseOut(false); | |||
addComponent(pv); | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Resize PopupView's content component while visible"; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 13666; | |||
} | |||
} |
@@ -0,0 +1,70 @@ | |||
/* | |||
* Copyright 2000-2013 Vaadin Ltd. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | |||
* use this file except in compliance with the License. You may obtain a copy of | |||
* the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.components.popupview; | |||
import static org.hamcrest.MatcherAssert.assertThat; | |||
import static org.hamcrest.Matchers.greaterThan; | |||
import static org.hamcrest.Matchers.is; | |||
import static org.hamcrest.Matchers.lessThan; | |||
import org.junit.Test; | |||
import org.openqa.selenium.By; | |||
import org.openqa.selenium.Dimension; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.elements.ButtonElement; | |||
import com.vaadin.testbench.elements.PopupViewElement; | |||
import com.vaadin.testbench.elements.VerticalLayoutElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
/** | |||
* Resizing PopupView's popup component while it is visible should also resize | |||
* the drop shadow of the overlay. | |||
* | |||
* @author Vaadin Ltd | |||
*/ | |||
public class PopupViewResizeWhileOpenTest extends MultiBrowserTest { | |||
@Test | |||
public void testCustomPopupSizeAfterResize() { | |||
openTestURL(); | |||
// Open PopupView | |||
$(PopupViewElement.class).first().click(); | |||
// Shadow element | |||
WebElement shadow = findElement(By.className("v-shadow")); | |||
WebElement vl = $(VerticalLayoutElement.class).id("content-vl"); | |||
// Sanity check | |||
assertShadowSize(vl, shadow); | |||
// Resize | |||
$(ButtonElement.class).first().click(); | |||
assertShadowSize(vl, shadow); | |||
} | |||
private void assertShadowSize(WebElement layout, WebElement shadow) { | |||
Dimension shadowSize = shadow.getSize(); | |||
Dimension layoutSize = layout.getSize(); | |||
assertThat(shadowSize.height, is(greaterThan(layoutSize.height))); | |||
assertThat(shadowSize.height, is(lessThan(layoutSize.height + 10))); | |||
assertThat(shadowSize.width, is(greaterThan(layoutSize.width))); | |||
assertThat(shadowSize.width, is(lessThan(layoutSize.width + 10))); | |||
} | |||
} |