From aafe2fb0be0c801bb63882a3afbf8b431035bd97 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 26 Apr 2011 14:52:10 +0000 Subject: [PATCH] Add support for actions for Table when no row is selected svn changeset:18475/svn branch:6.6 --- .../select/AbstractSelectTestCase.java | 2 +- .../vaadin/tests/components/table/Tables.java | 16 ++++++++++++++-- .../com/vaadin/tests/components/tree/Trees.java | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/src/com/vaadin/tests/components/select/AbstractSelectTestCase.java b/tests/src/com/vaadin/tests/components/select/AbstractSelectTestCase.java index dbc66ff8c3..528fbd7edd 100644 --- a/tests/src/com/vaadin/tests/components/select/AbstractSelectTestCase.java +++ b/tests/src/com/vaadin/tests/components/select/AbstractSelectTestCase.java @@ -38,7 +38,7 @@ public abstract class AbstractSelectTestCase extends items.add(new Action(caption, icon)); } - public Action[] getActions() { + public Action[] getActions(Object target, Object sender) { Action[] actions = new Action[items.size()]; for (int i = 0; i < items.size(); i++) { actions[i] = items.get(i); diff --git a/tests/src/com/vaadin/tests/components/table/Tables.java b/tests/src/com/vaadin/tests/components/table/Tables.java index 46165a5fd4..4a0b914534 100644 --- a/tests/src/com/vaadin/tests/components/table/Tables.java +++ b/tests/src/com/vaadin/tests/components/table/Tables.java @@ -134,7 +134,7 @@ public class Tables extends AbstractSelectTestCase implements } public Action[] getActions(Object target, Object sender) { - return value.getActions(); + return value.getActions(target, sender); } }); } @@ -184,10 +184,22 @@ public class Tables extends AbstractSelectTestCase
implements ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE)); options.put("Empty", new ContextMenu() { @Override - public Action[] getActions() { + public Action[] getActions(Object target, Object sender) { return null; } }); + options.put("Edit/New", new ContextMenu() { + @Override + public Action[] getActions(Object itemId, Object component) { + if (itemId == null) { + return new Action[] { new Action("New..."), + new Action("Common action") }; + } else { + return new Action[] { new Action("Edit " + itemId), + new Action("Common action") }; + } + } + }); createSelectAction("Context menu", category, options, "None", contextMenuCommand, true); diff --git a/tests/src/com/vaadin/tests/components/tree/Trees.java b/tests/src/com/vaadin/tests/components/tree/Trees.java index dbb340d0ef..076e0c9dda 100644 --- a/tests/src/com/vaadin/tests/components/tree/Trees.java +++ b/tests/src/com/vaadin/tests/components/tree/Trees.java @@ -92,7 +92,7 @@ public class Trees extends AbstractSelectTestCase implements } public Action[] getActions(Object target, Object sender) { - return value.getActions(); + return value.getActions(target, sender); } }); } -- 2.39.5