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.

DragAndDropWrapperInPanel.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2012 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.components.draganddropwrapper;
  17. import com.vaadin.tests.components.TestBase;
  18. import com.vaadin.ui.Button;
  19. import com.vaadin.ui.Button.ClickEvent;
  20. import com.vaadin.ui.Component;
  21. import com.vaadin.ui.DragAndDropWrapper;
  22. import com.vaadin.ui.Label;
  23. import com.vaadin.ui.Panel;
  24. import com.vaadin.ui.TextArea;
  25. public class DragAndDropWrapperInPanel extends TestBase {
  26. @Override
  27. protected void setup() {
  28. addComponent(new Button("Click to resize", new Button.ClickListener() {
  29. public void buttonClick(ClickEvent event) {
  30. for (int i = 1; i < getLayout().getComponentCount(); ++i) {
  31. Component c = getLayout().getComponent(i);
  32. c.setWidth("400px");
  33. c.setHeight("200px");
  34. }
  35. }
  36. }));
  37. Component content;
  38. content = new Button("Undefined-sized Button");
  39. content.setSizeUndefined();
  40. addDnDPanel(content);
  41. content = new Label("Full-sized Label");
  42. content.setSizeFull();
  43. addDnDPanel(content);
  44. content = new TextArea(null, "200x100px TextArea");
  45. content.setWidth("200px");
  46. content.setHeight("100px");
  47. addDnDPanel(content);
  48. }
  49. @Override
  50. protected String getDescription() {
  51. return "A full-sized DragAndDropWrapper causes scrollbars inside Panel";
  52. }
  53. @Override
  54. protected Integer getTicketNumber() {
  55. return 6880;
  56. }
  57. private void addDnDPanel(Component content) {
  58. Panel panel = new Panel();
  59. panel.setSizeUndefined();
  60. panel.setWidth("300px");
  61. panel.setHeight("150px");
  62. DragAndDropWrapper dndWrapper = new DragAndDropWrapper(content);
  63. dndWrapper.setSizeFull();
  64. panel.setContent(dndWrapper);
  65. addComponent(panel);
  66. }
  67. }