From 4c58616542827ccfbe7bfeb473ba472183acb97b Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Tue, 10 Jun 2014 22:38:11 +0300 Subject: [PATCH] Update Valo theme test application - Add DragAndDropWrapper examples - Improve Window example with toolbar support Change-Id: I1d6dc7d5e7449bd479f3510d9cbf1fda3cccddd6 --- .../vaadin/tests/themes/valo/CommonParts.java | 287 ++++++++++++------ .../vaadin/tests/themes/valo/Dragging.java | 273 +++++++++++++++++ .../vaadin/tests/themes/valo/MenuBars.java | 105 +++++-- .../vaadin/tests/themes/valo/RandomTests.java | 83 +++++ .../com/vaadin/tests/themes/valo/Tables.java | 8 +- .../vaadin/tests/themes/valo/Tabsheets.java | 4 +- .../tests/themes/valo/ValoThemeTest.java | 18 ++ 7 files changed, 659 insertions(+), 119 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/themes/valo/Dragging.java create mode 100644 uitest/src/com/vaadin/tests/themes/valo/RandomTests.java diff --git a/uitest/src/com/vaadin/tests/themes/valo/CommonParts.java b/uitest/src/com/vaadin/tests/themes/valo/CommonParts.java index 59b712d8b2..902ad82508 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/CommonParts.java +++ b/uitest/src/com/vaadin/tests/themes/valo/CommonParts.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 Vaadin Ltd. + * Copyright 2000-2014 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -26,9 +26,11 @@ import com.vaadin.server.Page; import com.vaadin.server.UserError; import com.vaadin.shared.Position; import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.GridLayout; @@ -39,6 +41,7 @@ import com.vaadin.ui.MenuBar.Command; import com.vaadin.ui.MenuBar.MenuItem; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; +import com.vaadin.ui.TabSheet; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; @@ -61,8 +64,8 @@ public class CommonParts extends VerticalLayout implements View { row.addComponent(loadingIndicators()); row.addComponent(notifications(), 1, 0, 1, 2); - row.addComponent(tooltips()); row.addComponent(windows()); + row.addComponent(tooltips()); } @@ -189,8 +192,9 @@ public class CommonParts extends VerticalLayout implements View { notification.setStyleName(styleString.trim()); } else { typeString = selectedItem.getText().toLowerCase(); - notification.setStyleName(typeString + " " - + styleString.trim()); + notification + .setStyleName((typeString + " " + styleString + .trim()).trim()); } for (MenuItem item : type.getItems()) { item.setChecked(false); @@ -221,10 +225,11 @@ public class CommonParts extends VerticalLayout implements View { } } if (styleString.trim().length() > 0) { - notification.setStyleName(typeString + " " - + styleString.trim()); + notification + .setStyleName((typeString + " " + styleString + .trim()).trim()); } else if (typeString.length() > 0) { - notification.setStyleName(typeString); + notification.setStyleName(typeString.trim()); } else { notification.setStyleName(null); } @@ -235,6 +240,7 @@ public class CommonParts extends VerticalLayout implements View { style.addItem("Success", styleCommand).setCheckable(true); style.addItem("Failure", styleCommand).setCheckable(true); style.addItem("Bar", styleCommand).setCheckable(true); + style.addItem("Small", styleCommand).setCheckable(true); style.addItem("Closable", styleCommand).setCheckable(true); addComponent(style); style.addStyleName("small"); @@ -435,51 +441,198 @@ public class CommonParts extends VerticalLayout implements View { Panel windows() { Panel p = new Panel("Dialogs"); VerticalLayout content = new VerticalLayout() { - final Window win = new Window(); - MenuBar footer = new MenuBar(); + final Window win = new Window("Window Caption"); String prevHeight = "300px"; + boolean footerVisible = true; + boolean autoHeight = false; + boolean tabsVisible = false; + boolean toolbarVisible = false; + boolean footerToolbar = false; + boolean toolbarLayout = false; + String toolbarStyle = null; + + VerticalLayout windowContent() { + VerticalLayout root = new VerticalLayout(); + + if (toolbarVisible) { + MenuBar menuBar = MenuBars.getToolBar(); + menuBar.setSizeUndefined(); + menuBar.setStyleName(toolbarStyle); + Component toolbar = menuBar; + if (toolbarLayout) { + menuBar.setWidth(null); + HorizontalLayout toolbarLayout = new HorizontalLayout(); + toolbarLayout.setWidth("100%"); + toolbarLayout.setSpacing(true); + Label label = new Label("Tools"); + label.setSizeUndefined(); + toolbarLayout.addComponents(label, menuBar); + toolbarLayout.setExpandRatio(menuBar, 1); + toolbarLayout.setComponentAlignment(menuBar, + Alignment.TOP_RIGHT); + toolbar = toolbarLayout; + } + toolbar.addStyleName("v-window-top-toolbar"); + root.addComponent(toolbar); + } + + Component content = null; + + if (tabsVisible) { + TabSheet tabs = new TabSheet(); + tabs.setSizeFull(); + VerticalLayout l = new VerticalLayout(); + l.addComponent(new Label( + "

Subtitle

Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.

Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.

", + ContentMode.HTML)); + l.setMargin(true); + tabs.addTab(l, "Selected"); + tabs.addTab(new Label(" ", ContentMode.HTML), + "Another"); + tabs.addTab(new Label(" ", ContentMode.HTML), + "One more"); + tabs.addStyleName("padded-tabbar"); + content = tabs; + } else if (!autoHeight) { + Panel p = new Panel(); + p.setSizeFull(); + p.addStyleName("borderless"); + if (!toolbarVisible || !toolbarLayout) { + p.addStyleName("scroll-divider"); + } + VerticalLayout l = new VerticalLayout(); + l.addComponent(new Label( + "

Subtitle

Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.

Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.

", + ContentMode.HTML)); + l.setMargin(true); + p.setContent(l); + content = p; + } else { + content = new Label( + "

Subtitle

Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.

Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.

", + ContentMode.HTML); + root.setMargin(true); + } + + root.addComponent(content); + + if (footerVisible) { + HorizontalLayout footer = new HorizontalLayout(); + footer.setWidth("100%"); + footer.setSpacing(true); + footer.addStyleName("v-window-bottom-toolbar"); + + Label footerText = new Label("Footer text"); + footerText.setSizeUndefined(); + + Button ok = new Button("OK"); + ok.addStyleName("primary"); + + Button cancel = new Button("Cancel"); + + footer.addComponents(footerText, ok, cancel); + footer.setExpandRatio(footerText, 1); + + if (footerToolbar) { + MenuBar menuBar = MenuBars.getToolBar(); + menuBar.setStyleName(toolbarStyle); + menuBar.setWidth(null); + footer.removeAllComponents(); + footer.addComponent(menuBar); + } + + root.addComponent(footer); + } + + if (!autoHeight) { + root.setSizeFull(); + root.setExpandRatio(content, 1); + } + + return root; + } + { setSpacing(true); setMargin(true); - win.setWidth("320px"); + win.setWidth("380px"); win.setHeight(prevHeight); win.setClosable(false); win.setResizable(false); - win.setContent(windowContents(true)); + win.setContent(windowContent()); win.setCloseShortcut(KeyCode.ESCAPE, null); - Command footerCommand = new Command() { + Command optionsCommand = new Command() { @Override public void menuSelected(MenuItem selectedItem) { - if (selectedItem.getText().equals("Fixed")) { - win.setContent(windowContents(true)); - win.setHeight(prevHeight); - } else { - win.setContent(windowContents(false)); - prevHeight = win.getHeight() - + win.getHeightUnits().toString(); - win.setHeight(null); + if (selectedItem.getText().equals("Footer")) { + footerVisible = selectedItem.isChecked(); } - for (MenuItem item : footer.getItems()) { - item.setChecked(false); + if (selectedItem.getText().equals("Auto Height")) { + autoHeight = selectedItem.isChecked(); + if (!autoHeight) { + win.setHeight(prevHeight); + } else { + prevHeight = win.getHeight() + + win.getHeightUnits().toString(); + win.setHeight(null); + } } - selectedItem.setChecked(true); + if (selectedItem.getText().equals("Tabs")) { + tabsVisible = selectedItem.isChecked(); + } + + if (selectedItem.getText().equals("Top Toolbar")) { + toolbarVisible = selectedItem.isChecked(); + } + + if (selectedItem.getText().equals("Footer Toolbar")) { + footerToolbar = selectedItem.isChecked(); + } + + if (selectedItem.getText().equals("Top Toolbar layout")) { + toolbarLayout = selectedItem.isChecked(); + } + + if (selectedItem.getText() + .equals("Borderless Toolbars")) { + toolbarStyle = selectedItem.isChecked() ? "borderless" + : null; + } + + win.setContent(windowContent()); } }; - footer.setCaption("Footer type"); - MenuItem fixed = footer.addItem("Fixed", footerCommand); - fixed.setCheckable(true); - fixed.setChecked(true); - footer.addItem("Scroll", footerCommand).setCheckable(true); - footer.addStyleName("small"); - addComponent(footer); + MenuBar options = new MenuBar(); + options.setCaption("Content"); + options.addItem("Auto Height", optionsCommand).setCheckable( + true); + options.addItem("Tabs", optionsCommand).setCheckable(true); + MenuItem option = options.addItem("Footer", optionsCommand); + option.setCheckable(true); + option.setChecked(true); + options.addStyleName("small"); + addComponent(options); + + options = new MenuBar(); + options.setCaption("Toolbars"); + options.addItem("Footer Toolbar", optionsCommand).setCheckable( + true); + options.addItem("Top Toolbar", optionsCommand).setCheckable( + true); + options.addItem("Top Toolbar layout", optionsCommand) + .setCheckable(true); + options.addItem("Borderless Toolbars", optionsCommand) + .setCheckable(true); + options.addStyleName("small"); + addComponent(options); - Command optionsCommand = new Command() { + Command optionsCommand2 = new Command() { @Override public void menuSelected(MenuItem selectedItem) { if (selectedItem.getText().equals("Caption")) { - win.setCaption(selectedItem.isChecked() ? "Window caption" + win.setCaption(selectedItem.isChecked() ? "Window Caption" : null); } else if (selectedItem.getText().equals("Closable")) { win.setClosable(selectedItem.isChecked()); @@ -491,12 +644,15 @@ public class CommonParts extends VerticalLayout implements View { } }; - MenuBar options = new MenuBar(); + options = new MenuBar(); options.setCaption("Options"); - options.addItem("Caption", optionsCommand).setCheckable(true); - options.addItem("Closable", optionsCommand).setCheckable(true); - options.addItem("Resizable", optionsCommand).setCheckable(true); - options.addItem("Modal", optionsCommand).setCheckable(true); + MenuItem caption = options.addItem("Caption", optionsCommand2); + caption.setCheckable(true); + caption.setChecked(true); + options.addItem("Closable", optionsCommand2).setCheckable(true); + options.addItem("Resizable", optionsCommand2) + .setCheckable(true); + options.addItem("Modal", optionsCommand2).setCheckable(true); options.addStyleName("small"); addComponent(options); @@ -513,6 +669,15 @@ public class CommonParts extends VerticalLayout implements View { show.addStyleName("primary"); addComponent(show); + final CheckBox hidden = new CheckBox("Hidden"); + hidden.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + win.setVisible(!hidden.getValue()); + } + }); + addComponent(hidden); + win.addCloseListener(new CloseListener() { @Override public void windowClose(CloseEvent e) { @@ -526,54 +691,6 @@ public class CommonParts extends VerticalLayout implements View { } - VerticalLayout windowContents(boolean scrollable) { - VerticalLayout root = new VerticalLayout(); - - HorizontalLayout footer = new HorizontalLayout(); - footer.setWidth("100%"); - footer.setSpacing(true); - footer.addStyleName("v-window-bottom-toolbar"); - - Label footerText = new Label("Footer text"); - footerText.setSizeUndefined(); - - Button ok = new Button("OK"); - ok.addStyleName("primary"); - - Button cancel = new Button("Cancel"); - - footer.addComponents(footerText, ok, cancel); - footer.setExpandRatio(footerText, 1); - - Component content = null; - if (scrollable) { - Panel panel = new Panel(); - panel.setSizeFull(); - panel.addStyleName("borderless"); - // Adds a border between the caption and the content - panel.addStyleName("scroll-divider"); - VerticalLayout l = new VerticalLayout(); - l.addComponent(new Label( - "

Subtitle

Quam diu etiam furor iste tuus nos eludet? Petierunt uti sibi concilium totius Galliae in diem certam indicere. Ut enim ad minim veniam, quis nostrud exercitation. Quae vero auctorem tractata ab fiducia dicuntur.

Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.

", - ContentMode.HTML)); - l.setMargin(true); - panel.setContent(l); - content = panel; - } else { - content = new Label( - "

Subtitle

Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.

", - ContentMode.HTML); - } - root.addComponents(content, footer); - if (scrollable) { - root.setSizeFull(); - root.setExpandRatio(content, 1); - } - root.setMargin(!scrollable); - - return root; - } - @Override public void enter(ViewChangeEvent event) { // TODO Auto-generated method stub diff --git a/uitest/src/com/vaadin/tests/themes/valo/Dragging.java b/uitest/src/com/vaadin/tests/themes/valo/Dragging.java new file mode 100644 index 0000000000..27bdea7d8a --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/Dragging.java @@ -0,0 +1,273 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.themes.valo; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.vaadin.event.Transferable; +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.DropTarget; +import com.vaadin.event.dd.TargetDetails; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.event.dd.acceptcriteria.Not; +import com.vaadin.event.dd.acceptcriteria.SourceIsTarget; +import com.vaadin.navigator.View; +import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; +import com.vaadin.server.ThemeResource; +import com.vaadin.shared.ui.dd.HorizontalDropLocation; +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.Component; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.DragAndDropWrapper; +import com.vaadin.ui.Embedded; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.MenuItem; +import com.vaadin.ui.Notification; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class Dragging extends VerticalLayout implements View { + + SortableLayout sample; + + public Dragging() { + setMargin(true); + setSpacing(true); + + Label h1 = new Label("Dragging Components"); + h1.addStyleName("h1"); + addComponent(h1); + + MenuBar options = new MenuBar(); + options.setCaption("Drop Hints"); + addComponent(options); + + // Use these styles to hide irrelevant drag hints + // Can be used either on a parent or directly on the DnDWrapper + MenuItem opt = options.addItem("Vertical", new MenuBar.Command() { + @Override + public void menuSelected(MenuItem selectedItem) { + if (selectedItem.isChecked()) { + sample.removeStyleName("no-vertical-drag-hints"); + } else { + sample.addStyleName("no-vertical-drag-hints"); + } + } + }); + opt.setCheckable(true); + opt.setChecked(true); + + opt = options.addItem("Horizontal", new MenuBar.Command() { + @Override + public void menuSelected(MenuItem selectedItem) { + if (selectedItem.isChecked()) { + sample.removeStyleName("no-horizontal-drag-hints"); + } else { + sample.addStyleName("no-horizontal-drag-hints"); + } + } + }); + opt.setCheckable(true); + opt.setChecked(true); + + opt = options.addItem("Box", new MenuBar.Command() { + @Override + public void menuSelected(MenuItem selectedItem) { + if (selectedItem.isChecked()) { + sample.removeStyleName("no-box-drag-hints"); + } else { + sample.addStyleName("no-box-drag-hints"); + } + } + }); + opt.setCheckable(true); + opt.setChecked(true); + + sample = new SortableLayout(); + sample.setSizeUndefined(); + sample.setHeight("100px"); + + for (final Component component : createComponents()) { + sample.addComponent(component); + } + + addComponent(sample); + + } + + private List createComponents() { + final List components = new ArrayList(); + + final Label label = new Label( + "This is a long text block that will wrap."); + label.setWidth("120px"); + components.add(label); + + final Embedded image = new Embedded("", new ThemeResource( + "../runo/icons/64/document.png")); + components.add(image); + + final CssLayout documentLayout = new CssLayout(); + documentLayout.setWidth("19px"); + for (int i = 0; i < 5; ++i) { + final Embedded e = new Embedded(null, new ThemeResource( + "../runo/icons/16/document.png")); + e.setHeight("16px"); + e.setWidth("16px"); + documentLayout.addComponent(e); + } + components.add(documentLayout); + + final VerticalLayout buttonLayout = new VerticalLayout(); + final Button button = new Button("Button"); + button.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(final ClickEvent event) { + Notification.show("Button clicked"); + } + }); + buttonLayout.addComponent(button); + buttonLayout.setComponentAlignment(button, Alignment.MIDDLE_CENTER); + components.add(buttonLayout); + + return components; + } + + private static class ReorderLayoutDropHandler implements DropHandler { + + private final AbstractOrderedLayout layout; + + public ReorderLayoutDropHandler(final AbstractOrderedLayout layout) { + this.layout = layout; + } + + @Override + public AcceptCriterion getAcceptCriterion() { + return new Not(SourceIsTarget.get()); + } + + @Override + public void drop(final DragAndDropEvent dropEvent) { + final Transferable transferable = dropEvent.getTransferable(); + final Component sourceComponent = transferable.getSourceComponent(); + if (sourceComponent instanceof WrappedComponent) { + final TargetDetails dropTargetData = dropEvent + .getTargetDetails(); + final DropTarget target = dropTargetData.getTarget(); + + // find the location where to move the dragged component + boolean sourceWasAfterTarget = true; + int index = 0; + final Iterator componentIterator = layout + .getComponentIterator(); + Component next = null; + while (next != target && componentIterator.hasNext()) { + next = componentIterator.next(); + if (next != sourceComponent) { + index++; + } else { + sourceWasAfterTarget = false; + } + } + if (next == null || next != target) { + // component not found - if dragging from another layout + return; + } + + // drop on top of target? + if (dropTargetData.getData("horizontalLocation").equals( + HorizontalDropLocation.CENTER.toString())) { + if (sourceWasAfterTarget) { + index--; + } + } + + // drop before the target? + else if (dropTargetData.getData("horizontalLocation").equals( + HorizontalDropLocation.LEFT.toString())) { + index--; + if (index < 0) { + index = 0; + } + } + + // move component within the layout + layout.removeComponent(sourceComponent); + layout.addComponent(sourceComponent, index); + } + } + } + + private static class SortableLayout extends CustomComponent { + private final AbstractOrderedLayout layout; + private final DropHandler dropHandler; + + public SortableLayout() { + layout = new HorizontalLayout(); + layout.setMargin(true); + dropHandler = new ReorderLayoutDropHandler(layout); + + // final DragAndDropWrapper pane = new DragAndDropWrapper(layout); + setCompositionRoot(layout); + } + + public void addComponent(final Component component) { + final WrappedComponent wrapper = new WrappedComponent(component, + dropHandler); + wrapper.setSizeUndefined(); + component.setHeight("100%"); + wrapper.setHeight("100%"); + layout.addComponent(wrapper); + } + } + + private static class WrappedComponent extends DragAndDropWrapper { + + private final DropHandler dropHandler; + + public WrappedComponent(final Component content, + final DropHandler dropHandler) { + super(content); + this.dropHandler = dropHandler; + setDragStartMode(DragStartMode.WRAPPER); + } + + @Override + public DropHandler getDropHandler() { + return dropHandler; + } + + } + + @Override + public void enter(ViewChangeEvent event) { + // TODO Auto-generated method stub + + } +} diff --git a/uitest/src/com/vaadin/tests/themes/valo/MenuBars.java b/uitest/src/com/vaadin/tests/themes/valo/MenuBars.java index c75338912a..f15f43254a 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/MenuBars.java +++ b/uitest/src/com/vaadin/tests/themes/valo/MenuBars.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 Vaadin Ltd. + * Copyright 2000-2014 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -47,45 +47,58 @@ public class MenuBars extends VerticalLayout implements View { menuBar.setCaption("Borderless style"); menuBar.addStyleName("borderless"); addComponent(menuBar); + + menuBar = getMenuBar(); + menuBar.setCaption("Small borderless style"); + menuBar.addStyleName("borderless"); + menuBar.addStyleName("small"); + addComponent(menuBar); } - MenuBar getMenuBar() { + static MenuBar getMenuBar() { + Command click = new Command() { + @Override + public void menuSelected(MenuItem selectedItem) { + Notification.show("Clicked " + selectedItem.getText()); + } + }; + MenuBar menubar = new MenuBar(); menubar.setWidth("100%"); final MenuBar.MenuItem file = menubar.addItem("File", null); final MenuBar.MenuItem newItem = file.addItem("New", null); - file.addItem("Open file...", null); + file.addItem("Open file...", click); file.addSeparator(); - newItem.addItem("File", null); - newItem.addItem("Folder", null); - newItem.addItem("Project...", null); + newItem.addItem("File", click); + newItem.addItem("Folder", click); + newItem.addItem("Project...", click); - file.addItem("Close", null); - file.addItem("Close All", null); + file.addItem("Close", click); + file.addItem("Close All", click); file.addSeparator(); - file.addItem("Save", null); - file.addItem("Save As...", null); - file.addItem("Save All", null); + file.addItem("Save", click); + file.addItem("Save As...", click); + file.addItem("Save All", click); final MenuBar.MenuItem edit = menubar.addItem("Edit", null); - edit.addItem("Undo", null); - edit.addItem("Redo", null).setEnabled(false); + edit.addItem("Undo", click); + edit.addItem("Redo", click).setEnabled(false); edit.addSeparator(); - edit.addItem("Cut", null); - edit.addItem("Copy", null); - edit.addItem("Paste", null); + edit.addItem("Cut", click); + edit.addItem("Copy", click); + edit.addItem("Paste", click); edit.addSeparator(); final MenuBar.MenuItem find = edit.addItem("Find/Replace", null); - find.addItem("Google Search", null); + find.addItem("Google Search", click); find.addSeparator(); - find.addItem("Find/Replace...", null); - find.addItem("Find Next", null); - find.addItem("Find Previous", null); + find.addItem("Find/Replace...", click); + find.addItem("Find Next", click); + find.addItem("Find Previous", click); Command check = new Command() { @Override @@ -100,12 +113,12 @@ public class MenuBars extends VerticalLayout implements View { MenuItem title = view.addItem("Show Title Bar", check); title.setCheckable(true); title.setChecked(true); - view.addItem("Customize Toolbar...", null); + view.addItem("Customize Toolbar...", click); view.addSeparator(); - view.addItem("Actual Size", null); - view.addItem("Zoom In", null); - view.addItem("Zoom Out", null); + view.addItem("Actual Size", click); + view.addItem("Zoom In", click); + view.addItem("Zoom Out", click); MenuItem fav = menubar.addItem("", check); fav.setIcon(TestIcon.get()); @@ -119,12 +132,48 @@ public class MenuBars extends VerticalLayout implements View { fav.setCheckable(true); fav.setCheckable(true); - menubar.addItem("Attach", null).setIcon(FontAwesome.PAPERCLIP); - menubar.addItem("Undo", null).setIcon(FontAwesome.UNDO); - MenuItem redo = menubar.addItem("Redo", null); + menubar.addItem("Attach", click).setIcon(FontAwesome.PAPERCLIP); + menubar.addItem("Undo", click).setIcon(FontAwesome.UNDO); + MenuItem redo = menubar.addItem("Redo", click); + redo.setIcon(FontAwesome.REPEAT); + redo.setEnabled(false); + menubar.addItem("Upload", click).setIcon(FontAwesome.UPLOAD); + + return menubar; + } + + static MenuBar getToolBar() { + MenuBar menubar = new MenuBar(); + menubar.setWidth("100%"); + + MenuItem fav = menubar.addItem("", null); + fav.setIcon(FontAwesome.ALIGN_LEFT); + fav.setStyleName("icon-only"); + fav.setCheckable(true); + // fav.setChecked(true); + + fav = menubar.addItem("", null); + fav.setIcon(FontAwesome.ALIGN_CENTER); + fav.setStyleName("icon-only"); + fav.setCheckable(true); + + fav = menubar.addItem("", null); + fav.setIcon(FontAwesome.ALIGN_RIGHT); + fav.setStyleName("icon-only"); + fav.setCheckable(true); + + MenuItem clip = menubar.addItem("", null); + clip.setIcon(FontAwesome.PAPERCLIP); + clip.setStyleName("icon-only"); + + MenuItem undo = menubar.addItem("", null); + undo.setIcon(FontAwesome.UNDO); + undo.setStyleName("icon-only"); + + MenuItem redo = menubar.addItem("", null); redo.setIcon(FontAwesome.REPEAT); redo.setEnabled(false); - menubar.addItem("Upload", null).setIcon(FontAwesome.UPLOAD); + redo.setStyleName("icon-only"); return menubar; } diff --git a/uitest/src/com/vaadin/tests/themes/valo/RandomTests.java b/uitest/src/com/vaadin/tests/themes/valo/RandomTests.java new file mode 100644 index 0000000000..26e2cd4eb6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/RandomTests.java @@ -0,0 +1,83 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.themes.valo; + +import com.vaadin.navigator.View; +import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.InlineDateField; +import com.vaadin.ui.Label; +import com.vaadin.ui.Panel; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +public class RandomTests extends VerticalLayout implements View { + public RandomTests() { + setMargin(true); + + Label h1 = new Label("Random Tests"); + h1.addStyleName("h1"); + addComponent(h1); + + Panel p = new Panel(); + addComponent(p); + + HorizontalLayout row = new HorizontalLayout(); + p.setHeight("300px"); + // row.setSpacing(true); + // row.setMargin(true); + row.setDefaultComponentAlignment(Alignment.BOTTOM_CENTER); + row.setWidth("100%"); + // row.setHeight("248px"); + row.setSizeFull(); + + Button button = new Button("Boo"); + button.setWidth("100%"); + Button button2 = new Button("Abc"); + button2.setWidth("100%"); + row.addComponents(button, new InlineDateField(), new CheckBox("Far")); + + p.setContent(row); + + p = new Panel(); + addComponent(p); + p.setHeight("400px"); + + VerticalLayout col = new VerticalLayout(); + col.setSizeFull(); + col.setSpacing(true); + // row.setMargin(true); + col.setDefaultComponentAlignment(Alignment.BOTTOM_CENTER); + + col.addComponents(new Button("Boo"), new InlineDateField(), + new CheckBox("Far"), new Button("Abc")); + + p.setContent(col); + + Table t = Tables.getTable(null); + t.setSizeFull(); + p.setContent(t); + } + + @Override + public void enter(ViewChangeEvent event) { + // TODO Auto-generated method stub + } + +} diff --git a/uitest/src/com/vaadin/tests/themes/valo/Tables.java b/uitest/src/com/vaadin/tests/themes/valo/Tables.java index d9e4bdd3ab..05cbf1e934 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/Tables.java +++ b/uitest/src/com/vaadin/tests/themes/valo/Tables.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 Vaadin Ltd. + * Copyright 2000-2014 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -107,19 +107,19 @@ public class Tables extends VerticalLayout implements View { addComponent(table); } - TreeTable getTreeTable(String caption) { + static TreeTable getTreeTable(String caption) { TreeTable table = new TreeTable(caption); configure(table, true); return table; } - Table getTable(String caption) { + static Table getTable(String caption) { Table table = new Table(caption); configure(table, false); return table; } - void configure(Table table, boolean hierarchical) { + static void configure(Table table, boolean hierarchical) { table.setSelectable(true); table.setMultiSelect(true); table.setSortEnabled(true); diff --git a/uitest/src/com/vaadin/tests/themes/valo/Tabsheets.java b/uitest/src/com/vaadin/tests/themes/valo/Tabsheets.java index 079a9c6b95..b98d2d398c 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/Tabsheets.java +++ b/uitest/src/com/vaadin/tests/themes/valo/Tabsheets.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 Vaadin Ltd. + * Copyright 2000-2014 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -69,7 +69,7 @@ public class Tabsheets extends VerticalLayout implements View { "icons-on-top padded-tabbar", closable.getValue(), overflow.getValue(), icon.getValue())); wrap.addComponent(getTabSheet("Only selected tab is closable", - "selected-closable", closable.getValue(), + "only-selected-closable", closable.getValue(), overflow.getValue(), icon.getValue())); } }; diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeTest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeTest.java index 0336be05a2..75e306edd2 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeTest.java +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package com.vaadin.tests.themes.valo; import java.util.Iterator; @@ -88,6 +103,8 @@ public class ValoThemeTest extends UI { navigator.addView("calendar", CalendarTest.class); navigator.addView("forms", Forms.class); navigator.addView("popupviews", PopupViews.class); + navigator.addView("random", RandomTests.class); + navigator.addView("dragging", Dragging.class); String f = Page.getCurrent().getUriFragment(); if (f == null || f.equals("")) { @@ -139,6 +156,7 @@ public class ValoThemeTest extends UI { menuItems.put("menubars", "Menu Bars"); menuItems.put("trees", "Trees"); menuItems.put("tables", "Tables"); + menuItems.put("dragging", "Drag and Drop"); menuItems.put("panels", "Panels"); menuItems.put("splitpanels", "Split Panels"); menuItems.put("tabs", "Tabs"); -- 2.39.5