Example usage for com.vaadin.ui HorizontalLayout setDefaultComponentAlignment

List of usage examples for com.vaadin.ui HorizontalLayout setDefaultComponentAlignment

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setDefaultComponentAlignment.

Prototype

@Override
    public void setDefaultComponentAlignment(Alignment defaultAlignment) 

Source Link

Usage

From source file:org.lucidj.ui.gauss.GaussUI.java

License:Apache License

private void initSecurityArea() {
    HorizontalLayout click_catcher = new HorizontalLayout();
    {// www.  jav a 2s . c  o  m
        click_catcher.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

        String fancy_css = "background-color: white; vertical-align:middle; width: 32px; height: 32px; border-radius: 50%;";
        String userinfo_html = "<span style='vertical-align:middle;'>LucidJ Admin</span>" + "&nbsp;&nbsp;"
                + "<img style='" + fancy_css + "' src='/VAADIN/~/vaadinui_libraries/user-frank-128x128.png'>";
        Label userinfo = new Label(userinfo_html, ContentMode.HTML);
        click_catcher.addComponent(userinfo);

        click_catcher.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
            @Override
            public void layoutClick(LayoutEvents.LayoutClickEvent layoutClickEvent) {
                navigator.navigateTo("accounts");
            }
        });
    }
    hSecurityArea.addComponent(click_catcher);
}

From source file:org.lucidj.vaadinui.BaseVaadinUI.java

License:Apache License

private void initSystemToolbar() {
    desktop_canvas.setSizeFull();/*  ww w .j  ava 2s  . c  o  m*/
    desktop_canvas.setWidth("100%");

    ui_header = new HorizontalLayout();
    {
        ui_header.setStyleName("ui-header-area");
        ui_header.setWidth(100, Sizeable.Unit.PERCENTAGE);
        ui_header.setHeightUndefined();
        ui_header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

        Label logo = new Label("&nbsp;", ContentMode.HTML);
        {
            logo.addStyleName("ui-header-logo");
            logo.setWidth(default_sidebar_width_pixels, Sizeable.Unit.PIXELS);
        }
        ui_header.addComponent(logo);

        HorizontalLayout header_components = new HorizontalLayout();
        {
            header_components.setWidth(100, com.vaadin.server.Sizeable.Unit.PERCENTAGE);
            header_components.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
            header_components.setSpacing(true);

            // Search component
            CssLayout search_component = new CssLayout();
            {
                search_component.setWidth(100, com.vaadin.server.Sizeable.Unit.PERCENTAGE);
                search_component.setWidthUndefined();
                search_component.addStyleName("v-component-group");
                search_component.addStyleName("ui-header-search");
                final ComboBox search_text = new ComboBox();
                {
                    search_text.setInputPrompt("Search or paste URL...");
                    //combo.setContainerDataSource(StringGenerator.generateContainer(200, false));
                    search_text.setNullSelectionAllowed(true);
                    search_text.setTextInputAllowed(true);
                    search_text.setNewItemsAllowed(true);
                    //combo.select(combo.getItemIds().iterator().next());
                    //combo.setItemCaptionPropertyId(StringGenerator.CAPTION_PROPERTY);
                    //combo.setItemIconPropertyId(StringGenerator.ICON_PROPERTY);

                    // TODO: SOMEDAY DISCOVER HOW TO EXPAND THIS GROUPED COMPONENT, AND THE CURE FOR CANCER
                    search_text.setWidth("480px");
                    search_text.addStyleName("invisible-focus");
                    search_text.addValueChangeListener(new Property.ValueChangeListener() {
                        @Override
                        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                            String search_args = (String) search_text.getValue();

                            if (search_args != null) {
                                fireEvent("search", search_text.getValue());
                                value_change_button_quirk = true;
                            }
                        }
                    });

                    // Handles the Enter key by activating on focus and deactivating on blur
                    final ShortcutListener handle_enter = new ShortcutListener("Enter",
                            ShortcutAction.KeyCode.ENTER, null) {
                        @Override
                        public void handleAction(Object o, Object o1) {
                            value_change_button_quirk = false;
                            fireEvent("search", search_text.getValue());
                        }
                    };

                    search_text.addFocusListener(new FieldEvents.FocusListener() {
                        @Override
                        public void focus(FieldEvents.FocusEvent focusEvent) {
                            if (nested_focus_blur_bug_count++ == 0) {
                                search_text.addShortcutListener(handle_enter);
                            }
                        }
                    });

                    search_text.addBlurListener(new FieldEvents.BlurListener() {
                        @Override
                        public void blur(FieldEvents.BlurEvent blurEvent) {
                            if (--nested_focus_blur_bug_count == 0) {
                                search_text.removeShortcutListener(handle_enter);
                            }
                        }
                    });

                }
                search_component.addComponent(search_text);

                Button search_button = new Button();
                {
                    search_button.setIcon(FontAwesome.SEARCH);
                    search_button.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent clickEvent) {
                            if (!value_change_button_quirk) {
                                fireEvent("search", search_text.getValue());
                            }
                            value_change_button_quirk = false;
                        }
                    });
                    search_button.addStyleName("invisible-focus");
                }
                search_component.addComponent(search_button);
            }
            header_components.addComponent(search_component);

            // User component
            user_component = new HorizontalLayout();
            {
                user_component.setStyleName("ui-header-user");
                user_component.setWidthUndefined();
            }
            header_components.addComponent(user_component);

            // I swear someday I'll learn CSS, AFTER implementing my own distributed
            // operating system with augmented reality interface and a machine learning kernel,
            // all written in Z80 assembly, as a preparation for the task.
            Label spacer = new Label();
            spacer.setWidthUndefined();
            header_components.addComponent(spacer);

            // Search expands
            header_components.setExpandRatio(search_component, 1.0f);
        }
        ui_header.addComponent(header_components);
        ui_header.setExpandRatio(header_components, 1.0f);
    }

    desktop_canvas.addComponent(ui_header);
    desktop_canvas.addComponent(empty_desktop);
    desktop_canvas.setExpandRatio(empty_desktop, 1.0f);
    setContent(desktop_canvas);
}

From source file:org.opennms.features.pluginmgr.vaadin.config.karaf.PluginManagerAdminApplication.java

License:Apache License

@Override
public void init(VaadinRequest request) {

    m_request = request;//from w  w w.j  a  va 2  s  .  com

    m_rootLayout = new VerticalLayout();
    m_rootLayout.setSizeFull();
    m_rootLayout.addStyleName("root-layout");
    setContent(m_rootLayout);

    // dynamically inject style for non write borders - avoids changing themes css
    // Get the stylesheet of the page
    Styles styles = Page.getCurrent().getStyles();
    // inject the new font size as a style. We need .v-app to override Vaadin's default styles here
    styles.add(".v-app .v-textfield-readonly {border: 1px solid #b6b6b6!important;"
            + " border-top-color: #9d9d9d!important;" + "border-bottom-color: #d6d6d6!important;"
            + "border-right-color: #d6d6d6!important;" + " opacity: 1.0!important;" + "filter: none;  }");
    styles.add(".v-app .v-textarea-readonly {border: 1px solid #b6b6b6!important;"
            + " border-top-color: #9d9d9d!important;" + "border-bottom-color: #d6d6d6!important;"
            + "border-right-color: #d6d6d6!important;" + " opacity: 1.0!important;" + "filter: none;  }");

    // add header if provided
    if (headerComponent != null)
        m_rootLayout.addComponent(headerComponent);

    //add additional header page links if provided
    if (headerLinks != null) {
        // defining 2 horizontal layouts to force links to stay together
        HorizontalLayout horizontalLayout1 = new HorizontalLayout();
        horizontalLayout1.setWidth("100%");
        horizontalLayout1.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        HorizontalLayout horizontalLayout2 = new HorizontalLayout();
        horizontalLayout1.addComponent(horizontalLayout2);

        for (String name : headerLinks.keySet()) {
            String urlStr = headerLinks.get(name);
            ExternalResource urlResource = new ExternalResource(urlStr);
            Link link = new Link(name, urlResource);
            Label label = new Label("&nbsp;&nbsp;&nbsp;", ContentMode.HTML); // adds space between links
            horizontalLayout2.addComponent(link);
            horizontalLayout2.addComponent(label);
        }
        m_rootLayout.addComponent(horizontalLayout1);
    }

    PluginManagerUIMainPanel pluginManagerUIMainPanel = new PluginManagerUIMainPanel(sessionPluginManager);

    m_rootLayout.addComponent(pluginManagerUIMainPanel);

    // this forces the UI panel to use up all the available space below the header
    m_rootLayout.setExpandRatio(pluginManagerUIMainPanel, 1.0f);

}

From source file:org.opennms.features.pluginmgr.vaadin.config.karaf.SimpleIframeApplication.java

License:Apache License

@Override
public void init(VaadinRequest request) {
    if (iframePageUrl == null)
        throw new RuntimeException("iframePageUrl must not be null");

    m_request = request;/*w  w  w  .  j ava  2s.c o m*/

    m_rootLayout = new VerticalLayout();

    m_rootLayout = new VerticalLayout();
    m_rootLayout.setSizeFull();
    m_rootLayout.addStyleName("root-layout");
    setContent(m_rootLayout);

    // add header if provided
    if (headerComponent != null)
        m_rootLayout.addComponent(headerComponent);

    //add additional header page links if provided
    if (headerLinks != null) {
        // defining 2 horizontal layouts to force links to stay together
        HorizontalLayout horizontalLayout1 = new HorizontalLayout();
        horizontalLayout1.setWidth("100%");
        horizontalLayout1.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        HorizontalLayout horizontalLayout2 = new HorizontalLayout();
        horizontalLayout1.addComponent(horizontalLayout2);

        for (String name : headerLinks.keySet()) {
            String urlStr = headerLinks.get(name);
            ExternalResource urlResource = new ExternalResource(urlStr);
            Link link = new Link(name, urlResource);
            Label label = new Label("&nbsp;&nbsp;&nbsp;", ContentMode.HTML); // adds space between links
            horizontalLayout2.addComponent(link);
            horizontalLayout2.addComponent(label);
        }
        m_rootLayout.addComponent(horizontalLayout1);
    }

    ExternalResource iframPageResource = new ExternalResource(iframePageUrl);

    BrowserFrame browser = new BrowserFrame("", iframPageResource);
    browser.setWidth("100%");
    browser.setHeight("100%");
    m_rootLayout.addComponent(browser);

    // this forces the UI panel to use up all the available space below the header
    m_rootLayout.setExpandRatio(browser, 1.0f);

}

From source file:org.opennms.features.pluginmgr.vaadin.config.opennms.PluginManagerAdminApplication.java

License:Open Source License

@Override
public void init(VaadinRequest request) {

    m_rootLayout = new VerticalLayout();
    m_rootLayout.setSizeFull();//from  w  ww  .java  2  s.  com
    m_rootLayout.addStyleName("root-layout");
    setContent(m_rootLayout);

    // dynamically inject style for non write borders - avoids changing themes css
    // Get the stylesheet of the page
    Styles styles = Page.getCurrent().getStyles();
    // inject the new font size as a style. We need .v-app to override Vaadin's default styles here
    styles.add(".v-app .v-textfield-readonly {border: 1px solid #b6b6b6!important;"
            + " border-top-color: #9d9d9d!important;" + "border-bottom-color: #d6d6d6!important;"
            + "border-right-color: #d6d6d6!important;" + " opacity: 1.0!important;" + "filter: none;  }");
    styles.add(".v-app .v-textarea-readonly {border: 1px solid #b6b6b6!important;"
            + " border-top-color: #9d9d9d!important;" + "border-bottom-color: #d6d6d6!important;"
            + "border-right-color: #d6d6d6!important;" + " opacity: 1.0!important;" + "filter: none;  }");

    addHeader(request);

    //add diagnostic page links
    if (headerLinks != null) {
        // defining 2 horizontal layouts to force links to stay together
        HorizontalLayout horizontalLayout1 = new HorizontalLayout();
        horizontalLayout1.setWidth("100%");
        horizontalLayout1.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        HorizontalLayout horizontalLayout2 = new HorizontalLayout();
        horizontalLayout1.addComponent(horizontalLayout2);

        for (String name : headerLinks.keySet()) {
            String urlStr = headerLinks.get(name);
            ExternalResource urlResource = new ExternalResource(urlStr);
            Link link = new Link(name, urlResource);
            Label label = new Label("&nbsp;&nbsp;&nbsp;", ContentMode.HTML); // adds space between links
            horizontalLayout2.addComponent(link);
            horizontalLayout2.addComponent(label);
        }
        m_rootLayout.addComponent(horizontalLayout1);
    }

    PluginManagerUIMainPanel pluginManagerUIMainPanel = new PluginManagerUIMainPanel(sessionPluginManager);

    m_rootLayout.addComponent(pluginManagerUIMainPanel);

    // this forces the UI panel to use up all the available space below the header
    m_rootLayout.setExpandRatio(pluginManagerUIMainPanel, 1.0f);

}

From source file:org.opennms.features.pluginmgr.vaadin.config.opennms.SimpleIframeInVaadinApplication.java

License:Open Source License

@Override
public void init(VaadinRequest request) {
    if (iframePageUrl == null)
        throw new RuntimeException("iframePageUrl must not be null");

    m_rootLayout = new VerticalLayout();
    m_rootLayout.setSizeFull();/* ww w  .ja  v  a 2s.  c  o  m*/
    m_rootLayout.addStyleName("root-layout");
    setContent(m_rootLayout);
    addHeader(request);

    //add diagnostic page links
    if (headerLinks != null) {
        // defining 2 horizontal layouts to force links to stay together
        HorizontalLayout horizontalLayout1 = new HorizontalLayout();
        horizontalLayout1.setWidth("100%");
        horizontalLayout1.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        HorizontalLayout horizontalLayout2 = new HorizontalLayout();
        horizontalLayout1.addComponent(horizontalLayout2);

        for (String name : headerLinks.keySet()) {
            String urlStr = headerLinks.get(name);
            ExternalResource urlResource = new ExternalResource(urlStr);
            Link link = new Link(name, urlResource);
            Label label = new Label("&nbsp;&nbsp;&nbsp;", ContentMode.HTML); // adds space between links
            horizontalLayout2.addComponent(link);
            horizontalLayout2.addComponent(label);
        }
        m_rootLayout.addComponent(horizontalLayout1);
    }

    ExternalResource iframPageResource = new ExternalResource(iframePageUrl);

    BrowserFrame browser = new BrowserFrame("", iframPageResource);
    browser.setWidth("100%");
    browser.setHeight("100%");
    m_rootLayout.addComponent(browser);

    // this forces the UI panel to use up all the available space below the header
    m_rootLayout.setExpandRatio(browser, 1.0f);

}

From source file:org.opennms.features.topology.app.internal.TopologyUI.java

License:Open Source License

private Component createMapLayout() {
    final Property<Double> scale = m_graphContainer.getScaleProperty();

    m_lastUpdatedTimeLabel = new LastUpdatedLabel();
    m_lastUpdatedTimeLabel.setImmediate(true);

    m_zoomLevelLabel.setHeight(20, Unit.PIXELS);
    m_zoomLevelLabel.setWidth(22, Unit.PIXELS);
    m_zoomLevelLabel.addStyleName("center-text");
    m_zoomLevelLabel.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override/*from www .ja  va2 s  . c  o  m*/
        public void textChange(FieldEvents.TextChangeEvent event) {
            try {
                int zoomLevel = Integer.parseInt(event.getText());
                setSemanticZoomLevel(zoomLevel);
            } catch (NumberFormatException e) {
                setSemanticZoomLevel(m_graphContainer.getSemanticZoomLevel());
            }

        }
    });

    m_topologyComponent = new TopologyComponent(m_graphContainer, m_iconRepositoryManager, this);
    m_topologyComponent.setSizeFull();
    m_topologyComponent.addMenuItemStateListener(this);
    m_topologyComponent.addVertexUpdateListener(this);

    final Slider slider = new Slider(0, 1);
    slider.setPropertyDataSource(scale);
    slider.setResolution(1);
    slider.setHeight("200px");
    slider.setOrientation(SliderOrientation.VERTICAL);

    slider.setImmediate(true);

    final NativeButton showFocusVerticesBtn = new NativeButton(FontAwesomeIcons.Icon.eye_open.variant());
    showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes");
    showFocusVerticesBtn.setHtmlContentAllowed(true);
    showFocusVerticesBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (showFocusVerticesBtn.getCaption().equals(FontAwesomeIcons.Icon.eye_close.variant())) {
                showFocusVerticesBtn.setCaption(FontAwesomeIcons.Icon.eye_open.variant());
            } else {
                showFocusVerticesBtn.setCaption(FontAwesomeIcons.Icon.eye_close.variant());
            }
            m_topologyComponent.getState()
                    .setHighlightFocus(!m_topologyComponent.getState().isHighlightFocus());
            m_topologyComponent.updateGraph();
        }
    });

    final NativeButton magnifyBtn = new NativeButton();
    magnifyBtn.setHtmlContentAllowed(true);
    magnifyBtn.setCaption("<i class=\"" + FontAwesomeIcons.Icon.zoom_in.stylename() + "\" ></i>");
    magnifyBtn.setStyleName("icon-button");
    magnifyBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (slider.getValue() < 1) {
                slider.setValue(Math.min(1, slider.getValue() + 0.25));
            }
        }
    });

    final NativeButton demagnifyBtn = new NativeButton();
    demagnifyBtn.setHtmlContentAllowed(true);
    demagnifyBtn.setCaption("<i class=\"" + FontAwesomeIcons.Icon.zoom_out.stylename() + "\" ></i>");
    demagnifyBtn.setStyleName("icon-button");
    demagnifyBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (slider.getValue() != 0) {
                slider.setValue(Math.max(0, slider.getValue() - 0.25));
            }
        }
    });

    VerticalLayout sliderLayout = new VerticalLayout();
    sliderLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    sliderLayout.addComponent(magnifyBtn);
    sliderLayout.addComponent(slider);
    sliderLayout.addComponent(demagnifyBtn);

    m_szlOutBtn = new Button();
    m_szlOutBtn.setHtmlContentAllowed(true);
    m_szlOutBtn.setCaption(FontAwesomeIcons.Icon.arrow_down.variant());
    m_szlOutBtn.setDescription("Collapse Semantic Zoom Level");
    m_szlOutBtn.setEnabled(m_graphContainer.getSemanticZoomLevel() > 0);
    m_szlOutBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            int szl = m_graphContainer.getSemanticZoomLevel();
            if (szl > 0) {
                szl--;
                setSemanticZoomLevel(szl);
                saveHistory();
            }
        }
    });

    final Button szlInBtn = new Button();
    szlInBtn.setHtmlContentAllowed(true);
    szlInBtn.setCaption(FontAwesomeIcons.Icon.arrow_up.variant());
    szlInBtn.setDescription("Expand Semantic Zoom Level");
    szlInBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            int szl = m_graphContainer.getSemanticZoomLevel();
            szl++;
            setSemanticZoomLevel(szl);
            saveHistory();
        }
    });

    m_panBtn = new Button();
    m_panBtn.setIcon(FontAwesome.ARROWS);
    m_panBtn.setDescription("Pan Tool");
    m_panBtn.setStyleName("toolbar-button down");

    m_selectBtn = new Button();
    m_selectBtn.setIcon(new ThemeResource("images/selection.png"));
    m_selectBtn.setDescription("Selection Tool");
    m_selectBtn.setStyleName("toolbar-button");
    m_selectBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            m_selectBtn.setStyleName("toolbar-button down");
            m_panBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("select");
        }
    });

    m_panBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            m_panBtn.setStyleName("toolbar-button down");
            m_selectBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("pan");
        }
    });

    final Button historyBackBtn = new Button(FontAwesomeIcons.Icon.arrow_left.variant());
    historyBackBtn.setHtmlContentAllowed(true);
    historyBackBtn.setDescription("Click to go back");
    historyBackBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("window.history.back()");
        }
    });

    final Button historyForwardBtn = new Button(FontAwesomeIcons.Icon.arrow_right.variant());
    historyForwardBtn.setHtmlContentAllowed(true);
    historyForwardBtn.setDescription("Click to go forward");
    historyForwardBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("window.history.forward()");
        }
    });

    m_searchBox = new SearchBox(m_serviceManager, new CommandManager.DefaultOperationContext(this,
            m_graphContainer, OperationContext.DisplayLocation.SEARCH));

    //History Button Layout
    HorizontalLayout historyButtonLayout = new HorizontalLayout();
    historyButtonLayout.setSpacing(true);
    historyButtonLayout.addComponent(historyBackBtn);
    historyButtonLayout.addComponent(historyForwardBtn);

    //Semantic Controls Layout
    HorizontalLayout semanticLayout = new HorizontalLayout();
    semanticLayout.setSpacing(true);
    semanticLayout.addComponent(szlInBtn);
    semanticLayout.addComponent(m_zoomLevelLabel);
    semanticLayout.addComponent(m_szlOutBtn);
    semanticLayout.setComponentAlignment(m_zoomLevelLabel, Alignment.MIDDLE_CENTER);

    VerticalLayout historyCtrlLayout = new VerticalLayout();
    historyCtrlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    historyCtrlLayout.addComponent(historyButtonLayout);

    HorizontalLayout controlLayout = new HorizontalLayout();
    controlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    controlLayout.addComponent(m_panBtn);
    controlLayout.addComponent(m_selectBtn);

    VerticalLayout semanticCtrlLayout = new VerticalLayout();
    semanticCtrlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    semanticCtrlLayout.addComponent(semanticLayout);

    HorizontalLayout locationToolLayout = createLocationToolLayout();

    //Vertical Layout for all tools on right side
    VerticalLayout toollayout = new VerticalLayout();
    toollayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    toollayout.setSpacing(true);

    toollayout.addComponent(historyCtrlLayout);
    toollayout.addComponent(locationToolLayout);
    toollayout.addComponent(showFocusVerticesBtn);
    toollayout.addComponent(sliderLayout);
    toollayout.addComponent(controlLayout);
    toollayout.addComponent(semanticCtrlLayout);

    AbsoluteLayout mapLayout = new AbsoluteLayout();
    mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;");
    mapLayout.addComponent(m_lastUpdatedTimeLabel, "top: 5px; right: 10px;");
    mapLayout.addComponent(toollayout, "top: 25px; right: 10px;");
    mapLayout.setSizeFull();

    m_infoPanel = new InfoPanel(m_searchBox, mapLayout);
    return m_infoPanel;
}

From source file:org.opennms.features.topology.app.internal.TopologyUI.java

License:Open Source License

private HorizontalLayout createLocationToolLayout() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);//from  w  w w  .  jav a 2  s.  c o m
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    Button showAllMapBtn = new Button(FontAwesomeIcons.Icon.globe.variant());
    showAllMapBtn.setHtmlContentAllowed(true);
    showAllMapBtn.setDescription("Show Entire Map");
    showAllMapBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            m_topologyComponent.showAllMap();
        }
    });

    Button centerSelectionBtn = new Button(FontAwesomeIcons.Icon.location_arrow.variant());
    centerSelectionBtn.setHtmlContentAllowed(true);
    centerSelectionBtn.setDescription("Center On Selection");
    centerSelectionBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            m_topologyComponent.centerMapOnSelection();
        }
    });

    layout.addComponent(centerSelectionBtn);
    layout.addComponent(showAllMapBtn);

    return layout;
}

From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceMainLayout.java

License:Open Source License

public BusinessServiceMainLayout(BusinessServiceManager businessServiceManager) {
    m_businessServiceManager = Objects.requireNonNull(businessServiceManager);
    m_table = new BusinessServiceTreeTable(businessServiceManager);

    setSizeFull();/*from  ww  w. j a  v a  2 s.  c om*/

    // Create button
    final Button createButton = UIHelper.createButton("New Business Service", null, FontAwesome.PLUS_SQUARE,
            (Button.ClickListener) event -> {
                final BusinessService businessService = m_businessServiceManager.createBusinessService();
                final BusinessServiceEditWindow window = new BusinessServiceEditWindow(businessService,
                        m_businessServiceManager);
                window.addCloseListener(e -> m_table.refresh());
                getUI().addWindow(window);
            });
    createButton.setId("createButton");

    // Collapse all
    final Button collapseButton = UIHelper.createButton("Collapse All", null, FontAwesome.FOLDER,
            (Button.ClickListener) event -> {
                m_table.getContainerDataSource().getItemIds().forEach(id -> m_table.setCollapsed(id, true));
            });
    collapseButton.setId("collapseButton");

    // Expand all
    final Button expandButton = UIHelper.createButton("Expand All", null, FontAwesome.FOLDER_OPEN,
            (Button.ClickListener) event -> {
                m_table.getContainerDataSource().getItemIds().forEach(id -> m_table.setCollapsed(id, false));
            });
    expandButton.setId("expandButton");

    // Refresh
    final Button refreshButton = UIHelper.createButton("Refresh Table", null, FontAwesome.REFRESH,
            (Button.ClickListener) event -> {
                m_table.refresh();
            });
    refreshButton.setId("refreshButton");

    // Reload daemon
    final Button reloadButton = UIHelper.createButton("Reload Daemon",
            "Reloads the Business Service State Machine", FontAwesome.RETWEET, (Button.ClickListener) event -> {
                m_businessServiceManager.triggerDaemonReload();
            });
    reloadButton.setId("reloadButton");

    // Group the create and collapse buttons on the left
    HorizontalLayout leftButtonGroup = new HorizontalLayout();
    leftButtonGroup.setSpacing(true);
    leftButtonGroup.addComponent(createButton);
    leftButtonGroup.addComponent(collapseButton);
    leftButtonGroup.addComponent(expandButton);
    leftButtonGroup.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    // Group the refresh and reload buttons to the right
    HorizontalLayout rightButtonGroup = new HorizontalLayout();
    rightButtonGroup.setSpacing(true);
    rightButtonGroup.addComponent(refreshButton);
    rightButtonGroup.addComponent(reloadButton);
    rightButtonGroup.setDefaultComponentAlignment(Alignment.TOP_RIGHT);

    // Build the upper layout
    HorizontalLayout upperLayout = new HorizontalLayout();
    upperLayout.setSpacing(true);
    upperLayout.addComponent(leftButtonGroup);
    upperLayout.addComponent(rightButtonGroup);
    upperLayout.setComponentAlignment(leftButtonGroup, Alignment.TOP_LEFT);
    upperLayout.setComponentAlignment(rightButtonGroup, Alignment.TOP_RIGHT);
    upperLayout.setWidth(100, Unit.PERCENTAGE);
    addComponent(upperLayout);

    // Add some space between the upper layout and the table
    Label sz = new Label("");
    sz.setWidth(null);
    sz.setHeight(5, Unit.PIXELS);
    addComponent(sz);

    /**
     * add the table to the layout
     */
    addComponent(m_table);
    setExpandRatio(m_table, 1.0f);

    /**
     * initial refresh of table
     */
    m_table.refresh();
}

From source file:org.vaadin.spring.samples.mvp.ui.view.HeaderView.java

License:Apache License

protected HorizontalLayout buildControlsArea(ControlsContext context) {
    HorizontalLayout left = new HorizontalLayout();
    left.setSpacing(true);/* w ww.  jav a2  s .c o  m*/
    left.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    // ---- DYNAMIC HEADER ELEMENTS ----
    // Rendering depends on what tab was selected
    List<Component> controls = context.getControls();
    LayoutIntegrator.addComponents(left, controls.toArray(new Component[controls.size()]));

    return left;
}