From: Matti Tahvonen Date: Mon, 26 Oct 2009 16:21:01 +0000 (+0000) Subject: merged [9380] from 6.1 X-Git-Tag: 6.7.0.beta1~2389 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8c7b4b7e8bd9fc8bcdc572ae13c66eddc01ba4d7;p=vaadin-framework.git merged [9380] from 6.1 svn changeset:9381/svn branch:6.2 --- diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java index c0fe8fd8d1..8e8a640e47 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java @@ -14,6 +14,7 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RootPanel; @@ -28,6 +29,7 @@ import com.vaadin.terminal.gwt.client.VCaption; import com.vaadin.terminal.gwt.client.VCaptionWrapper; import com.vaadin.terminal.gwt.client.VTooltip; import com.vaadin.terminal.gwt.client.RenderInformation.Size; +import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea; public class VPopupView extends HTML implements Container, Iterable { @@ -274,6 +276,9 @@ public class VPopupView extends HTML implements Container, Iterable { // Notify children with focus if ((popupComponentWidget instanceof Focusable)) { ((Focusable) popupComponentWidget).setFocus(false); + } else { + + checkForRTE(popupComponentWidget); } // Notify children that have used the keyboard @@ -286,6 +291,19 @@ public class VPopupView extends HTML implements Container, Iterable { activeChildren.clear(); } + private void checkForRTE(Widget popupComponentWidget2) { + if (popupComponentWidget2 instanceof VRichTextArea) { + ((VRichTextArea) popupComponentWidget2) + .synchronizeContentToServer(); + } else if (popupComponentWidget2 instanceof HasWidgets) { + HasWidgets hw = (HasWidgets) popupComponentWidget2; + Iterator iterator = hw.iterator(); + while (iterator.hasNext()) { + checkForRTE(iterator.next()); + } + } + } + @Override public boolean remove(Widget w) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java index c4f27dd974..9a825347ac 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java +++ b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java @@ -28,9 +28,9 @@ import com.vaadin.terminal.gwt.client.ui.Field; /** * This class implements a basic client side rich text editor component. - * + * * @author IT Mill Ltd. - * + * */ public class VRichTextArea extends Composite implements Paintable, Field, ChangeHandler, BlurHandler, KeyPressHandler { @@ -132,15 +132,21 @@ public class VRichTextArea extends Composite implements Paintable, Field, // TODO is this really used, or does everything go via onBlur() only? public void onChange(ChangeEvent event) { + synchronizeContentToServer(); + } + + /** + * Method is public to let popupview force synchronization on close. + */ + public void synchronizeContentToServer() { + final String html = rta.getHTML(); if (client != null && id != null) { - client.updateVariable(id, "text", rta.getText(), immediate); + client.updateVariable(id, "text", html, immediate); } } public void onBlur(BlurEvent event) { - final String html = rta.getHTML(); - client.updateVariable(id, "text", html, immediate); - + synchronizeContentToServer(); } /** diff --git a/src/com/vaadin/tests/components/popupview/PopupViewWithRTE.java b/src/com/vaadin/tests/components/popupview/PopupViewWithRTE.java new file mode 100644 index 0000000000..06319a5019 --- /dev/null +++ b/src/com/vaadin/tests/components/popupview/PopupViewWithRTE.java @@ -0,0 +1,50 @@ +package com.vaadin.tests.components.popupview; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Component; +import com.vaadin.ui.PopupView; +import com.vaadin.ui.RichTextArea; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.PopupView.Content; + +public class PopupViewWithRTE extends TestBase { + + @Override + protected String getDescription() { + return "Rich text editor should work properly in popupview. Try to edit text below."; + } + + @Override + protected Integer getTicketNumber() { + return 3043; + } + + @Override + protected void setup() { + PopupView pv = new PopupView(new Content() { + + RichTextArea rte = new RichTextArea(); + + VerticalLayout vl = new VerticalLayout(); + + public String getMinimizedValueAsHTML() { + Object value = rte.getValue(); + if (value == null || "".equals(value)) { + value = "Initial content for

rte

."; + rte.setValue(value); + rte.setHeight("150px"); + rte.setWidth("100%"); + vl.addComponent(rte); + vl.setWidth("600px"); + } + return value.toString(); + } + + public Component getPopupComponent() { + return vl; + } + }); + getLayout().addComponent(pv); + } + +}