Example usage for com.vaadin.ui HorizontalLayout setSpacing

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

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:com.example.EditingWindow.java

License:Apache License

protected HorizontalLayout makeFooter() {
    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName("v-window-bottom-toolbar");

    Label footerText = new Label("Footer text");
    footerText.setSizeUndefined();// www. j av  a 2  s. co m

    btnOK.addStyleName(ValoTheme.BUTTON_PRIMARY);
    btnOK.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    btnCancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);

    footer.addComponents(footerText, btnOK, btnCancel);
    footer.setExpandRatio(footerText, 1);

    return footer;
}

From source file:com.expressui.core.view.entityselect.EntitySelectResults.java

License:Open Source License

@PostConstruct
@Override//from  ww w  .j  av  a 2  s  . c om
public void postConstruct() {
    super.postConstruct();
    addSelectionChangedListener(this, "selectionChanged");

    HorizontalLayout crudButtons = new HorizontalLayout();
    setDebugId(crudButtons, "crudButtons");
    crudButtons.setMargin(false);
    crudButtons.setSpacing(true);

    selectButton = new Button(uiMessageSource.getMessage("results.select"));
    selectButton.setDescription(uiMessageSource.getToolTip("results.select.toolTip"));
    selectButton.setEnabled(false);
    selectButton.addStyleName("small default");
    crudButtons.addComponent(selectButton);

    getCrudButtons().addComponent(crudButtons, 0);
    getCrudButtons().setComponentAlignment(crudButtons, Alignment.MIDDLE_LEFT);

    getEntityQuery().setPageSize(applicationProperties.getDefaultSelectPageSize());

    addCodePopupButtonIfEnabled(EntitySelectResults.class);
}

From source file:com.expressui.core.view.export.ExportForm.java

License:Open Source License

@Override
protected void createFooterButtons(HorizontalLayout footerLayout) {
    footerLayout.setSpacing(true);
    footerLayout.setMargin(true);//  w ww . j  a  va2 s  .  co m

    Button closeButton = new Button(uiMessageSource.getMessage("exportForm.close"), this, "close");
    closeButton.setDescription(uiMessageSource.getToolTip("exportForm.close.toolTip"));
    closeButton.setIcon(new ThemeResource("../expressui/icons/16/delete.png"));
    closeButton.addStyleName("small default");
    footerLayout.addComponent(closeButton);

    exportButton = new Button(uiMessageSource.getMessage("exportForm.export"));
    exportButton.setDescription(uiMessageSource.getToolTip("exportForm.export.toolTip"));
    exportButton.setIcon(new ThemeResource("../expressui/icons/16/excel.bmp"));
    exportButton.addStyleName("small default");
    footerLayout.addComponent(exportButton);
}

From source file:com.expressui.core.view.form.EntityForm.java

License:Open Source License

/**
 * Creates the footer buttons: cancel, refresh, save.
 *
 * @param footerLayout horizontal layout containing buttons
 *//*from   w  ww  .java  2s.c  o m*/
@Override
protected void createFooterButtons(HorizontalLayout footerLayout) {
    footerLayout.setSpacing(true);
    footerLayout.setMargin(true);

    cancelButton = new Button(uiMessageSource.getMessage("entityForm.cancel"), this, "cancel");
    cancelButton.setDescription(uiMessageSource.getToolTip("entityForm.cancel.toolTip"));
    cancelButton.setIcon(new ThemeResource("../expressui/icons/16/cancel.png"));
    cancelButton.addStyleName("small default");
    footerLayout.addComponent(cancelButton);

    refreshButton = new Button(uiMessageSource.getMessage("entityForm.refresh"), this, "refresh");
    refreshButton.setDescription(uiMessageSource.getToolTip("entityForm.refresh.toolTip"));
    refreshButton.setIcon(new ThemeResource("../expressui/icons/16/refresh.png"));
    refreshButton.addStyleName("small default");
    footerLayout.addComponent(refreshButton);

    saveAndStayOpenButton = new Button(uiMessageSource.getMessage("entityForm.saveAndStayOpen"), this,
            "saveAndStayOpen");
    saveAndStayOpenButton.setDescription(uiMessageSource.getToolTip("entityForm.saveAndStayOpen.toolTip"));
    saveAndStayOpenButton.setIcon(new ThemeResource("../expressui/icons/16/save.png"));
    saveAndStayOpenButton.addStyleName("small default");
    footerLayout.addComponent(saveAndStayOpenButton);

    saveAndCloseButton = new Button(uiMessageSource.getMessage("entityForm.saveAndClose"), this,
            "saveAndClose");
    saveAndCloseButton.setDescription(uiMessageSource.getToolTip("entityForm.saveAndClose.toolTip"));
    saveAndCloseButton.setIcon(new ThemeResource("../expressui/icons/16/save.png"));
    saveAndCloseButton.addStyleName("small default");
    footerLayout.addComponent(saveAndCloseButton);

    backupSaveButtonIcons();
}

From source file:com.expressui.core.view.form.ResultsConnectedEntityForm.java

License:Open Source License

private HorizontalLayout createNavigationFormLayout() {
    HorizontalLayout navigationFormLayout = new HorizontalLayout();
    String id = StringUtil.generateDebugId("e", this, navigationFormLayout, "navigationFormLayout");
    navigationFormLayout.setDebugId(id);
    navigationFormLayout.setSizeUndefined();

    VerticalLayout previousButtonLayout = new VerticalLayout();
    id = StringUtil.generateDebugId("e", this, previousButtonLayout, "previousButtonLayout");
    previousButtonLayout.setDebugId(id);

    previousButtonLayout.setSizeUndefined();
    previousButtonLayout.setMargin(false);
    previousButtonLayout.setSpacing(false);
    Label spaceLabel = new Label("</br></br></br>", Label.CONTENT_XHTML);
    spaceLabel.setSizeUndefined();//  w ww  . jav  a 2 s . co  m
    previousButtonLayout.addComponent(spaceLabel);

    Button previousButton = new Button(null, this, "previousItem");
    previousButton.setDescription(entityForm.uiMessageSource.getToolTip("entityForm.previous.toolTip"));
    previousButton.setSizeUndefined();
    previousButton.addStyleName("borderless");
    previousButton.setIcon(new ThemeResource("../expressui/icons/16/previous.png"));

    if (entityForm.getViewableToManyRelationships().size() == 0) {
        HorizontalLayout previousButtonHorizontalLayout = new HorizontalLayout();
        id = StringUtil.generateDebugId("e", this, previousButtonHorizontalLayout,
                "previousButtonHorizontalLayout");
        previousButtonHorizontalLayout.setDebugId(id);
        previousButtonHorizontalLayout.setSizeUndefined();
        Label horizontalSpaceLabel = new Label("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", Label.CONTENT_XHTML);
        horizontalSpaceLabel.setSizeUndefined();
        previousButtonHorizontalLayout.addComponent(previousButton);
        previousButtonHorizontalLayout.addComponent(horizontalSpaceLabel);
        previousButtonLayout.addComponent(previousButtonHorizontalLayout);
    } else {
        previousButtonLayout.addComponent(previousButton);
    }

    navigationFormLayout.addComponent(previousButtonLayout);
    navigationFormLayout.setComponentAlignment(previousButtonLayout, Alignment.TOP_LEFT);

    navigationFormLayout.addComponent(entityForm);

    VerticalLayout nextButtonLayout = new VerticalLayout();
    id = StringUtil.generateDebugId("e", this, nextButtonLayout, "nextButtonLayout");
    nextButtonLayout.setDebugId(id);
    nextButtonLayout.setSizeUndefined();
    nextButtonLayout.setMargin(false);
    nextButtonLayout.setSpacing(false);
    spaceLabel = new Label("</br></br></br>", Label.CONTENT_XHTML);
    spaceLabel.setSizeUndefined();
    previousButtonLayout.addComponent(spaceLabel);
    nextButtonLayout.addComponent(spaceLabel);

    Button nextButton = new Button(null, this, "nextItem");
    nextButton.setDescription(entityForm.uiMessageSource.getToolTip("entityForm.next.toolTip"));
    nextButton.setSizeUndefined();
    nextButton.addStyleName("borderless");
    nextButton.setIcon(new ThemeResource("../expressui/icons/16/next.png"));

    HorizontalLayout nextButtonHorizontalLayout = new HorizontalLayout();
    id = StringUtil.generateDebugId("e", this, nextButtonHorizontalLayout, "nextButtonHorizontalLayout");
    nextButtonHorizontalLayout.setDebugId(id);
    nextButtonHorizontalLayout.setSizeUndefined();
    Label horizontalSpaceLabel = new Label("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", Label.CONTENT_XHTML);
    horizontalSpaceLabel.setSizeUndefined();
    nextButtonHorizontalLayout.addComponent(horizontalSpaceLabel);
    nextButtonHorizontalLayout.addComponent(nextButton);

    nextButtonLayout.addComponent(nextButtonHorizontalLayout);
    navigationFormLayout.addComponent(nextButtonLayout);
    navigationFormLayout.setComponentAlignment(nextButtonLayout, Alignment.TOP_RIGHT);

    navigationFormLayout.setSpacing(false);
    navigationFormLayout.setMargin(false);

    return navigationFormLayout;
}

From source file:com.expressui.core.view.form.SearchForm.java

License:Open Source License

@Override
protected void createFooterButtons(HorizontalLayout footerLayout) {
    footerLayout.setSpacing(true);
    footerLayout.setMargin(true);//  ww w.  jav a2s. c om

    Button clearButton = new Button(uiMessageSource.getMessage("searchForm.clear"), this, "clear");
    clearButton.setDescription(uiMessageSource.getToolTip("searchForm.clear.toolTip"));
    clearButton.setIcon(new ThemeResource("../expressui/icons/16/clear.png"));
    clearButton.addStyleName("small default");
    footerLayout.addComponent(clearButton);

    Button searchButton = new Button(uiMessageSource.getMessage("searchForm.search"), this, "search");
    searchButton.setDescription(uiMessageSource.getToolTip("searchForm.search.toolTip"));
    searchButton.setIcon(new ThemeResource("../expressui/icons/16/search.png"));
    searchButton.addStyleName("small default");
    footerLayout.addComponent(searchButton);
}

From source file:com.expressui.core.view.page.DashboardPage.java

License:Open Source License

/**
 * Adds a component to the dashboard./*w w w. j a  va  2s  .co m*/
 *
 * @param component   component to add
 * @param caption     caption to display above component
 * @param startRow    start row coordinate in Dashboard grid
 * @param startColumn start column coordinate in Dashboard grid
 * @param endRow      end row coordinate in Dashboard grid
 * @param endColumn   end column coordinate in Dashboard grid
 */
public void addComponent(Component component, String caption, int startRow, int startColumn, int endRow,
        int endColumn) {
    if (component instanceof TypedComponent && !((TypedComponent) component).isViewAllowed())
        return;

    Panel panel = new Panel(caption);
    panel.addStyleName(ChameleonTheme.PANEL_BUBBLE);
    HorizontalLayout panelLayout = new HorizontalLayout();
    panelLayout.setSizeUndefined();
    panel.setSizeUndefined();

    setWidthAndHeightIfNotNull(component);

    panel.setContent(panelLayout);
    panelLayout.setMargin(true);
    panelLayout.setSpacing(true);
    panelLayout.addComponent(component);
    int rows = Math.max(rootLayout.getRows() - 1, endRow);
    int columns = Math.max(rootLayout.getColumns() - 1, endColumn);

    if (rootLayout.getRows() < rows) {
        rootLayout.setRows(rows);
    }
    if (rootLayout.getColumns() < columns) {
        rootLayout.setColumns(columns);
    }

    removeComponent(startRow, startColumn);
    rootLayout.addComponent(panel, startColumn - 1, startRow - 1, endColumn - 1, endRow - 1);
}

From source file:com.expressui.core.view.results.CrudResults.java

License:Open Source License

@PostConstruct
@Override//from w  w  w  .  j a  va2 s.  c o  m
public void postConstruct() {
    super.postConstruct();

    getResultsTable().setMultiSelect(true);

    HorizontalLayout crudButtons = new HorizontalLayout();
    setDebugId(crudButtons, "crudButtons");
    crudButtons.setMargin(false);
    crudButtons.setSpacing(true);

    newButton = new Button(uiMessageSource.getMessage("crudResults.new"), this, "create");
    newButton.setDescription(uiMessageSource.getToolTip("crudResults.new.toolTip"));
    newButton.setIcon(new ThemeResource("../expressui/icons/16/add.png"));
    newButton.addStyleName("small default");
    crudButtons.addComponent(newButton);

    viewButton = new Button(uiMessageSource.getMessage("crudResults.view"), this, "view");
    viewButton.setDescription(uiMessageSource.getToolTip("crudResults.view.toolTip"));
    viewButton.setIcon(new ThemeResource("../expressui/icons/16/view.png"));
    viewButton.addStyleName("small default");
    crudButtons.addComponent(viewButton);

    editButton = new Button(uiMessageSource.getMessage("crudResults.edit"), this, "edit");
    editButton.setDescription(uiMessageSource.getToolTip("crudResults.edit.toolTip"));
    editButton.setIcon(new ThemeResource("../expressui/icons/16/edit.png"));
    editButton.addStyleName("small default");
    crudButtons.addComponent(editButton);

    deleteButton = new Button(uiMessageSource.getMessage("crudResults.delete"), this, "delete");
    deleteButton.setDescription(uiMessageSource.getToolTip("crudResults.delete.toolTip"));
    deleteButton.setIcon(new ThemeResource("../expressui/icons/16/delete.png"));
    deleteButton.addStyleName("small default");
    crudButtons.addComponent(deleteButton);

    actionContextMenu.addAction("crudResults.view", this, "view");
    actionContextMenu.addAction("crudResults.edit", this, "edit");
    actionContextMenu.addAction("crudResults.delete", this, "delete");

    addSelectionChangedListener(this, "selectionChanged");
    getCrudButtons().addComponent(crudButtons, 0);
    getCrudButtons().setComponentAlignment(crudButtons, Alignment.MIDDLE_LEFT);

    getResultsTable().addListener(new DoubleClickListener());

    addCodePopupButtonIfEnabledForCrudResults();
}

From source file:com.expressui.core.view.results.Results.java

License:Open Source License

private HorizontalLayout createNavigationLine() {

    HorizontalLayout resultCountDisplay = new HorizontalLayout();
    setDebugId(resultCountDisplay, "resultCountDisplay");
    firstResultTextField = createFirstResultTextField();
    firstResultTextField.addStyleName("small");
    firstResultTextField.setSizeUndefined();
    resultCountDisplay.addComponent(firstResultTextField);
    resultCountLabel = new Label("", Label.CONTENT_XHTML);
    resultCountLabel.setSizeUndefined();
    resultCountLabel.addStyleName("small");
    resultCountDisplay.addComponent(resultCountLabel);

    Label spaceLabel = new Label(" &nbsp; ", Label.CONTENT_XHTML);
    spaceLabel.setSizeUndefined();//from ww  w .j  a v a 2 s  .c o m
    resultCountDisplay.addComponent(spaceLabel);

    Button refreshButton = new Button(null, getResultsTable(), "refresh");
    refreshButton.setDescription(uiMessageSource.getToolTip("results.refresh.toolTip"));
    refreshButton.setSizeUndefined();
    refreshButton.addStyleName("borderless");
    refreshButton.setIcon(new ThemeResource("../expressui/icons/16/refresh-blue.png"));
    resultCountDisplay.addComponent(refreshButton);

    HorizontalLayout navigationButtons = new HorizontalLayout();
    setDebugId(navigationButtons, "navigationButtons");
    navigationButtons.setMargin(false, true, false, false);
    navigationButtons.setSpacing(true);

    String perPageText = uiMessageSource.getMessage("results.pageSize");
    pageSizeMenu = new Select();
    pageSizeMenu.addStyleName("small");
    List<Integer> pageSizeOptions = applicationProperties.getPageSizeOptions();
    for (Integer pageSizeOption : pageSizeOptions) {
        pageSizeMenu.addItem(pageSizeOption);
        pageSizeMenu.setItemCaption(pageSizeOption, pageSizeOption + " " + perPageText);
    }
    pageSizeMenu.setFilteringMode(Select.FILTERINGMODE_OFF);
    pageSizeMenu.setNewItemsAllowed(false);
    pageSizeMenu.setNullSelectionAllowed(false);
    pageSizeMenu.setImmediate(true);
    pageSizeMenu.setWidth(8, UNITS_EM);
    navigationButtons.addComponent(pageSizeMenu);

    firstButton = new Button(null, getResultsTable(), "firstPage");
    firstButton.setDescription(uiMessageSource.getToolTip("results.first.toolTip"));
    firstButton.setSizeUndefined();
    firstButton.addStyleName("borderless");
    firstButton.setIcon(new ThemeResource("../expressui/icons/16/first.png"));
    navigationButtons.addComponent(firstButton);

    previousButton = new Button(null, getResultsTable(), "previousPage");
    previousButton.setDescription(uiMessageSource.getToolTip("results.previous.toolTip"));
    previousButton.setSizeUndefined();
    previousButton.addStyleName("borderless");
    previousButton.setIcon(new ThemeResource("../expressui/icons/16/previous.png"));
    navigationButtons.addComponent(previousButton);

    nextButton = new Button(null, getResultsTable(), "nextPage");
    nextButton.setDescription(uiMessageSource.getToolTip("results.next.toolTip"));
    nextButton.setSizeUndefined();
    nextButton.addStyleName("borderless");
    nextButton.setIcon(new ThemeResource("../expressui/icons/16/next.png"));
    navigationButtons.addComponent(nextButton);

    lastButton = new Button(null, getResultsTable(), "lastPage");
    lastButton.setDescription(uiMessageSource.getToolTip("results.last.toolTip"));
    lastButton.setSizeUndefined();
    lastButton.addStyleName("borderless");
    lastButton.setIcon(new ThemeResource("../expressui/icons/16/last.png"));
    navigationButtons.addComponent(lastButton);

    excelButton = new Button(null, this, "openExportForm");
    excelButton.setDescription(uiMessageSource.getToolTip("results.excel.toolTip"));
    excelButton.setSizeUndefined();
    excelButton.addStyleName("borderless");
    excelButton.setIcon(new ThemeResource("../expressui/icons/16/excel.bmp"));
    navigationButtons.addComponent(excelButton);
    exportForm.setExportButtonListener(this, "exportToExcel");

    HorizontalLayout navigationLine = new HorizontalLayout();
    setDebugId(navigationLine, "navigationLine");
    navigationLine.setSizeUndefined();
    navigationLine.setMargin(true, false, true, false);

    navigationLine.addComponent(resultCountDisplay);
    navigationLine.setComponentAlignment(resultCountDisplay, Alignment.BOTTOM_LEFT);

    spaceLabel = new Label("", Label.CONTENT_XHTML);
    spaceLabel.setWidth(2, Sizeable.UNITS_EM);
    navigationLine.addComponent(spaceLabel);

    navigationLine.addComponent(navigationButtons);
    navigationLine.setComponentAlignment(navigationButtons, Alignment.BOTTOM_RIGHT);

    return navigationLine;
}

From source file:com.expressui.core.view.RootComponent.java

License:Open Source License

/**
 * Sets composition root of this component to a HorizontalLayout with margins and spacing.
 *//*from  w  w w . j a va 2 s  .  c o  m*/
public HorizontalLayout createHorizontalLayout() {
    HorizontalLayout rootLayout = new HorizontalLayout();
    setDebugId(rootLayout, "rootLayout");
    rootLayout.setMargin(true);
    rootLayout.setSpacing(false);

    return rootLayout;
}