summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-11-20 16:53:49 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-21 13:41:46 +0000
commitfeac70070091a3d823632a7396ec4eef0886f5b2 (patch)
tree6f30cfdeb85bc7969d5f4c98e425e0b482d7e65c /uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
parent29ea66b5bad701db2a3f6e2c67a143678d1dd52a (diff)
downloadvaadin-framework-feac70070091a3d823632a7396ec4eef0886f5b2.tar.gz
vaadin-framework-feac70070091a3d823632a7396ec4eef0886f5b2.zip
Remove AddonContext (#10254)
Change-Id: I12d3075a4808b004d7b891d1c4092131fa7cb1a2
Diffstat (limited to 'uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java')
-rw-r--r--uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java53
1 files changed, 52 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
index 35f7aeb044..512d89a381 100644
--- a/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
+++ b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
@@ -16,15 +16,66 @@
package com.vaadin.tests.vaadincontext;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.server.BootstrapFragmentResponse;
+import com.vaadin.server.BootstrapListener;
+import com.vaadin.server.BootstrapPageResponse;
+import com.vaadin.server.BootstrapResponse;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.UI;
public class BootstrapModifyUI extends AbstractTestUI {
+ private static final String INSTALLED_ATRIBUTE_NAME = BootstrapModifyUI.class
+ .getName() + ".installed";
@Override
protected void setup(VaadinRequest request) {
- // TODO Auto-generated method stub
+ Button c = new Button("Add bootstrap listener",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ getSession().addBootstrapListener(
+ createBootstrapListener());
+ event.getButton().setEnabled(false);
+ getSession().setAttribute(INSTALLED_ATRIBUTE_NAME,
+ Boolean.TRUE);
+ }
+ });
+ addComponent(c);
+ c.setEnabled(getSession().getAttribute(INSTALLED_ATRIBUTE_NAME) == null);
+ }
+
+ private static BootstrapListener createBootstrapListener() {
+ return new BootstrapListener() {
+ @Override
+ public void modifyBootstrapFragment(
+ BootstrapFragmentResponse response) {
+ if (shouldModify(response)) {
+ Element heading = new Element(Tag.valueOf("div"), "")
+ .text("Added by modifyBootstrapFragment");
+ response.getFragmentNodes().add(0, heading);
+ }
+ }
+
+ private boolean shouldModify(BootstrapResponse response) {
+ Class<? extends UI> uiClass = response.getUiClass();
+ boolean shouldModify = uiClass == BootstrapModifyUI.class;
+ return shouldModify;
+ }
+ @Override
+ public void modifyBootstrapPage(BootstrapPageResponse response) {
+ if (shouldModify(response)) {
+ response.getDocument().body().child(0)
+ .before("<div>Added by modifyBootstrapPage</div>");
+ }
+ }
+ };
}
@Override