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.

TabSheetElementTabWithoutCaption.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.elements.tabsheet;
  17. import com.vaadin.server.ThemeResource;
  18. import com.vaadin.server.VaadinRequest;
  19. import com.vaadin.tests.components.AbstractTestUI;
  20. import com.vaadin.ui.Component;
  21. import com.vaadin.ui.Label;
  22. import com.vaadin.ui.TabSheet;
  23. import com.vaadin.ui.TabSheet.Tab;
  24. public class TabSheetElementTabWithoutCaption extends AbstractTestUI {
  25. @Override
  26. protected void setup(VaadinRequest request) {
  27. // Create a tab sheet with a tab having no caption
  28. TabSheet ts = new TabSheet();
  29. Tab newTab;
  30. for (int i = 1; i <= 5; i++) {
  31. Component c = createTabContent(i);
  32. if (i != 3) {
  33. newTab = ts.addTab(c, "Tab " + i);
  34. } else {
  35. newTab = ts.addTab(c);
  36. }
  37. newTab.setClosable(true);
  38. }
  39. addComponent(ts);
  40. // Create a tab sheet that has icons instead of text captions
  41. TabSheet ts2 = new TabSheet();
  42. newTab = ts2.addTab(createTabContent(10), null,
  43. new ThemeResource("favicon.ico"));
  44. newTab.setClosable(true);
  45. newTab = ts2.addTab(createTabContent(11), null,
  46. new ThemeResource("window/img/maximize.png"));
  47. newTab.setClosable(false);
  48. newTab = ts2.addTab(createTabContent(12));
  49. newTab.setClosable(false);
  50. newTab = ts2.addTab(createTabContent(12));
  51. newTab.setClosable(true);
  52. newTab = ts2.addTab(createTabContent(13), null,
  53. new ThemeResource("window/img/restore.png"));
  54. newTab.setClosable(true);
  55. addComponent(ts2);
  56. }
  57. @Override
  58. protected String getTestDescription() {
  59. return "The methods of TabSheetElement should not fail when there are tabs without a caption.";
  60. }
  61. @Override
  62. protected Integer getTicketNumber() {
  63. return 14434;
  64. }
  65. private Label createTabContent(int index) {
  66. return new Label("This is tab " + index);
  67. }
  68. }