| 1 | package test; |
|---|
| 2 | |
|---|
| 3 | import com.itmill.toolkit.Application; |
|---|
| 4 | import com.itmill.toolkit.data.util.IndexedContainer; |
|---|
| 5 | import com.itmill.toolkit.terminal.Sizeable; |
|---|
| 6 | import com.itmill.toolkit.ui.*; |
|---|
| 7 | |
|---|
| 8 | /** |
|---|
| 9 | * Test class for ticket 1983 |
|---|
| 10 | */ |
|---|
| 11 | public class Ticket1983 extends Application { |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | public void init() { |
|---|
| 15 | Window main = new Window("Test for ticket 1983"); |
|---|
| 16 | main.setLayout(new TestLayout()); |
|---|
| 17 | setMainWindow(main); |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | private static class TestLayout extends SplitPanel { |
|---|
| 21 | public TestLayout() { |
|---|
| 22 | super(ORIENTATION_HORIZONTAL); |
|---|
| 23 | |
|---|
| 24 | setSplitPosition(200, Sizeable.UNITS_PIXELS); |
|---|
| 25 | setMargin(false); |
|---|
| 26 | setLocked(true); |
|---|
| 27 | |
|---|
| 28 | final SplitPanel leftSide = initLeftSide(); |
|---|
| 29 | setFirstComponent(leftSide); |
|---|
| 30 | |
|---|
| 31 | final Layout rightSide = new OrderedLayout(); |
|---|
| 32 | rightSide.setHeight("100%"); |
|---|
| 33 | setSecondComponent(rightSide); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | private SplitPanel initLeftSide() { |
|---|
| 37 | final SplitPanel leftSide = new SplitPanel(ORIENTATION_VERTICAL); |
|---|
| 38 | leftSide.setHeight("100%"); |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | final IndexedContainer dataSource = new IndexedContainer(); |
|---|
| 42 | final String propId = "col"; |
|---|
| 43 | dataSource.addContainerProperty(propId, String.class, null); |
|---|
| 44 | final Object itemId = dataSource.addItem(); |
|---|
| 45 | dataSource.getItem(itemId).getItemProperty(propId).setValue("Very long value that makes a scrollbar appear for sure"); |
|---|
| 46 | |
|---|
| 47 | final Table table = new Table(); |
|---|
| 48 | table.setContainerDataSource(dataSource); |
|---|
| 49 | table.setVisibleColumns(new Object[]{propId}); |
|---|
| 50 | |
|---|
| 51 | leftSide.setSecondComponent(table); |
|---|
| 52 | |
|---|
| 53 | Button button = new Button("Change col value to short"); |
|---|
| 54 | button.addListener(new Button.ClickListener() { |
|---|
| 55 | public void buttonClick(Button.ClickEvent event) { |
|---|
| 56 | // Change the column value to a short one --> Should remove the scrollbar |
|---|
| 57 | dataSource.getItem(itemId).getItemProperty(propId).setValue("Short value"); |
|---|
| 58 | // Works the same way with or without repaint request |
|---|
| 59 | table.requestRepaint(); |
|---|
| 60 | } |
|---|
| 61 | }); |
|---|
| 62 | leftSide.setFirstComponent(button); |
|---|
| 63 | |
|---|
| 64 | return leftSide; |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | } |
|---|