From 51664d073aac5b1fcd3fe1fc28a8b3af5608770e Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 21 Jul 2010 13:26:01 +0000 Subject: [PATCH] test case for #4175 svn changeset:14288/svn branch:6.4 --- .../RichTextAreaWithKeyboardShortcuts.java | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/richtextarea/RichTextAreaWithKeyboardShortcuts.java diff --git a/tests/src/com/vaadin/tests/components/richtextarea/RichTextAreaWithKeyboardShortcuts.java b/tests/src/com/vaadin/tests/components/richtextarea/RichTextAreaWithKeyboardShortcuts.java new file mode 100644 index 0000000000..a6bd70a2d0 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/richtextarea/RichTextAreaWithKeyboardShortcuts.java @@ -0,0 +1,77 @@ +package com.vaadin.tests.components.richtextarea; + +import com.vaadin.event.Action; +import com.vaadin.event.ShortcutAction; +import com.vaadin.event.Action.Handler; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbstractField; +import com.vaadin.ui.Component; +import com.vaadin.ui.Panel; +import com.vaadin.ui.RichTextArea; +import com.vaadin.ui.Window; + +@SuppressWarnings("serial") +public class RichTextAreaWithKeyboardShortcuts extends TestBase { + + private Handler actionHandler = new Handler() { + + ShortcutAction save = new ShortcutAction("^Save"); + private Action[] actions = new Action[] { save }; + + public void handleAction(Action action, Object sender, Object target) { + String msg = "Action: " + action.getCaption(); + msg += " From : " + sender.getClass().getSimpleName() + " '" + + ((Component) sender).getCaption() + "'"; + + AbstractField f = (AbstractField) target; + msg += " Target:" + target.getClass().getSimpleName() + " '" + + f.getCaption() + "'"; + + String string = f.getValue().toString(); + + msg += " Value: " + string; + f.getWindow().showNotification(msg); + + } + + public Action[] getActions(Object target, Object sender) { + return actions; + } + }; + + @Override + protected void setup() { + + getLayout().getWindow().addActionHandler(actionHandler); + getLayout().addComponent(createRichTextArea("InMainLayout")); + + Panel panel = new Panel("RTA Panel"); + panel.addActionHandler(actionHandler); + panel.getContent().addComponent(createRichTextArea("InPanel")); + getLayout().addComponent(panel); + + Window w = new Window("SubWindow"); + w.addActionHandler(actionHandler); + w.addComponent(createRichTextArea("InSubWindow")); + w.getContent().setSizeUndefined(); + + getLayout().getWindow().addWindow(w); + + } + + private RichTextArea createRichTextArea(String caption) { + RichTextArea rta = new RichTextArea(caption); + return rta; + } + + @Override + protected String getDescription() { + return "RichTextArea shouls support shortcut actions just like other components do."; + } + + @Override + protected Integer getTicketNumber() { + return 4175; + } + +} -- 2.39.5