Example usage for com.vaadin.ui CssLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

License:Open Source License

@Override
public void render() {
    select = new ListSelect();
    refreshSelect();/*from   w ww. jav  a2  s.c  om*/

    CssLayout layout = new CssLayout();
    layout.setWidth("100%");

    layout.addComponent(new Label(editor.getLabel()));

    HorizontalLayout row = new HorizontalLayout();
    row.setWidth("100%");
    layout.addComponent(row);

    row.addComponent(select);
    select.setWidth("100%");

    buttonPanel = new CssLayout();
    buttonPanel.setSizeFull();
    row.addComponent(buttonPanel);

    row.setExpandRatio(select, 8);
    row.setExpandRatio(buttonPanel, 2);

    createButtons();
    component = layout;
}

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 {/* w  w w . ja v  a2s.c  o  m*/
        slider.setValue(getValue().doubleValue());
    } catch (ValueOutOfBoundsException vo) {

    }

    slider.setOrientation(SliderOrientation.HORIZONTAL);
    layout.addComponent(slider);
    this.component = 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 ww  w.  j a  va 2s  .  c  o  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.semanticsoft.vaaclipse.presentation.renderers.PartRenderer.java

License:Open Source License

@Override
public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) {
    VerticalLayout pane = new VerticalLayout();
    pane.setSizeFull();/*ww w . j av  a 2  s  .  c o m*/
    final MPart part = (MPart) element;

    CssLayout toolbarArea = new CssLayout();
    toolbarArea.setStyleName("mparttoolbararea");
    toolbarArea.setSizeUndefined();
    toolbarArea.setWidth("100%");
    pane.addComponent(toolbarArea);

    //create toolbar
    MToolBar toolbar = part.getToolbar();
    if (toolbar != null && toolbar.isToBeRendered()) {
        Component toolbarWidget = (Component) renderingEngine.createGui(toolbar);
        ((AbstractLayout) toolbarWidget).setSizeUndefined();
        toolbarWidget.setStyleName("mparttoolbar");
        toolbarArea.addComponent(toolbarWidget);
    }

    VerticalLayout contributionArea = new VerticalLayout();
    contributionArea.setSizeFull();
    pane.addComponent(contributionArea);
    pane.setExpandRatio(contributionArea, 100);

    pane.setStyleName("part");
    element.setWidget(pane);

    IEclipseContext localContext = part.getContext();
    localContext.set(Component.class, contributionArea);
    localContext.set(ComponentContainer.class, contributionArea);
    localContext.set(VerticalLayout.class, contributionArea);
    localContext.set(MPart.class, part);
    SavePromptSetup savePromptProvider = new SavePromptSetup();
    savePrompts.put(part, savePromptProvider);
    localContext.set(SavePromptSetup.class, savePromptProvider);
    if (part instanceof MInputPart)
        localContext.set(MInputPart.class, (MInputPart) part);

    IContributionFactory contributionFactory = (IContributionFactory) localContext
            .get(IContributionFactory.class.getName());
    Object newPart = contributionFactory.create(part.getContributionURI(), localContext);

    part.setObject(newPart);
}

From source file:org.vaadin.alump.fancylayouts.demo.PanelDemo.java

License:Apache License

/**
 * Sample content with simple table (disabled as table is so broken in
 * Vaadin 7). To get table work you probably need some special timer.
 * //from w  ww.  j  ava 2  s. c  o m
 * @return
 */
// private ComponentContainer createPanelContentC() {
// VerticalLayout layout = new VerticalLayout();
// layout.setWidth("100%");
// layout.setMargin(true);
// layout.setSpacing(true);
//
// Label label = new Label ("Table is quite broken in Vaadin 7?");
// layout.addComponent(label);
//
// Table table = new Table();
// table.setWidth("400px");
// table.setHeight("500px");
// table.addContainerProperty("Name", String.class, "");
// table.addContainerProperty("Phone Number", String.class, "");
// table.addItem(new Object[] { "Matti Meiklinen", "555 234 2344" },
// "Matti");
// table.addItem(new Object[] { "Donald Duck", "555 332 7782" }, "Donald");
//
// layout.addComponent(table);
//
// return layout;
// }

private ComponentContainer createPanelContentD() {
    CssLayout layout = new CssLayout();
    layout.addStyleName("demo-panel-d");
    layout.setWidth("100%");
    layout.setHeight("100%");

    Image image = new Image();
    image.setSource(new ThemeResource("images/meme.jpg"));
    image.addStyleName("demo-meme");
    layout.addComponent(image);

    return layout;
}

From source file:org.vaadin.notifique.Notifique.java

License:Apache License

/**
 * Create a new item into the queue. It is not visible until added with
 *///from   w  w w.j  a  va  2  s. c  o m
protected Message createMessage(final Component component, String style) {

    final Message m = new Message();

    // Wrap to a CssLayout (this is needed for styling and sizing correctly)
    CssLayout css = new CssLayout();
    css.setWidth("100%");
    css.setStyleName(Notifique.STYLE_ITEM);
    css.addStyleName(style != null ? style : Styles.MESSAGE);
    css.addComponent(component);

    // Wrap component into an animator
    m.component = component;
    m.animatedContent = css;

    return m;
}

From source file:org.vaadin.spring.sidebar.components.ValoSideBar.java

License:Apache License

@Override
protected CssLayout createCompositionRoot() {
    CssLayout layout = new CssLayout();
    layout.addStyleName(ValoTheme.MENU_PART);
    if (largeIcons) {
        layout.addStyleName(ValoTheme.MENU_PART_LARGE_ICONS);
    }/* w  w  w .jav  a2 s. c o  m*/
    layout.setWidth(null);
    layout.setHeight("100%");
    if (logo != null) {
        layout.addComponent(logo);
    }
    if (headerLayout != null) {
        layout.addComponent(headerLayout);
    }
    return layout;
}

From source file:org.vaadin.tori.component.DebugControlPanel.java

License:Apache License

private Component createPostControl(final Method setter, final List<Post> posts) throws Exception {
    if (posts == null || posts.isEmpty()) {
        final Label label = new Label(getNameForCheckBox(setter));
        label.setEnabled(false);//from   www . j  a  v a  2 s .co  m
        return label;
    }

    Component content = new CustomComponent() {
        {
            final CssLayout root = new CssLayout();
            root.addStyleName("postselect-content");
            root.addStyleName(setter.getName());
            setCompositionRoot(root);
            root.setWidth("100%");
            setWidth("400px");

            root.addComponent(new Label(setter.getName()));

            for (final Post post : posts) {
                final Method getter = getGetterFrom(setter);
                final boolean getterValue = (Boolean) getter.invoke(authorizationService, post.getId());

                final String authorName = post.getAuthor().getDisplayedName();

                String postBody = post.getBodyRaw();
                if (postBody.length() > 20) {
                    postBody = postBody.substring(0, 20);
                }

                final CheckBox checkbox = new CheckBox(authorName + " :: " + postBody);
                checkbox.setValue(getterValue);
                checkbox.addValueChangeListener(new PostCheckboxListener(post, setter));
                checkbox.setImmediate(true);
                checkbox.setWidth("100%");
                root.addComponent(checkbox);
            }
        }
    };
    final PopupView popup = new PopupView(getNameForCheckBox(setter), content);
    popup.setHideOnMouseOut(false);
    popup.setHeight(30.0f, Unit.PIXELS);
    return popup;
}

From source file:ro.zg.open_groups.gui.components.CausalHierarchyContainer.java

License:Apache License

private void init() {
    /* start depth combo */
    CssLayout startDepthContainer = new CssLayout();
    startDepthContainer.setWidth("100%");
    startDepthContainer.setHeight("22px");
    startDepthContainer.addStyleName(OpenGroupsStyles.HIERARCHY_FILTERS_BAR);

    Label startDepthLabel = new Label(OpenGroupsResources.getMessage("hierarchy.start.depth"));
    startDepthLabel.setSizeUndefined();/*from   w ww  .jav  a2 s. co m*/
    startDepthLabel.addStyleName(OpenGroupsStyles.HORIZONTAL);

    startDepthSelect = new ComboBox();
    startDepthSelect.setInvalidAllowed(false);
    startDepthSelect.setNullSelectionAllowed(false);
    startDepthSelect.setNewItemsAllowed(false);
    startDepthSelect.addStyleName(OpenGroupsStyles.HORIZONTAL);
    startDepthSelect.setWidth("55px");
    startDepthSelect.setImmediate(true);

    startDepthContainer.addComponent(startDepthLabel);
    startDepthContainer.addComponent(startDepthSelect);

    // CssLayout hierarchyTitleBar = new CssLayout();
    // hierarchyTitleBar.setWidth("100%");
    // hierarchyTitleBar.addStyleName(OpenGroupsStyles.HIERARCHY_TITLE_BAR);
    // Label title = new Label("Ierarhie cauzal");
    // title.addStyleName(OpenGroupsStyles.TITLE_LINK);
    // hierarchyTitleBar.addComponent(title);

    // addComponent(hierarchyTitleBar);
    addComponent(startDepthContainer);

    /* the tree */
    hierarchyTree = new Tree();
    hierarchyTree.addStyleName(OpenGroupsStyles.HIERARCHY_TREE);
    hierarchyTree.setMultiSelect(false);
    hierarchyTree.setImmediate(true);
    hierarchyTree.setNullSelectionAllowed(true);
    hierarchyTree.setSizeUndefined();
    hierarchyTree.setContainerDataSource(new HierarchicalContainer());
    hierarchyTree.addContainerProperty("depth", Integer.class, null);
    hierarchyTree.addListener(new CollapseListener() {

        @Override
        public void nodeCollapse(CollapseEvent event) {
            Object itemId = event.getItemId();
            /* remove the subhierarchy */
            removeSubhierarchy(itemId);
        }
    });

    CssLayout treeContainer = new CssLayout();
    treeContainer.addStyleName("hierarchy-tree-container");
    treeContainer.setWidth("100%");
    treeContainer.setHeight("93%");
    treeContainer.addComponent(hierarchyTree);
    addComponent(treeContainer);
    // setExpandRatio(hierarchyTree, 1);
}