summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/tests/tickets/Ticket1598.java
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
committerHenri Sara <henri.sara@itmill.com>2009-05-11 09:19:03 +0000
commitadc8c0ad3573272c236040c3a76005b9e73a5737 (patch)
treea3860704dbd5b82dc6af38684b80f8ef79a32722 /src/com/vaadin/tests/tickets/Ticket1598.java
parent5abc870dda584d0c2fc47fd5eec4ae3de3fa240e (diff)
downloadvaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.tar.gz
vaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.zip
#2904: initial bulk rename "com.itmill.toolkit" -> "com.vaadin"
- com.itmill.toolkit.external not yet fully renamed svn changeset:7715/svn branch:6.0
Diffstat (limited to 'src/com/vaadin/tests/tickets/Ticket1598.java')
-rw-r--r--src/com/vaadin/tests/tickets/Ticket1598.java126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/com/vaadin/tests/tickets/Ticket1598.java b/src/com/vaadin/tests/tickets/Ticket1598.java
new file mode 100644
index 0000000000..ca2da6d010
--- /dev/null
+++ b/src/com/vaadin/tests/tickets/Ticket1598.java
@@ -0,0 +1,126 @@
+package com.vaadin.tests.tickets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.MenuBar.Command;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+public class Ticket1598 extends Application {
+
+ Window main = new Window("MenuBar test");
+
+ final MenuBar menuBar = new MenuBar();
+
+ @Override
+ public void init() {
+ setMainWindow(main);
+ setTheme("default");
+
+ List<MenuItem> itemList = new ArrayList<MenuItem>();
+ // Populate the menu bar
+ for (int i = 0; i < 6; i++) {
+ itemList.add(menuBar.addItem(new String("Menu " + i), null, null));
+ }
+
+ MenuItem first = itemList.get(0);
+
+ for (int i = 0; i < 5; i++) {
+ first.addItem(new String("Submenu item" + i), null, new Command() {
+
+ public void menuSelected(MenuItem selected) {
+ main.showNotification("Action " + selected.getText());
+ }
+ });
+ }
+
+ MenuItem firstSubItem1 = first.getChildren().get(1);
+
+ for (int i = 0; i < 3; i++) {
+ firstSubItem1.addItem(new String("Subsubmenu item" + i), null,
+ new Command() {
+
+ public void menuSelected(MenuItem selected) {
+ main.showNotification("Action "
+ + selected.getText());
+ }
+ });
+ }
+ MenuItem firstSubItem2 = first.getChildren().get(3);
+
+ for (int i = 0; i < 3; i++) {
+ firstSubItem2.addItem(new String("Subsubmenu item" + i), null,
+ new Command() {
+
+ public void menuSelected(MenuItem selected) {
+ main.showNotification("Action "
+ + selected.getText());
+ }
+ });
+ }
+
+ MenuItem second = menuBar.getItems().get(1);
+
+ for (int i = 0; i < 5; i++) {
+ second.addItem(new String("Second submenu item" + i), null,
+ new Command() {
+
+ public void menuSelected(MenuItem selected) {
+ main.showNotification("Action "
+ + selected.getText());
+ }
+ });
+ }
+
+ MenuItem third = menuBar.getItems().get(2);
+ third.setIcon(new ThemeResource("icons/16/document.png"));
+
+ for (int i = 2; i <= 3; i++) {
+ ((MenuItem) menuBar.getItems().get(i)).setCommand(new Command() {
+
+ public void menuSelected(MenuItem selectedItem) {
+ main.showNotification("Action " + selectedItem.getText());
+ }
+ });
+ }
+
+ final MenuItem fourth = menuBar.getItems().get(3);
+ fourth.setText("Add new item");
+
+ fourth.setCommand(new Command() {
+ public void menuSelected(MenuItem selected) {
+ menuBar.addItem("Newborn", null, null);
+ }
+ });
+
+ final MenuItem fifth = menuBar.getItems().get(4);
+ for (int i = 0; i < 5; i++) {
+ fifth.addItem("Another subitem " + i, null);
+ }
+
+ final MenuItem last = menuBar.getItems().get(menuBar.getSize() - 1);
+ last.setText("Remove me!");
+
+ // A command for removing the selected menuitem
+ Command removeCommand = new Command() {
+
+ public void menuSelected(MenuItem selected) {
+ MenuItem parent = selected.getParent();
+ if (parent != null) {
+ parent.removeChild(selected);
+ } else {
+ menuBar.removeItem(selected);
+ }
+ }
+ };
+
+ last.setCommand(removeCommand);
+
+ main.addComponent(menuBar);
+
+ }
+} \ No newline at end of file