Example usage for com.vaadin.ui CssLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:org.lunifera.vaaclipse.ui.preferences.addon.internal.ScaleFieldEditorRenderer.java

License:Open Source License

@Override
public void render() {
    CssLayout layout = new CssLayout();
    layout.setWidth("100%");
    layout.addComponent(new Label(editor.getLabel()));
    slider = new Slider();
    slider.setWidth("100%");
    if (editor.getMaxValue() != null)
        slider.setMax(editor.getMaxValue().doubleValue());
    if (editor.getMinValue() != null)
        slider.setMin(editor.getMinValue().doubleValue());

    try {//from  w ww  .j a v a2 s  .  c  om
        slider.setValue(getValue().doubleValue());
    } catch (ValueOutOfBoundsException vo) {

    }

    slider.setOrientation(SliderOrientation.HORIZONTAL);
    layout.addComponent(slider);
    this.component = layout;
}

From source file:org.lunifera.vaaclipse.ui.preferences.addon.internal.StringFieldEditorRenderer.java

License:Open Source License

@Override
public void render() {

    field = new TextField();
    field.setValue(getValue());// ww  w  .j a  va 2  s . c  o m
    // field.setCaption(editor.getLabel());

    CssLayout layout = new CssLayout();
    Label label = new Label(editor.getLabel());
    layout.addComponent(label);
    layout.addComponent(field);

    component = layout;
}

From source file:org.opencms.ui.apps.CmsFileExplorer.java

License:Open Source License

/**
 * @see org.opencms.ui.apps.I_CmsWorkplaceApp#initUI(org.opencms.ui.apps.I_CmsAppUIContext)
 *///from w ww .  j  a  v a 2 s . c o m
public void initUI(I_CmsAppUIContext context) {

    m_appContext = context;
    m_appContext.setMenuDialogContext(
            new CmsExplorerDialogContext(ContextType.appToolbar, m_fileTable, this, null));
    HorizontalSplitPanel sp = new HorizontalSplitPanel();
    sp.setSizeFull();
    sp.setFirstComponent(m_fileTree);
    CmsFileExplorerSettings settings;
    try {
        settings = OpenCms.getWorkplaceAppManager().getAppSettings(A_CmsUI.getCmsObject(),
                CmsFileExplorerSettings.class);

        m_fileTable.setTableState(settings);
    } catch (Exception e) {
        LOG.error("Error while reading file explorer settings from user.", e);
    }
    sp.setSecondComponent(m_fileTable);

    sp.setSplitPosition(LAYOUT_SPLIT_POSITION, Unit.PIXELS);

    context.setAppContent(sp);
    context.showInfoArea(true);
    HorizontalLayout inf = new HorizontalLayout();
    inf.setSizeFull();
    inf.setSpacing(true);
    inf.setMargin(true);
    m_siteSelector.setWidth("379px");
    inf.addComponent(m_siteSelector);
    CssLayout crumbWrapper = new CssLayout();
    crumbWrapper.setSizeFull();
    crumbWrapper.setPrimaryStyleName(OpenCmsTheme.CRUMB_WRAPPER);
    crumbWrapper.addComponent(m_crumbs);

    m_infoPath.setWidth("100%");
    crumbWrapper.addComponent(m_infoPath);
    inf.addComponent(crumbWrapper);
    inf.setExpandRatio(crumbWrapper, 1);

    m_searchField.setWidth("200px");
    inf.addComponent(m_searchField);
    context.setAppInfo(inf);

    initToolbarButtons(context);
    m_fileTable.updateColumnWidths(A_CmsUI.get().getPage().getBrowserWindowWidth() - LAYOUT_SPLIT_POSITION);
}

From source file:org.opencms.ui.components.CmsUserInfo.java

License:Open Source License

/**
 * Creates the user image button.<p>
 *
 * @return the created button/*w  w  w  .j a va2s .c  o m*/
 */
private Component createImageButton() {

    CssLayout layout = new CssLayout();
    layout.addStyleName(OpenCmsTheme.USER_IMAGE);
    Image userImage = new Image();
    userImage.setSource(new ExternalResource(OpenCms.getWorkplaceAppManager().getUserIconHelper()
            .getBigIconPath(A_CmsUI.getCmsObject(), m_user)));

    layout.addComponent(userImage);

    if (!CmsAppWorkplaceUi.isOnlineProject()) {
        CmsUploadButton uploadButton = createImageUploadButton(null, FontOpenCms.UPLOAD_SMALL, m_user,
                m_uploadListener);
        layout.addComponent(uploadButton);
        if (CmsUserIconHelper.hasUserImage(m_user)) {
            Button deleteButton = new Button(FontOpenCms.TRASH_SMALL);
            deleteButton.addClickListener(new ClickListener() {

                private static final long serialVersionUID = 1L;

                public void buttonClick(ClickEvent event) {

                    OpenCms.getWorkplaceAppManager().getUserIconHelper()
                            .deleteUserImage(A_CmsUI.getCmsObject());
                    m_context.updateUserInfo();

                }
            });
            layout.addComponent(deleteButton);
        }
    }

    return layout;
}

From source file:org.opencms.ui.sitemap.CmsLocaleComparePanel.java

License:Open Source License

/**
 * Initializes the locale comparison view.<p>
 *
 * @param id the structure id of the currrent sitemap root entry
 * @param initialComparisonLocale if not null, the initially selected ccomparison locale
 *
 * @throws CmsException if something goes wrong
 *///from   www.  j  a  v a  2 s  .co  m
public void initialize(CmsUUID id, Locale initialComparisonLocale) throws CmsException {

    removeAllComponents();
    CmsObject cms = A_CmsUI.getCmsObject();
    CmsResource res = cms.readResource(id);
    m_currentRoot = res;
    CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(res.getRootPath());

    Locale rootLocale = OpenCms.getLocaleManager().getDefaultLocale(cms, res);
    m_rootLocale = rootLocale;
    Locale mainLocale = site.getMainTranslationLocale(null);
    List<Locale> secondaryLocales = site.getSecondaryTranslationLocales();

    List<Locale> possibleLocaleSelections = getMainLocaleSelectOptions(cms, res, mainLocale, secondaryLocales);
    m_rootLocaleSelector = new ComboBox();
    m_rootLocaleSelector.addStyleName("o-sitemap-localeselect");
    m_rootLocaleSelector.setNullSelectionAllowed(false);
    for (Locale selectableLocale : possibleLocaleSelections) {
        m_rootLocaleSelector.addItem(selectableLocale);
        m_rootLocaleSelector.setItemIcon(selectableLocale, FontOpenCms.SPACE);
        m_rootLocaleSelector.setItemCaption(selectableLocale,
                selectableLocale.getDisplayName(A_CmsUI.get().getLocale()));
    }
    m_rootLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON);
    m_rootLocaleSelector.setValue(m_rootLocale);
    m_rootLocaleSelector.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void valueChange(ValueChangeEvent event) {

            if (!m_handlingLocaleChange) {
                m_handlingLocaleChange = true;
                try {
                    Locale newLocale = (Locale) (event.getProperty().getValue());
                    switchToLocale(newLocale);
                } catch (Exception e) {
                    LOG.error(e.getLocalizedMessage(), e);
                    CmsErrorDialog.showErrorDialog(e);
                } finally {
                    m_handlingLocaleChange = false;
                }
            }
        }
    });

    m_comparisonLocaleSelector = new ComboBox();
    m_comparisonLocaleSelector.addStyleName("o-sitemap-localeselect");
    m_comparisonLocaleSelector.setNullSelectionAllowed(false);

    List<Locale> comparisonLocales = getComparisonLocales();
    Locale selectedComparisonLocale = null;
    for (Locale comparisonLocale : comparisonLocales) {
        m_comparisonLocaleSelector.addItem(comparisonLocale);
        m_comparisonLocaleSelector.setItemIcon(comparisonLocale, FontOpenCms.SPACE);
        m_comparisonLocaleSelector.setItemCaption(comparisonLocale,
                comparisonLocale.getDisplayName(A_CmsUI.get().getLocale()));
        if ((selectedComparisonLocale == null) && !comparisonLocale.equals(m_rootLocale)) {
            selectedComparisonLocale = comparisonLocale;
        }
        if ((initialComparisonLocale != null) && comparisonLocale.equals(initialComparisonLocale)
                && !comparisonLocale.equals(m_rootLocale)) {
            // if an initial comparison locale is given, it should have priority over the first comparison locale
            selectedComparisonLocale = comparisonLocale;
        }

    }
    m_comparisonLocale = selectedComparisonLocale;
    m_comparisonLocaleSelector.setValue(selectedComparisonLocale);
    m_comparisonLocaleSelector.setItemIcon(mainLocale, MAIN_LOCALE_ICON);

    m_comparisonLocaleSelector.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void valueChange(ValueChangeEvent event) {

            if (!m_handlingLocaleChange) {
                m_handlingLocaleChange = true;
                try {
                    Locale locale = (Locale) (event.getProperty().getValue());
                    if (m_rootLocale.equals(locale)) {
                        Locale oldComparisonLocale = m_comparisonLocale;
                        if (getLocaleGroup().getResourcesByLocale().keySet().contains(oldComparisonLocale)) {
                            m_comparisonLocale = locale;
                            switchToLocale(oldComparisonLocale);
                            updateLocaleWidgets();
                        } else {
                            Notification.show(CmsVaadinUtils.getMessageText(
                                    Messages.GUI_LOCALECOMPARE_CANNOT_SWITCH_COMPARISON_LOCALE_0));
                            m_comparisonLocaleSelector.setValue(oldComparisonLocale);
                        }
                    } else {
                        m_comparisonLocale = locale;
                        updateLocaleWidgets();
                        initTree(m_currentRoot);
                    }

                } catch (Exception e) {
                    LOG.error(e.getLocalizedMessage(), e);
                    CmsErrorDialog.showErrorDialog(e);
                } finally {
                    m_handlingLocaleChange = false;
                }
            }
        }
    });

    CssLayout localeSelectors = new CssLayout();
    localeSelectors.addStyleName(OpenCmsTheme.SITEMAP_LOCALE_BAR);

    m_rootLocaleSelector.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_MAIN_LOCALE_0));
    m_comparisonLocaleSelector
            .setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_COMPARISON_LOCALE_0));

    localeSelectors.setWidth("100%");
    localeSelectors.addComponent(m_rootLocaleSelector);
    localeSelectors.addComponent(m_comparisonLocaleSelector);
    // localeSelectors.setComponentAlignment(wrapper2, Alignment.MIDDLE_RIGHT);

    setSpacing(true);
    addComponent(localeSelectors);
    addComponent(m_treeContainer);
    m_treeContainer.setWidth("100%");
    initTree(res);
}

From source file:org.opencms.ui.sitemap.CmsSitemapTreeController.java

License:Open Source License

/**
 * Creates a sitemap tree node widget from a tree node bean.<p>
 *
 * @param entry the tree node bean/*from  w w  w  . ja v  a 2s .  co m*/
 * @return the tree node widget
 */
public CmsSitemapTreeNode createNode(final CmsSitemapTreeNodeData entry) {

    final CmsSitemapTreeNode node = new CmsSitemapTreeNode();

    node.addLayoutClickListener(new LayoutClickListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void layoutClick(LayoutClickEvent event) {

            Component currentComponent = event.getClickedComponent();
            if (currentComponent != null) {
                boolean linked = false;
                do {
                    currentComponent = currentComponent.getParent();
                    if ((currentComponent != null)
                            && "linked".equals(((AbstractComponent) currentComponent).getData())) {
                        linked = true;
                    }
                    if (event.getClickedComponent() instanceof CmsResourceIcon) {
                        if (currentComponent == node) {
                            openTargetPage((CmsSitemapTreeNodeData) (node.getData()), linked);
                        } else if (currentComponent instanceof CmsSitemapTreeNode) {
                            break;
                        }
                    }
                } while (currentComponent != null);
            }

        }

    });
    String icon = CmsResourceIcon.getSitemapResourceIcon(A_CmsUI.getCmsObject(), entry.getResource(),
            IconMode.localeCompare);
    CmsResourceInfo info = new CmsResourceInfo(entry.getClientEntry().getTitle(),
            entry.getClientEntry().getSitePath(), icon);
    info = CmsResourceInfo.createSitemapResourceInfo(entry.getResource(),
            OpenCms.getSiteManager().getSiteForRootPath(m_localeContext.getRoot().getRootPath()));
    info.getResourceIcon().addStyleName(OpenCmsTheme.POINTER);
    info.getResourceIcon()
            .setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_OPEN_PAGE_0));

    if (entry.getClientEntry().isHiddenNavigationEntry()) {
        info.addStyleName(OpenCmsTheme.RESOURCE_INFO_WEAK);
    }
    final MenuBar menu = new MenuBar();
    boolean noTranslation = false;
    noTranslation = entry.isMarkedNoTranslation(m_localeContext.getComparisonLocale());

    final MenuItem main = menu.addItem("", null);
    main.setIcon(FontOpenCms.CONTEXT_MENU);
    CssLayout rightSide = new CssLayout();
    info.setButtonWidget(rightSide);
    rightSide.addComponent(menu);
    main.setCommand(new Command() {

        /** Serial version id. */
        private static final long serialVersionUID = 1L;

        public void menuSelected(MenuItem selectedItem) {

            List<I_CmsSimpleContextMenuEntry<MenuContext>> entries = Arrays.asList(

                    new EntryOpen(), new EntryExplorer(), new EntryProperties(), new EntryLink(),
                    new EntryUnlink(), new EntryMark(), new EntryRemoveMark(), new EntryCopy(),
                    new EntryInfo());

            MenuContext context = new MenuContext(entry, node);
            m_menu.setEntries(entries, context);
            m_menu.open(menu);

        }

    });

    menu.addStyleName("borderless o-toolbar-button o-resourceinfo-toolbar");
    if (entry.isLinked()) {
        CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(m_localeContext.getRoot().getRootPath());
        CmsResourceInfo linkedInfo = CmsResourceInfo
                .createSitemapResourceInfo(readSitemapEntryFolderIfPossible(entry.getLinkedResource()), site);
        linkedInfo.addStyleName(OpenCmsTheme.RESOURCE_INFO_DIRECTLINK);
        rightSide.addComponent(linkedInfo, 0);
        linkedInfo.setWidth(RHS_WIDTH + "px");
        node.setContent(info);
        linkedInfo.setData("linked"); // Data used by click handler to distinguish clicked resource icons
        linkedInfo.getResourceIcon()
                .setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_OPEN_PAGE_0));
        linkedInfo.getResourceIcon().addStyleName(OpenCmsTheme.POINTER);
    } else {
        if (noTranslation) {
            CmsResourceInfo noTranslationInfo = new CmsResourceInfo();
            String topMessage = CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_NO_TRANSLATION_TOP_0);
            String bottomMessage = CmsVaadinUtils
                    .getMessageText(Messages.GUI_LOCALECOMPARE_NO_TRANSLATION_BOTTOM_0);
            noTranslationInfo.getTopLine().setValue(topMessage);
            noTranslationInfo.getBottomLine().setValue(bottomMessage);
            noTranslationInfo.getResourceIcon().setValue("<span class=\"" + OpenCmsTheme.RESOURCE_ICON + " "
                    + OpenCmsTheme.NO_TRANSLATION_ICON + "\">" + FontAwesome.BAN.getHtml() + "</span>");
            noTranslationInfo.addStyleName(OpenCmsTheme.RESOURCE_INFO_DIRECTLINK);
            noTranslationInfo.setWidth(RHS_WIDTH + "px");
            rightSide.addComponent(noTranslationInfo, 0);
        }
        node.setContent(info);
    }

    if (entry.hasNoChildren()) {
        node.setOpen(true);
        node.setOpenerVisible(false);
    }
    node.setData(entry);
    return node;

}

From source file:org.openeos.vaadin.main.internal.MainApplication.java

License:Apache License

@Override
public void init() {
    // TODO Make better implementation, not literal
    if (notificationManager == null) {
        throw new IllegalStateException();
    }/*from w w w.j  a v  a2  s . co  m*/
    if (applicationLifecycleManager == null) {
        throw new IllegalStateException();
    }
    logger.info("Initializing Main Application");

    // setTheme(Reindeer.THEME_NAME);
    // setTheme(Runo.THEME_NAME);
    // setTheme("demo");
    setTheme("uno");

    main = new Window("Dynamic Vaadin OSGi Demo");
    mainLayout = (VerticalLayout) main.getContent();
    mainLayout.setMargin(false);
    //mainLayout.setStyleName(Reindeer.L "blue");
    setMainWindow(main);

    mainLayout.setSizeFull();
    mainLayout.addComponent(getMenu());

    mainLayout.addComponent(getHeader());

    CssLayout margin = new CssLayout();
    margin.setMargin(false, true, true, true);
    margin.setSizeFull();
    tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    tabSheet.setCloseHandler(closeHandler);
    margin.addComponent(tabSheet);
    mainLayout.addComponent(margin);
    mainLayout.setExpandRatio(margin, 1);

    for (IVaadinMenuContributor contributor : menuContributorsList) {
        contributor.contribute(menubar, this);
    }

    if (getContext() != null) {
        getContext().addTransactionListener(this);
    }

    initialized = true;

    applicationLifecycleManager.init(this);
}

From source file:org.openeos.vaadin.main.internal.MainApplication.java

License:Apache License

private Layout getHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setMargin(true);/*from  w w w .j a va2  s.co  m*/
    header.setSpacing(true);
    // header.setStyleName(Reindeer.LAYOUT_BLACK);

    CssLayout titleLayout = new CssLayout();
    H2 title = new H2("Dynamic Vaadin OSGi Demo");
    titleLayout.addComponent(title);
    SmallText description = new SmallText(
            "Select the \"Bundle View\" tab and activate/stop OSGi bundles dynamically.");
    description.setSizeUndefined();
    titleLayout.addComponent(description);

    header.addComponent(titleLayout);
    Component notificationArea = notificationManager.getComponent(this);
    header.addComponent(notificationArea);
    header.setComponentAlignment(notificationArea, Alignment.MIDDLE_RIGHT);

    return header;
}

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

License:Open Source License

public ToolbarPanel(final ToolbarPanelController controller) {
    addStyleName(Styles.TOOLBAR);//from  w ww.j av a  2s .  co  m
    this.layoutManager = controller.getLayoutManager();

    final Property<Double> scale = controller.getScaleProperty();
    final Boolean[] eyeClosed = new Boolean[] { false };
    final Button showFocusVerticesBtn = new Button();
    showFocusVerticesBtn.setIcon(FontAwesome.EYE);
    showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes");
    showFocusVerticesBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (eyeClosed[0]) {
                showFocusVerticesBtn.setIcon(FontAwesome.EYE);
            } else {
                showFocusVerticesBtn.setIcon(FontAwesome.EYE_SLASH);
            }
            eyeClosed[0] = !eyeClosed[0]; // toggle
            controller.toggleHighlightFocus();
        }
    });

    final Button magnifyBtn = new Button();
    magnifyBtn.setIcon(FontAwesome.PLUS);
    magnifyBtn.setDescription("Magnify");
    magnifyBtn.addClickListener(
            (Button.ClickListener) event -> scale.setValue(Math.min(1, scale.getValue() + 0.25)));

    final Button demagnifyBtn = new Button();
    demagnifyBtn.setIcon(FontAwesome.MINUS);
    demagnifyBtn.setDescription("Demagnify");
    demagnifyBtn.addClickListener(
            (Button.ClickListener) event -> scale.setValue(Math.max(0, scale.getValue() - 0.25)));

    m_szlOutBtn = new Button();
    m_szlOutBtn.setId("szlOutBtn");
    m_szlOutBtn.setIcon(FontAwesome.ANGLE_DOWN);
    m_szlOutBtn.setDescription("Decrease Semantic Zoom Level");
    m_szlOutBtn.setEnabled(controller.getSemanticZoomLevel() > 0);
    m_szlOutBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            int szl = controller.getSemanticZoomLevel();
            if (szl > 0) {
                setSemanticZoomLevel(controller, szl - 1);
                controller.saveHistory();
            }
        }
    });

    final Button szlInBtn = new Button();
    szlInBtn.setId("szlInBtn");
    szlInBtn.setIcon(FontAwesome.ANGLE_UP);
    szlInBtn.setDescription("Increase Semantic Zoom Level");
    szlInBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setSemanticZoomLevel(controller, controller.getSemanticZoomLevel() + 1);
            controller.saveHistory();
        }
    });

    m_zoomLevelLabel.setId("szlInputLabel");

    m_panBtn = new Button();
    m_panBtn.setIcon(FontAwesome.ARROWS);
    m_panBtn.setDescription("Pan Tool");
    m_panBtn.addStyleName(Styles.SELECTED);

    m_selectBtn = new Button();
    m_selectBtn.setIcon(IonicIcons.ANDROID_EXPAND);
    m_selectBtn.setDescription("Selection Tool");
    m_selectBtn.setStyleName("toolbar-button");
    m_selectBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            m_selectBtn.addStyleName(Styles.SELECTED);
            m_panBtn.removeStyleName(Styles.SELECTED);
            controller.setActiveTool(ActiveTool.select);
        }
    });

    m_panBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            m_panBtn.addStyleName(Styles.SELECTED);
            m_selectBtn.removeStyleName(Styles.SELECTED);
            controller.setActiveTool(ActiveTool.pan);
        }
    });

    Button showAllMapBtn = new Button();
    showAllMapBtn.setId("showEntireMapBtn");
    showAllMapBtn.setIcon(FontAwesome.GLOBE);
    showAllMapBtn.setDescription("Show Entire Map");
    showAllMapBtn.addClickListener((Button.ClickListener) event -> controller.showAllMap());

    Button centerSelectionBtn = new Button();
    centerSelectionBtn.setIcon(FontAwesome.LOCATION_ARROW);
    centerSelectionBtn.setDescription("Center On Selection");
    centerSelectionBtn.addClickListener((Button.ClickListener) event -> controller.centerMapOnSelection());

    Button shareButton = new Button("", FontAwesome.SHARE_SQUARE_O);
    shareButton.setDescription("Share");
    shareButton.addClickListener((x) -> {
        // Create the share link
        String fragment = getUI().getPage().getLocation().getFragment();
        String url = getUI().getPage().getLocation().toString().replace("#" + fragment, "");
        String shareLink = String.format("%s?%s=%s", url, PARAMETER_HISTORY_FRAGMENT, fragment);

        // Create the Window
        Window shareWindow = new Window();
        shareWindow.setCaption("Share Link");
        shareWindow.setModal(true);
        shareWindow.setClosable(true);
        shareWindow.setResizable(false);
        shareWindow.setWidth(400, Sizeable.Unit.PIXELS);

        TextArea shareLinkField = new TextArea();
        shareLinkField.setValue(shareLink);
        shareLinkField.setReadOnly(true);
        shareLinkField.setRows(3);
        shareLinkField.setWidth(100, Sizeable.Unit.PERCENTAGE);

        // Close Button
        Button close = new Button("Close");
        close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
        close.addClickListener(event -> shareWindow.close());

        // Layout for Buttons
        HorizontalLayout buttonLayout = new HorizontalLayout();
        buttonLayout.setMargin(true);
        buttonLayout.setSpacing(true);
        buttonLayout.setWidth("100%");
        buttonLayout.addComponent(close);
        buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);

        // Content Layout
        VerticalLayout verticalLayout = new VerticalLayout();
        verticalLayout.setMargin(true);
        verticalLayout.setSpacing(true);
        verticalLayout.addComponent(
                new Label("Please use the following link to share the current view with others."));
        verticalLayout.addComponent(shareLinkField);
        verticalLayout.addComponent(buttonLayout);

        shareWindow.setContent(verticalLayout);

        getUI().addWindow(shareWindow);
    });

    // Refresh Button
    Button refreshButton = new Button();
    refreshButton.setId("refreshNow");
    refreshButton.setIcon(FontAwesome.REFRESH);
    refreshButton.setDescription("Refresh Now");
    refreshButton.addClickListener((event) -> controller.refreshUI());

    // Layer Layout
    layerLayout = new VerticalLayout();
    layerLayout.setId("layerComponent");
    layerLayout.setSpacing(true);
    layerLayout.setMargin(true);

    // Layer Button
    layerButton = new Button();
    layerButton.setId("layerToggleButton");
    layerButton.setIcon(FontAwesome.BARS);
    layerButton.setDescription("Layers");
    layerButton.addClickListener((event) -> {
        boolean isCollapsed = layerButton.getStyleName().contains(Styles.EXPANDED);
        setLayerLayoutVisible(!isCollapsed);
    });

    // Save button
    layerSaveButton = new Button();
    layerSaveButton.setId("saveLayerButton");
    layerSaveButton.setIcon(FontAwesome.FLOPPY_O);
    layerSaveButton.addClickListener((event) -> controller.saveLayout());

    // Actual Layout for the Toolbar
    CssLayout contentLayout = new CssLayout();
    contentLayout.addStyleName("toolbar-component");
    contentLayout.addComponent(createGroup(szlInBtn, m_zoomLevelLabel, m_szlOutBtn));
    contentLayout.addComponent(
            createGroup(refreshButton, centerSelectionBtn, showAllMapBtn, layerButton, showFocusVerticesBtn));
    contentLayout.addComponent(createGroup(m_panBtn, m_selectBtn));
    contentLayout.addComponent(createGroup(magnifyBtn, demagnifyBtn));
    contentLayout.addComponent(createGroup(shareButton));
    contentLayout.addComponent(createGroup(layerSaveButton));

    // Toolbar
    addComponent(contentLayout);
}

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

License:Open Source License

private CssLayout createGroup(Component... components) {
    CssLayout group = new CssLayout();
    group.addStyleName("toolbar-component-group");
    group.setSizeFull();/*from  w ww .  j  av  a  2  s . c  o m*/
    for (Component eachComponent : components) {
        eachComponent.setPrimaryStyleName("toolbar-group-item");
        group.addComponent(eachComponent);
    }
    return group;
}