diff options
Diffstat (limited to 'tests')
7 files changed, 916 insertions, 7 deletions
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java new file mode 100644 index 0000000000..86015a0109 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java @@ -0,0 +1,469 @@ +package com.vaadin.tests.components.orderedlayout; + +import java.util.ArrayList; +import java.util.Arrays; + +import com.vaadin.annotations.Theme; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.event.LayoutEvents.LayoutClickEvent; +import com.vaadin.event.LayoutEvents.LayoutClickListener; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.terminal.ThemeResource; +import com.vaadin.terminal.UserError; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.AbstractField; +import com.vaadin.ui.AbstractOrderedLayout; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.themes.Reindeer; + +@Theme("tests-components") +public class BoxLayoutTest extends AbstractTestRoot { + + protected AbstractOrderedLayout view; + + protected AbstractOrderedLayout l; + + protected AbstractComponent target; + + protected NativeSelect componentWidth; + protected NativeSelect componentHeight; + protected NativeSelect componentCaption; + protected NativeSelect componentIcon; + protected TextField componentDescription; + protected CheckBox componentError; + protected CheckBox componentRequired; + + protected NativeSelect align; + protected CheckBox expand; + + @Override + protected void setup(WrappedRequest request) { + + view = new VerticalLayout(); + // view.setSizeFull(); + view.setMargin(true); + view.setSpacing(true); + + // view.addComponent(createControls(false)); + // view.addComponent(createTestLayout(false)); + // view.setExpandRatio(view.getComponent(1), 1); + + for (int i = 0; i < 20; i++) { + view.addComponent(createHorizontalTest()); + } + + setContent(view); + getApplication().setRootPreserved(true); + } + + private Component createHorizontalTest() { + HorizontalLayout l = new HorizontalLayout(); + l.setWidth("100%"); + l.setSpacing(true); + + Label exp; + + // l.addComponent(new Embedded(null, new ThemeResource( + // "../runo/icons/32/document.png"))); + l.addComponent(exp = new Label( + "Mauris iaculis porttitor posuere. Praesent id metus massa, ut blandit odio. Proin quis tortor orci. Etiam at risus et justo dignissim congue. Donec.")); + // exp.setWidth("300px"); + l.addComponent(new Button("Edit")); + l.addComponent(new Button("Delete")); + l.setExpandRatio(exp, 1); + + for (int i = 0; i < l.getComponentCount(); i++) { + l.setComponentAlignment(l.getComponent(i), Alignment.MIDDLE_LEFT); + } + + return l; + } + + protected AbstractOrderedLayout createControls(boolean horizontal) { + VerticalLayout root = new VerticalLayout(); + root.setSpacing(true); + + // First row + HorizontalLayout header = new HorizontalLayout(); + header.setSpacing(true); + root.addComponent(header); + + Label title = new Label("BoxLayout Test"); + title.addStyleName(Reindeer.LABEL_H1); + header.addComponent(title); + + final CheckBox vertical = new CheckBox("Vertical", !horizontal); + vertical.setImmediate(true); + vertical.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + view.removeAllComponents(); + + view.addComponent(createControls(!vertical.getValue() + .booleanValue())); + view.addComponent(createTestLayout(!vertical.getValue() + .booleanValue())); + + view.setExpandRatio(view.getComponent(1), 1); + + } + }); + header.addComponent(vertical); + + Button addComponent = new Button("Add Component", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + GridLayout grid = new GridLayout(2, 2); + Button grow = new Button("Grow Me", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + if (event.getButton().getWidth() == -1) { + event.getButton().setHeight("50px"); + event.getButton().setWidth("200px"); + } else { + event.getButton() + .setSizeUndefined(); + } + } + }); + grid.addComponent(new Label("Grid cell 1")); + grid.addComponent(new Label("Grid cell 2")); + grid.addComponent(grow); + grid.addComponent(new Label("Grid cell 4")); + l.addComponent(grid); + // l.addComponent(new TextField("Some field")); + } + }); + header.addComponent(addComponent); + + Button removeComponent = new Button("Remove Component", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Component last = l.getComponent(l.getComponentCount() - 1); + l.removeComponent(last); + } + }); + header.addComponent(removeComponent); + + // Second row + HorizontalLayout controls = new HorizontalLayout(); + controls.setSpacing(true); + root.addComponent(controls); + + // Layout controls + HorizontalLayout layout = new HorizontalLayout(); + layout.addStyleName("fieldset"); + layout.setSpacing(true); + controls.addComponent(layout); + layout.addComponent(new Label("Layout")); + + ArrayList<String> sizes = new ArrayList<String>(); + sizes.addAll(Arrays.asList("100px", "30em", "100%")); + + final NativeSelect width = new NativeSelect(null, sizes); + width.setImmediate(true); + width.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (width.getValue() != null) { + l.setWidth(width.getValue().toString()); + } else { + l.setWidth(null); + } + } + }); + layout.addComponent(width); + layout.addComponent(new Label("×", ContentMode.XHTML)); + final NativeSelect height = new NativeSelect(null, sizes); + height.setImmediate(true); + height.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (height.getValue() != null) { + l.setHeight(height.getValue().toString()); + } else { + l.setHeight(null); + } + } + }); + layout.addComponent(height); + + final CheckBox margin = new CheckBox("Margin", false); + margin.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + l.setMargin(margin.getValue().booleanValue()); + } + }); + margin.setImmediate(true); + layout.addComponent(margin); + layout.addComponent(margin); + + final CheckBox spacing = new CheckBox("Spacing", false); + spacing.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + l.setSpacing(spacing.getValue().booleanValue()); + } + }); + spacing.setImmediate(true); + layout.addComponent(spacing); + + // Cell controls + HorizontalLayout cell = new HorizontalLayout(); + cell.addStyleName("fieldset"); + cell.setSpacing(true); + controls.addComponent(cell); + cell.addComponent(new Label("Cell")); + + ArrayList<Alignment> alignments = new ArrayList<Alignment>(); + alignments.addAll(Arrays.asList(Alignment.TOP_LEFT, + Alignment.MIDDLE_LEFT, Alignment.BOTTOM_LEFT, + Alignment.TOP_CENTER, Alignment.MIDDLE_CENTER, + Alignment.BOTTOM_CENTER, Alignment.TOP_RIGHT, + Alignment.MIDDLE_RIGHT, Alignment.BOTTOM_RIGHT)); + + align = new NativeSelect(null, alignments); + for (Alignment a : alignments) { + align.setItemCaption(a, + a.getVerticalAlignment() + "-" + a.getHorizontalAlignment()); + } + align.setImmediate(true); + align.setEnabled(false); + align.setNullSelectionAllowed(false); + align.select(Alignment.TOP_LEFT); + align.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (target == null) { + return; + } + l.setComponentAlignment(target, ((Alignment) align.getValue())); + } + }); + cell.addComponent(align); + + expand = new CheckBox("Expand"); + expand.setImmediate(true); + expand.setEnabled(false); + expand.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (target != null) { + l.setExpandRatio(target, expand.getValue() ? 1 : 0); + } + } + }); + cell.addComponent(expand); + + // Component controls + HorizontalLayout component = new HorizontalLayout(); + component.addStyleName("fieldset"); + component.setSpacing(true); + root.addComponent(component); + component.addComponent(new Label("Component")); + + sizes = new ArrayList<String>(); + sizes.addAll(Arrays.asList("50px", "200px", "10em", "50%", "100%")); + + componentWidth = new NativeSelect(null, sizes); + componentWidth.setImmediate(true); + componentWidth.setEnabled(false); + componentWidth.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (target == null) { + return; + } + if (componentWidth.getValue() != null) { + target.setWidth(componentWidth.getValue().toString()); + } else { + target.setWidth(null); + } + } + }); + component.addComponent(componentWidth); + component.addComponent(new Label("×", ContentMode.XHTML)); + + componentHeight = new NativeSelect(null, sizes); + componentHeight.setImmediate(true); + componentHeight.setEnabled(false); + componentHeight.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (componentHeight.getValue() != null) { + target.setHeight(componentHeight.getValue().toString()); + } else { + target.setHeight(null); + } + } + }); + component.addComponent(componentHeight); + + componentCaption = new NativeSelect("Caption", Arrays.asList("Short", + "Slightly Longer Caption")); + componentCaption.setImmediate(true); + componentCaption.setEnabled(false); + componentCaption.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (componentCaption.getValue() != null) { + target.setCaption(componentCaption.getValue().toString()); + } else { + target.setCaption(null); + } + } + }); + component.addComponent(componentCaption); + + componentIcon = new NativeSelect("Icon", Arrays.asList( + "../runo/icons/16/folder.png", "../runo/icons/32/document.png")); + componentIcon.setImmediate(true); + componentIcon.setEnabled(false); + componentIcon.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (componentIcon.getValue() != null) { + target.setIcon(new ThemeResource(componentIcon.getValue() + .toString())); + } else { + target.setIcon(null); + } + } + }); + component.addComponent(componentIcon); + + componentDescription = new TextField("Description"); + componentDescription.setImmediate(true); + componentDescription.setEnabled(false); + componentDescription.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + target.setDescription(componentDescription.getValue()); + } + }); + component.addComponent(componentDescription); + + componentError = new CheckBox("Error"); + componentError.setImmediate(true); + componentError.setEnabled(false); + componentError.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (target != null) { + target.setComponentError(componentError.getValue() ? new UserError( + "Error message") : null); + } + } + }); + component.addComponent(componentError); + + componentRequired = new CheckBox("Required"); + componentRequired.setImmediate(true); + componentRequired.setEnabled(false); + componentRequired.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + if (target != null && target instanceof AbstractField) { + ((AbstractField<?>) target).setRequired(componentRequired + .getValue()); + } + } + }); + component.addComponent(componentRequired); + + for (int i = 0; i < component.getComponentCount(); i++) { + component.setComponentAlignment(component.getComponent(i), + Alignment.MIDDLE_LEFT); + } + + return root; + } + + protected AbstractOrderedLayout createTestLayout(boolean horizontal) { + l = horizontal ? new HorizontalLayout() : new VerticalLayout(); + l.setSizeUndefined(); + l.addStyleName("test"); + + Label label = new Label("Component 1"); + l.addComponent(label); + l.addComponent(new Button("Component 2")); + + l.addListener(new LayoutClickListener() { + public void layoutClick(LayoutClickEvent event) { + if (event.getChildComponent() == null + || target == event.getChildComponent()) { + if (target != null) { + target.removeStyleName("target"); + } + target = null; + } else if (target != event.getChildComponent()) { + if (target != null) { + target.removeStyleName("target"); + } + target = (AbstractComponent) event.getChildComponent(); + target.addStyleName("target"); + } + componentWidth.setEnabled(target != null); + componentHeight.setEnabled(target != null); + componentCaption.setEnabled(target != null); + componentIcon.setEnabled(target != null); + componentDescription.setEnabled(target != null); + componentError.setEnabled(target != null); + componentRequired.setEnabled(target != null + && target instanceof AbstractField); + align.setEnabled(target != null); + expand.setEnabled(target != null); + if (target != null) { + if (target.getWidth() > -1) { + componentWidth.select(new Float(target.getWidth()) + .intValue() + + target.getWidthUnits().getSymbol()); + } else { + componentWidth.select(null); + } + if (target.getHeight() > -1) { + componentHeight.select(new Float(target.getHeight()) + .intValue() + + target.getHeightUnits().getSymbol()); + } else { + componentHeight.select(null); + } + + align.select(l.getComponentAlignment(target)); + expand.setValue(new Boolean(l.getExpandRatio(target) > 0)); + + componentCaption.select(target.getCaption()); + if (target.getIcon() != null) { + componentIcon.select(((ThemeResource) target.getIcon()) + .getResourceId()); + } else { + componentIcon.select(null); + } + componentDescription.setValue(target.getDescription()); + componentError.setValue(target.getComponentError() != null); + if (target instanceof AbstractField) { + componentRequired.setValue(((AbstractField<?>) target) + .isRequired()); + } + } + } + }); + + target = null; + + return l; + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +}
\ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutRenderTimeTest.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutRenderTimeTest.java new file mode 100644 index 0000000000..871a467877 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutRenderTimeTest.java @@ -0,0 +1,58 @@ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.Application.LegacyApplication; +import com.vaadin.terminal.ThemeResource; +import com.vaadin.ui.Button; +import com.vaadin.ui.Embedded; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Root; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.themes.Reindeer; + +public class LayoutRenderTimeTest extends LegacyApplication { + + @Override + public void init() { + Root.LegacyWindow main = new Root.LegacyWindow(); + setMainWindow(main); + + VerticalLayout root = new VerticalLayout(); + root.setWidth("100%"); + main.setContent(root); + + for (int i = 1; i <= 100; i++) { + root.addComponent(getRow(i)); + } + } + + private HorizontalLayout getRow(int i) { + HorizontalLayout row = new HorizontalLayout(); + // row.setWidth("100%"); + // row.setSpacing(true); + + Embedded icon = new Embedded(null, new ThemeResource( + "../runo/icons/32/document.png")); + // row.addComponent(icon); + // row.setComponentAlignment(icon, Alignment.MIDDLE_LEFT); + + Label text = new Label( + "Row content #" + + i + + ". In pellentesque faucibus vestibulum. Nulla at nulla justo, eget luctus tortor. Nulla facilisi. Duis aliquet."); + // row.addComponent(text); + // row.setExpandRatio(text, 1); + + Button button = new Button("Edit"); + button.addStyleName(Reindeer.BUTTON_SMALL); + row.addComponent(button); + // row.setComponentAlignment(button, Alignment.MIDDLE_LEFT); + + button = new Button("Delete"); + button.addStyleName(Reindeer.BUTTON_SMALL); + row.addComponent(button); + // row.setComponentAlignment(button, Alignment.MIDDLE_LEFT); + + return row; + } +} diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java index 07562b7cfe..62c552ee75 100644 --- a/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/LayoutResizeTest.java @@ -9,7 +9,6 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalSplitPanel; -import com.vaadin.ui.JavaScript; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; @@ -40,8 +39,10 @@ public class LayoutResizeTest extends TestBase { new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { - JavaScript - .getCurrent() + event.getButton() + .getRoot() + .getPage() + .getJavaScript() .execute( "setTimeout(function() {window.resizeTo(700,400)}, 500)"); } @@ -51,8 +52,10 @@ public class LayoutResizeTest extends TestBase { resize = new Button("Resize to 900x600", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { - JavaScript - .getCurrent() + event.getButton() + .getRoot() + .getPage() + .getJavaScript() .execute( "setTimeout(function() {window.resizeTo(900,600)}, 500)"); } diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java index 46fd6ee852..aeae09e7b9 100644 --- a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import com.vaadin.annotations.Theme; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.terminal.WrappedRequest; @@ -20,6 +21,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.NativeSelect; import com.vaadin.ui.VerticalLayout; +@Theme("tests-components") public class OrderedLayoutCases extends AbstractTestRoot { private static final String[] dimensionValues = { "-1px", "5px", "350px", "800px", "100%", "50%" }; diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/VaadinTunesLayout.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/VaadinTunesLayout.java new file mode 100644 index 0000000000..973bd63d76 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/VaadinTunesLayout.java @@ -0,0 +1,341 @@ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.terminal.Sizeable; +import com.vaadin.terminal.ThemeResource; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Embedded; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.HorizontalSplitPanel; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.Slider; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +@Theme("tests-components") +public class VaadinTunesLayout extends AbstractTestRoot { + + @Override + public void setup(WrappedRequest request) { + + /* + * We'll build the whole UI here, since the application will not contain + * any logic. Otherwise it would be more practical to separate parts of + * the UI into different classes and methods. + */ + + // Main (browser) window, needed in all Vaadin applications + VerticalLayout rootLayout = new VerticalLayout(); + // final Window root = new Window("VaadinTunes", rootLayout); + + /* + * We'll attach the window to the browser view already here, so we won't + * forget it later. + */ + setContent(rootLayout); + + // root.showNotification( + // "This is an example of how you can do layouts in Vaadin.<br/>It is not a working sound player.", + // Notification.TYPE_HUMANIZED_MESSAGE); + + // Our root window contains one VerticalLayout, let's make + // sure it's 100% sized, and remove unwanted margins + rootLayout.setSizeFull(); + rootLayout.setMargin(false); + + // Top area, containing playback and volume controls, play status, view + // modes and search + HorizontalLayout top = new HorizontalLayout(); + top.setWidth("100%"); + top.setMargin(false, true, false, true); // Enable horizontal margins + top.setSpacing(true); + + // Let's attach that one straight away too + rootLayout.addComponent(top); + + // Create the placeholders for all the components in the top area + HorizontalLayout playback = new HorizontalLayout(); + HorizontalLayout volume = new HorizontalLayout(); + HorizontalLayout status = new HorizontalLayout(); + HorizontalLayout viewmodes = new HorizontalLayout(); + ComboBox search = new ComboBox(); + + // Add the components and align them properly + top.addComponent(playback); + top.addComponent(volume); + top.addComponent(status); + top.addComponent(viewmodes); + top.addComponent(search); + top.setComponentAlignment(playback, Alignment.MIDDLE_LEFT); + top.setComponentAlignment(volume, Alignment.MIDDLE_LEFT); + top.setComponentAlignment(status, Alignment.MIDDLE_CENTER); + top.setComponentAlignment(viewmodes, Alignment.MIDDLE_LEFT); + top.setComponentAlignment(search, Alignment.MIDDLE_LEFT); + + /* + * We want our status area to expand if the user resizes the root + * window, and we want it to accommodate as much space as there is + * available. All other components in the top layout should stay fixed + * sized, so we don't need to specify any expand ratios for them (they + * will automatically revert to zero after the following line). + */ + top.setExpandRatio(status, 1.0F); + + // Playback controls + Button prev = new NativeButton("Previous"); + Button play = new NativeButton("Play/pause"); + Button next = new NativeButton("Next"); + playback.addComponent(prev); + playback.addComponent(play); + playback.addComponent(next); + // Set spacing between the buttons + playback.setSpacing(true); + + // Volume controls + Button mute = new NativeButton("mute"); + Slider vol = new Slider(); + vol.setOrientation(Slider.ORIENTATION_HORIZONTAL); + vol.setWidth("100px"); + Button max = new NativeButton("max"); + volume.addComponent(mute); + volume.addComponent(vol); + volume.addComponent(max); + + // Status area + status.setWidth("80%"); + status.setSpacing(true); + + Button toggleVisualization = new NativeButton("Mode"); + Label timeFromStart = new Label("0:00"); + + // We'll need another layout to show currently playing track and + // progress + VerticalLayout trackDetails = new VerticalLayout(); + trackDetails.setWidth("100%"); + Label track = new Label("Track Name"); + Label album = new Label("Album Name - Artist"); + track.setWidth(null); + album.setWidth(null); + Slider progress = new Slider(); + progress.setOrientation(Slider.ORIENTATION_HORIZONTAL); + progress.setWidth("100%"); + trackDetails.addComponent(track); + trackDetails.addComponent(album); + trackDetails.addComponent(progress); + trackDetails.setComponentAlignment(track, Alignment.TOP_CENTER); + trackDetails.setComponentAlignment(album, Alignment.TOP_CENTER); + + Label timeToEnd = new Label("-4:46"); + Button jumpToTrack = new NativeButton("Show"); + + // Place all components to the status layout and align them properly + status.addComponent(toggleVisualization); + status.setComponentAlignment(toggleVisualization, Alignment.MIDDLE_LEFT); + status.addComponent(timeFromStart); + status.setComponentAlignment(timeFromStart, Alignment.BOTTOM_LEFT); + status.addComponent(trackDetails); + status.addComponent(timeToEnd); + status.setComponentAlignment(timeToEnd, Alignment.BOTTOM_LEFT); + status.addComponent(jumpToTrack); + status.setComponentAlignment(jumpToTrack, Alignment.MIDDLE_LEFT); + + // Then remember to specify the expand ratio + status.setExpandRatio(trackDetails, 1.0F); + + // View mode buttons + Button viewAsTable = new NativeButton("Table"); + Button viewAsGrid = new NativeButton("Grid"); + Button coverflow = new NativeButton("Coverflow"); + viewmodes.addComponent(viewAsTable); + viewmodes.addComponent(viewAsGrid); + viewmodes.addComponent(coverflow); + + /* + * That covers the top bar. Now let's move on to the sidebar and track + * listing + */ + + // We'll need one splitpanel to separate the sidebar and track listing + HorizontalSplitPanel bottom = new HorizontalSplitPanel(); + rootLayout.addComponent(bottom); + + // The splitpanel is by default 100% x 100%, but we'll need to adjust + // our main window layout to accomodate the height + rootLayout.setExpandRatio(bottom, 1.0F); + + // Give the sidebar less space than the listing + bottom.setSplitPosition(200, Sizeable.UNITS_PIXELS); + + // Let's add some content to the sidebar + // First, we need a layout to but all components in + VerticalLayout sidebar = new VerticalLayout(); + sidebar.setSizeFull(); + bottom.setFirstComponent(sidebar); + + /* + * Then we need some labels and buttons, and an album cover image The + * labels and buttons go into their own vertical layout, since we want + * the 'sidebar' layout to be expanding (cover image in the bottom). + * VerticalLayout is by default 100% wide. + */ + VerticalLayout selections = new VerticalLayout(); + Label library = new Label("Library"); + Button music = new NativeButton("Music"); + music.setWidth("100%"); + + Label store = new Label("Store"); + Button vaadinTunesStore = new NativeButton("VaadinTunes Store"); + vaadinTunesStore.setWidth("100%"); + Button purchased = new NativeButton("Purchased"); + purchased.setWidth("100%"); + + Label playlists = new Label("Playlists"); + Button genius = new NativeButton("Geniues"); + genius.setWidth("100%"); + Button recent = new NativeButton("Recently Added"); + recent.setWidth("100%"); + + // Lets add them to the 'selections' layout + selections.addComponent(library); + selections.addComponent(music); + selections.addComponent(store); + selections.addComponent(vaadinTunesStore); + selections.addComponent(purchased); + selections.addComponent(playlists); + selections.addComponent(genius); + selections.addComponent(recent); + + // Then add the selections to the sidebar, and set it expanding + sidebar.addComponent(selections); + sidebar.setExpandRatio(selections, 1.0F); + + // Then comes the cover artwork (we'll add the actual image in the + // themeing section) + Embedded cover = new Embedded("Currently Playing"); + sidebar.addComponent(cover); + + /* + * And lastly, we need the track listing table It should fill the whole + * left side of our bottom layout + */ + Table listing = new Table(); + listing.setSizeFull(); + listing.setSelectable(true); + bottom.setSecondComponent(listing); + + // Add the table headers + listing.addContainerProperty("Name", String.class, ""); + listing.addContainerProperty("Time", String.class, "0:00"); + listing.addContainerProperty("Artist", String.class, ""); + listing.addContainerProperty("Album", String.class, ""); + listing.addContainerProperty("Genre", String.class, ""); + listing.addContainerProperty("Rating", NativeSelect.class, + new NativeSelect()); + + // Lets populate the table with random data + String[] tracks = new String[] { "Red Flag", "Millstone", + "Not The Sun", "Breath", "Here We Are", "Deep Heaven", + "Her Voice Resides", "Natural Tan", "End It All", "Kings", + "Daylight Slaving", "Mad Man", "Resolve", "Teargas", + "African Air", "Passing Bird" }; + String[] times = new String[] { "4:12", "6:03", "5:43", "4:32", "3:42", + "4:45", "2:56", "9:34", "2:10", "3:44", "5:49", "6:30", "5:18", + "7:42", "3:13", "2:52" }; + String[] artists = new String[] { "Billy Talent", "Brand New", + "Breaking Benjamin", "Becoming The Archetype", + "Bullet For My Valentine", "Chasing Victory", "Chimaira", + "Danko Jones", "Deadlock", "Deftones", "From Autumn To Ashes", + "Haste The Day", "Four Year Strong", "In Flames", "Kemopetrol", + "John Legend" }; + String[] albums = new String[] { "Once Again", "The Caitiff Choir", + "The Devil And God", "Light Grenades", "Dicthonomy", + "Back In Black", "Dreamer", "Come Clarity", "Year Zero", + "Frames", "Fortress", "Phobia", "The Poison", "Manifesto", + "White Pony", "The Big Dirty" }; + String[] genres = new String[] { "Rock", "Metal", "Hardcore", "Indie", + "Pop", "Alternative", "Blues", "Jazz", "Hip Hop", + "Electronica", "Punk", "Hard Rock", "Dance", "R'n'B", "Gospel", + "Country" }; + for (int i = 0; i < 1000; i++) { + NativeSelect s = new NativeSelect(); + s.addItem("1 star"); + s.addItem("2 stars"); + s.addItem("3 stars"); + s.addItem("4 stars"); + s.addItem("5 stars"); + s.select(i % 5 + " stars"); + final int index = i % 16; + listing.addItem(new Object[] { tracks[index], times[index], + artists[index], albums[index], genres[index], s }, i); + } + + // We'll align the track time column to right as well + listing.setColumnAlignment("Time", Table.ALIGN_RIGHT); + + // TODO the footer + + // Now what's left to do? Themeing of course. + // setTheme("vaadintunes"); + + /* + * Let's give a namespace to our application window. This way, if + * someone uses the same theme for different applications, we don't get + * unwanted style conflicts. + */ + // root.setStyleName("tTunes"); + + top.setStyleName("top"); + top.setHeight("75px"); // Same as the background image height + + playback.setStyleName("playback"); + playback.setMargin(false, true, false, false); // Add right-side margin + play.setStyleName("play"); + next.setStyleName("next"); + prev.setStyleName("prev"); + playback.setComponentAlignment(prev, Alignment.MIDDLE_LEFT); + playback.setComponentAlignment(next, Alignment.MIDDLE_LEFT); + + volume.setStyleName("volume"); + mute.setStyleName("mute"); + max.setStyleName("max"); + vol.setWidth("78px"); + + status.setStyleName("status"); + status.setMargin(true); + status.setHeight("46px"); // Height of the background image + + toggleVisualization.setStyleName("toggle-vis"); + jumpToTrack.setStyleName("jump"); + + viewAsTable.setStyleName("viewmode-table"); + viewAsGrid.setStyleName("viewmode-grid"); + coverflow.setStyleName("viewmode-coverflow"); + + sidebar.setStyleName("sidebar"); + + music.setStyleName("selected"); + + cover.setSource(new ThemeResource("images/album-cover.jpg")); + // Because this is an image, it will retain it's aspect ratio + cover.setWidth("100%"); + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +}
\ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/components/table/TextFieldRelativeWidth.java b/tests/testbench/com/vaadin/tests/components/table/TextFieldRelativeWidth.java index ae3f4c42a4..5c7479d060 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TextFieldRelativeWidth.java +++ b/tests/testbench/com/vaadin/tests/components/table/TextFieldRelativeWidth.java @@ -27,8 +27,7 @@ public class TextFieldRelativeWidth extends TestBase { public class EditTable extends Table implements Button.ClickListener { - private Button addButton = new Button("Add new row", - (Button.ClickListener) this); + private Button addButton = new Button("Add new row", this); private String inputPrompt; diff --git a/tests/testbench/com/vaadin/tests/themes/LiferayThemeTest.java b/tests/testbench/com/vaadin/tests/themes/LiferayThemeTest.java new file mode 100644 index 0000000000..fa15d88799 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/themes/LiferayThemeTest.java @@ -0,0 +1,37 @@ +package com.vaadin.tests.themes; + +import com.vaadin.annotations.Theme; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.ui.Label; +import com.vaadin.ui.Panel; +import com.vaadin.ui.themes.LiferayTheme; + +@Theme("liferay") +public class LiferayThemeTest extends AbstractTestRoot { + + @Override + protected void setup(WrappedRequest request) { + Panel p = new Panel("Panel"); + addComponent(p); + p.addComponent(new Label("Panel content")); + + p = new Panel("Light Panel"); + p.addStyleName(LiferayTheme.PANEL_LIGHT); + addComponent(p); + p.addComponent(new Label("Panel content")); + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} |