You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TabSheetIndexOperations.java 2.6KB

пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package com.vaadin.tests.components.tabsheet;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.ui.Button;
  4. import com.vaadin.ui.Button.ClickEvent;
  5. import com.vaadin.ui.Label;
  6. import com.vaadin.ui.TabSheet;
  7. import com.vaadin.ui.TabSheet.Tab;
  8. public class TabSheetIndexOperations extends TestBase {
  9. private int tabCounter = 1;
  10. @Override
  11. protected void setup() {
  12. final TabSheet tabs = new TabSheet();
  13. // Add some tabs
  14. tabs.addTab(new Label("Content 1"), "Tab 1", null);
  15. tabs.addTab(new Label("Content 2"), "Tab 2", null);
  16. tabs.addTab(new Label("Content 3"), "Tab 3", null);
  17. addComponent(tabs);
  18. Button addTab = new Button("Add tab at index 2",
  19. new Button.ClickListener() {
  20. @Override
  21. public void buttonClick(ClickEvent event) {
  22. tabs.addTab(new Label("Content " + tabCounter),
  23. "Added Tab " + tabCounter, null, 2);
  24. tabCounter++;
  25. }
  26. });
  27. addComponent(addTab);
  28. Button setCaption = new Button("Invert tab caption at index 2",
  29. new Button.ClickListener() {
  30. @Override
  31. public void buttonClick(ClickEvent event) {
  32. Tab tab = tabs.getTab(2);
  33. tab.setCaption(new StringBuffer(tab.getCaption())
  34. .reverse().toString());
  35. }
  36. });
  37. addComponent(setCaption);
  38. Button move = new Button("Move selected tab to index 2",
  39. new Button.ClickListener() {
  40. @Override
  41. public void buttonClick(ClickEvent event) {
  42. tabs.setTabPosition(tabs.getTab(tabs.getSelectedTab()),
  43. 2);
  44. }
  45. });
  46. addComponent(move);
  47. Button getIndex = new Button("Get selected tab index",
  48. new Button.ClickListener() {
  49. @Override
  50. public void buttonClick(ClickEvent event) {
  51. getMainWindow().showNotification(
  52. "Index: " + tabs.getTabPosition(
  53. tabs.getTab(tabs.getSelectedTab())));
  54. }
  55. });
  56. addComponent(getIndex);
  57. }
  58. @Override
  59. protected String getDescription() {
  60. return "You can use indexes to add and reorder the TabSheet";
  61. }
  62. @Override
  63. protected Integer getTicketNumber() {
  64. return 6188;
  65. }
  66. }