Example usage for com.vaadin.ui Layout addComponent

List of usage examples for com.vaadin.ui Layout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui Layout addComponent.

Prototype

public void addComponent(Component c);

Source Link

Document

Adds the component into this container.

Usage

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getPopupViewPreviews() {
    Layout grid = getPreviewLayout("Popup views");

    Label content = new Label("Simple popup content");
    content.setSizeUndefined();//from   www. ja  va2 s  .  c om
    PopupView pv = new PopupView("Default popup", content);
    grid.addComponent(pv);

    return grid;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getMenuBarPreviews() {
    Layout grid = getPreviewLayout("Menu bars");

    MenuBar menubar = new MenuBar();
    final MenuBar.MenuItem file = menubar.addItem("File", null);
    final MenuBar.MenuItem newItem = file.addItem("New", null);
    file.addItem("Open file...", null);
    file.addSeparator();/*from ww  w. j av  a 2  s  .c om*/

    newItem.addItem("File", null);
    newItem.addItem("Folder", null);
    newItem.addItem("Project...", null);

    file.addItem("Close", null);
    file.addItem("Close All", null);
    file.addSeparator();

    file.addItem("Save", null);
    file.addItem("Save As...", null);
    file.addItem("Save All", null);

    final MenuBar.MenuItem edit = menubar.addItem("Edit", null);
    edit.addItem("Undo", null);
    edit.addItem("Redo", null).setEnabled(false);
    edit.addSeparator();

    edit.addItem("Cut", null);
    edit.addItem("Copy", null);
    edit.addItem("Paste", null);
    edit.addSeparator();

    final MenuBar.MenuItem find = edit.addItem("Find/Replace", null);

    // Actions can be added inline as well, of course
    find.addItem("Google Search", null);
    find.addSeparator();
    find.addItem("Find/Replace...", null);
    find.addItem("Find Next", null);
    find.addItem("Find Previous", null);

    final MenuBar.MenuItem view = menubar.addItem("View", null);
    view.addItem("Show/Hide Status Bar", null);
    view.addItem("Customize Toolbar...", null);
    view.addSeparator();

    view.addItem("Actual Size", null);
    view.addItem("Zoom In", null);
    view.addItem("Zoom Out", null);

    grid.addComponent(menubar);

    return grid;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getWindowPreviews() {
    Layout grid = getPreviewLayout("Windows");

    Button win = new Button("Open normal sub-window", new Button.ClickListener() {
        @Override//www. jav  a2  s . c  om
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(new Window("Normal window"));
        }
    });
    grid.addComponent(win);
    win.setDescription("new Window()");

    win = new Button("Open opaque sub-window", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Window w = new Window("Window.addStyleName(\"opaque\")");
            w.addStyleName("opaque");
            getApplication().getMainWindow().addWindow(w);
        }
    });
    grid.addComponent(win);
    win.setDescription("Window.addStyleName(\"opaque\")");

    return grid;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getCompoundButtons() {
    Layout grid = getPreviewLayout("Compound Buttons");

    Label title = new Label("Segment");
    title.setStyleName("h1");
    grid.addComponent(title);
    ((GridLayout) grid).newLine();

    Label segments = new Label(
            "The segment control is just a set of buttons inside a HorizontalLayout. Use the structure shown on the right, <strong>and remember that you need to implement all logic yourself</strong>. This theme just provides suitable stylenames for you to use.",
            Label.CONTENT_XHTML);
    grid.addComponent(segments);/*www.  jav a 2 s  .com*/
    segments = new Label(
            "HorizontalLayout.setStyleName(\"segment\") and .addStyleName(\"segment-alternate\")\n  +  Button.addStyleName(\"first\") and .addStyleName(\"down\")\n  +  Button\n\t...\n  +  Button.addStyleName(\"last\")",
            Label.CONTENT_PREFORMATTED);
    ((GridLayout) grid).addComponent(segments, 1, 1, 2, 1);

    Segment segment = new Segment();
    segment.setCaption("Segment");
    Button b = new Button("One");
    b.setStyleName("down");
    b.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));
    segment.addButton(b).addButton(new Button("Two")).addButton(new Button("Three"))
            .addButton(new Button("Four"));
    grid.addComponent(segment);

    segment = new Segment();
    segment.addStyleName("segment-alternate");
    segment.setCaption("Segment (alternate)");
    b = new Button("One");
    b.setStyleName("down");
    b.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));
    segment.addButton(b).addButton(new Button("Two")).addButton(new Button("Three"))
            .addButton(new Button("Four"));
    grid.addComponent(segment);

    segment = new Segment();
    segment.setCaption("Small segment");
    b = new Button("Apples");
    b.setStyleName("small");
    b.addStyleName("down");
    segment.addButton(b);
    b = new Button("Oranges");
    b.setStyleName("small");
    segment.addButton(b);
    b = new Button("Bananas");
    b.setStyleName("small");
    segment.addButton(b);
    b = new Button("Grapes");
    b.setStyleName("small");
    segment.addButton(b);
    grid.addComponent(segment);

    return grid;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

Layout getCompoundMenus() {
    Layout grid = getPreviewLayout("Compound Menus");

    Label title = new Label("Sidebar Menu");
    title.setStyleName("h1");
    grid.addComponent(title);
    ((GridLayout) grid).newLine();

    Label menus = new Label(
            "<strong>The sidebar menu</strong> control is just a set of labels and buttons inside a CssLayout or a VerticalLayout. Use the structure shown on the right, <strong>and remember that you need to implement all logic yourself</strong>. This theme just provides suitable stylenames for you to use.<br><br>You can also use the <a href=\"http://vaadin.com/forum/-/message_boards/message/119172\">DetachedTabs add-on</a> inside the sidebar-menu, it will style automatically.<br><br><strong>Note: only NativeButtons are styled inside the menu, normal buttons are left untouched.</strong>",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);/*  ww w  . j ava2  s.  com*/
    menus = new Label(
            "CssLayout.setStyleName(\"sidebar-menu\")\n  +  Label\n  +  NativeButton\n  +  NativeButton\n\t...\n  +  Label\n  +  DetachedTabs\n\t...",
            Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    SidebarMenu sidebar = new SidebarMenu();
    sidebar.setWidth("200px");
    sidebar.addComponent(new Label("Fruits"));
    NativeButton b = new NativeButton("Apples");
    b.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    sidebar.addButton(b);
    sidebar.setSelected(b);
    sidebar.addButton(new NativeButton("Oranges"));
    sidebar.addButton(new NativeButton("Bananas"));
    sidebar.addButton(new NativeButton("Grapes"));
    sidebar.addComponent(new Label("Vegetables"));
    sidebar.addButton(new NativeButton("Tomatoes"));
    sidebar.addButton(new NativeButton("Cabbages"));
    sidebar.addButton(new NativeButton("Potatoes"));
    sidebar.addButton(new NativeButton("Carrots"));
    grid.addComponent(sidebar);
    ((GridLayout) grid).setColumnExpandRatio(0, 1);
    ((GridLayout) grid).setColumnExpandRatio(1, 1);

    title = new Label("Toolbar");
    title.setStyleName("h1");
    grid.addComponent(title);
    ((GridLayout) grid).newLine();

    CssLayout toolbars = new CssLayout();

    menus = new Label(
            "<strong>Toolbar</strong> is a simple CssLayout with a stylename. It provides the background and a little padding for its contents. Normally you will want to put buttons inside it, but segment controls fit in nicely as well.",
            Label.CONTENT_XHTML);
    grid.addComponent(menus);
    menus = new Label("CssLayout.setStyleName(\"toolbar\")", Label.CONTENT_PREFORMATTED);
    grid.addComponent(menus);

    CssLayout toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    Button b2 = new Button("Action");
    b2.setStyleName("small");
    toolbar.addComponent(b2);

    Segment segment = new Segment();
    segment.addStyleName("segment-alternate");
    b2 = new Button("Apples");
    b2.setStyleName("small");
    b2.addStyleName("down");
    segment.addButton(b2);
    b2 = new Button("Oranges");
    b2.setStyleName("small");
    segment.addButton(b2);
    toolbar.addComponent(segment);

    b2 = new Button("Notes");
    b2.setStyleName("small borderless");
    b2.setIcon(new ThemeResource("../runo/icons/16/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    toolbar = new CssLayout();
    toolbar.setStyleName("toolbar");
    toolbar.setWidth("300px");

    b2 = new Button("Action");
    b2.setIcon(new ThemeResource("../runo/icons/32/document.png"));
    b2.setStyleName("borderless");
    toolbar.addComponent(b2);

    b2 = new Button("Action 2");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/user.png"));
    toolbar.addComponent(b2);

    b2 = new Button("Action 3");
    b2.setStyleName("borderless");
    b2.setIcon(new ThemeResource("../runo/icons/32/note.png"));
    toolbar.addComponent(b2);
    toolbars.addComponent(toolbar);

    grid.addComponent(toolbars);

    return grid;
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java

License:Apache License

public void setTabContent(Tab target, Component content, String permission) {
    Component c = target.getComponent();
    if (c != null && c instanceof Layout) {
        Layout l = (Layout) c;
        l.removeAllComponents();//w  ww.j a  v  a  2 s .  c  o m
        if (content != null) {
            l.addComponent(content);
        }
    } else {
        LOG.log(Level.SEVERE, "Invalid target: {0}", target);
    }
    if (permission != null && !permission.isEmpty()) {
        //Hide tab based on permissions
        boolean viewable = checkRight(permission);
        if (viewable != target.isVisible()) {
            target.setVisible(viewable);
        }
    }
    tabSheet.setSelectedTab(target);
}

From source file:nz.co.senanque.vaadinsupport.tableeditor.EditorWindowImpl.java

License:Apache License

public void initialize(List<String> fields) {
    Layout main = new VerticalLayout();
    setLayout(main);/*from w  w  w . jav a  2 s .  c o m*/
    main.setWidth(getWindowWidth());
    main.setStyleName(Panel.STYLE_LIGHT);

    setFields(fields);
    m_form.setSizeFull();

    main.addComponent(m_form);

    save = m_form.createButton("save", new SubmitButtonPainter(m_maduraSessionManager), this);
    delete = m_form.createButton("delete", new SimpleButtonPainter(m_maduraSessionManager), this);
    close = m_form.createButton("close", new SimpleButtonPainter(m_maduraSessionManager), this);

    extraFields();
    HorizontalLayout actions = new HorizontalLayout();
    actions.addComponent(save);

    save.addListener(this);

    actions.addComponent(delete);
    delete.addListener(this);
    close.addListener(this);
    actions.addComponent(close);

    main.addComponent(actions);
}

From source file:org.azrul.langkuik.framework.webgui.breadcrumb.BreadCrumbBuilder.java

public static void buildBreadCrumb(final Navigator navigator, final Layout breadcrumb,
        final Deque<History> history) {
    ((HorizontalLayout) breadcrumb).removeAllComponents();

    for (Iterator<History> it = history.descendingIterator(); it.hasNext();) {
        final History h = it.next();
        Button button = new Button(h.getDisplayName() + " >", new Button.ClickListener() {

            @Override//w w w  .ja va 2s.  c  om
            public void buttonClick(Button.ClickEvent event) {
                while (!h.getViewHandle().equals(history.peek().getViewHandle())) {
                    history.pop();
                }
                navigator.navigateTo(h.getViewHandle());
            }
        });
        //button.addStyleName("link");
        breadcrumb.addComponent(button);
    }
}

From source file:org.eclipse.skalli.view.component.PeopleComponent.java

License:Open Source License

protected PeopleComponent(final User user) {
    addStyleName(STYLE);//from  ww  w .  j  a  v a  2 s  .c  o m

    Layout layout = new CssLayout();
    layout.setSizeFull();
    layout.setMargin(false);

    StringBuilder sb = new StringBuilder();
    sb.append("<span class=\"v-img-peoplecomponent\">"); //$NON-NLS-1$
    sb.append("<img src=\"/VAADIN/themes/simple/icons/people/team.png\" /> "); //$NON-NLS-1$
    sb.append("</span>"); //$NON-NLS-1$

    String userDetailsLink = UserDetailsUtil.getUserDetailsLink(user.getUserId());
    if (userDetailsLink != null) {
        // user details link configured, render a link to user details dialog
        sb.append("<a href=\""); //$NON-NLS-1$
        sb.append(userDetailsLink);
        sb.append("\" target=\"_blank\">"); //$NON-NLS-1$
        sb.append(StringEscapeUtils.escapeHtml(user.getDisplayName()));
        sb.append("</a> "); //$NON-NLS-1$
    } else {
        // not configured, just display the user name
        sb.append(StringEscapeUtils.escapeHtml(user.getDisplayName()));
        sb.append(" "); //$NON-NLS-1$
    }

    sb.append("<span class=\"v-link-peoplecomponent\">"); //$NON-NLS-1$

    if (user.hasEmail()) {
        sb.append("<a class=\"link\" href=\"mailto:"); //$NON-NLS-1$
        sb.append(user.getEmail());
        sb.append("\">"); //$NON-NLS-1$
        sb.append("Mail");
        sb.append("</a> "); //$NON-NLS-1$
    }

    sb.append("<a class=\"link\" href=\""); //$NON-NLS-1$
    sb.append(Consts.URL_PROJECTS_USER);
    sb.append(StringEscapeUtils.escapeHtml(user.getUserId()));
    sb.append("\">"); //$NON-NLS-1$
    sb.append("Projects");
    sb.append("</a> "); //$NON-NLS-1$

    sb.append("</span>"); //$NON-NLS-1$

    Label lbl = new Label();
    lbl.setContentMode(Label.CONTENT_XHTML);
    lbl.setValue(sb.toString());
    layout.addComponent(lbl);

    setCompositionRoot(layout);
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.FeedInfoBox.java

License:Open Source License

private void renderSourceFilters(Layout parentLayout, Project project, String userId,
        HashMap<String, SourceDetails> sourceFilter) {
    FloatLayout grid = new FloatLayout();
    Set<String> keys = sourceFilter.keySet();
    for (String source : keys) {
        addSourceFilter(parentLayout, grid, source, sourceFilter, project, userId);
    }//ww w .  j  ava  2s .c o m
    parentLayout.addComponent(grid);
}