Example usage for com.vaadin.ui GridLayout setSpacing

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

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:org.sensorhub.ui.NetworkAdminPanel.java

License:Mozilla Public License

@Override
public void build(final MyBeanItem<ModuleConfig> beanItem, final ICommNetwork<?> module) {
    super.build(beanItem, module);

    // add sub form
    final GridLayout form = new GridLayout();
    form.setWidth(100.0f, Unit.PERCENTAGE);
    form.setMargin(false);// ww  w . j  a v  a  2 s  .  c  om
    form.setSpacing(true);

    // add sections
    addAvailableNetworks(form, module);
    addScannedDevices(form, module);

    addComponent(form);
}

From source file:org.sensorhub.ui.SensorAdminPanel.java

License:Mozilla Public License

@Override
public void build(final MyBeanItem<ModuleConfig> beanItem, final ISensorModule<?> module) {
    super.build(beanItem, module);

    // add section label
    final GridLayout form = new GridLayout();
    form.setWidth(100.0f, Unit.PERCENTAGE);
    form.setMargin(false);/*from  ww w . ja  v a  2s. c  o  m*/
    form.setSpacing(true);

    // section title
    form.addComponent(new Label(""));
    HorizontalLayout titleBar = new HorizontalLayout();
    titleBar.setSpacing(true);
    Label sectionLabel = new Label("Inputs/Outputs");
    sectionLabel.addStyleName(STYLE_H3);
    sectionLabel.addStyleName(STYLE_COLORED);
    titleBar.addComponent(sectionLabel);
    titleBar.setComponentAlignment(sectionLabel, Alignment.MIDDLE_LEFT);

    // refresh button to show latest record
    Button refreshButton = new Button("Refresh");
    refreshButton.setDescription("Load latest data from sensor");
    refreshButton.setIcon(REFRESH_ICON);
    refreshButton.addStyleName(STYLE_QUIET);
    titleBar.addComponent(refreshButton);
    titleBar.setComponentAlignment(refreshButton, Alignment.MIDDLE_LEFT);
    refreshButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            rebuildSwePanels(form, module);
        }
    });

    form.addComponent(titleBar);

    // add I/O panel
    rebuildSwePanels(form, module);
    addComponent(form);
}

From source file:org.sensorhub.ui.StorageAdminPanel.java

License:Mozilla Public License

@Override
public void build(final MyBeanItem<ModuleConfig> beanItem, final IRecordStorageModule<?> storage) {
    super.build(beanItem, storage);

    if (storage != null) {
        // section layout
        final GridLayout form = new GridLayout();
        form.setWidth(100.0f, Unit.PERCENTAGE);
        form.setMargin(false);//  w w  w  .  ja  v a 2 s. com
        form.setSpacing(true);

        // section title
        form.addComponent(new Label(""));
        HorizontalLayout titleBar = new HorizontalLayout();
        titleBar.setSpacing(true);
        Label sectionLabel = new Label("Data Store Content");
        sectionLabel.addStyleName(STYLE_H3);
        sectionLabel.addStyleName(STYLE_COLORED);
        titleBar.addComponent(sectionLabel);
        titleBar.setComponentAlignment(sectionLabel, Alignment.MIDDLE_LEFT);

        // refresh button to show latest record
        Button refreshButton = new Button("Refresh");
        refreshButton.setDescription("Reload data from storage");
        refreshButton.setIcon(REFRESH_ICON);
        refreshButton.addStyleName(STYLE_QUIET);
        titleBar.addComponent(refreshButton);
        titleBar.setComponentAlignment(refreshButton, Alignment.MIDDLE_LEFT);
        refreshButton.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                buildDataPanel(form, storage);
            }
        });

        form.addComponent(titleBar);

        // add I/O panel
        buildDataPanel(form, storage);
        addComponent(form);
    }
}

From source file:org.sensorhub.ui.StorageAdminPanel.java

License:Mozilla Public License

protected void buildDataPanel(GridLayout form, IRecordStorageModule<?> storage) {
    // measurement outputs
    int i = 1;//from www.j av  a 2 s.  co m
    if (storage.isEnabled()) {
        for (IRecordStoreInfo dsInfo : storage.getRecordStores().values()) {
            Panel panel = newPanel("Stream #" + i++);
            GridLayout panelLayout = ((GridLayout) panel.getContent());
            panelLayout.setSpacing(true);

            // stored time period
            double[] timeRange = storage.getRecordsTimeRange(dsInfo.getName());
            Label l = new Label("<b>Time Range:</b> " + new DateTimeFormat().formatIso(timeRange[0], 0) + " / "
                    + new DateTimeFormat().formatIso(timeRange[1], 0));
            l.setContentMode(ContentMode.HTML);
            panelLayout.addComponent(l, 0, 0, 1, 0);

            // time line
            panelLayout.addComponent(buildGantt(storage, dsInfo), 0, 1, 1, 1);

            // data structure
            DataComponent dataStruct = dsInfo.getRecordDescription();
            Component sweForm = new SWECommonForm(dataStruct);
            panelLayout.addComponent(sweForm);

            // data table
            panelLayout.addComponent(buildTable(storage, dsInfo));

            if (oldPanel != null)
                form.replaceComponent(oldPanel, panel);
            else
                form.addComponent(panel);
            oldPanel = panel;
        }
    }
}

From source file:org.sensorhub.ui.StorageAdminPanel.java

License:Mozilla Public License

protected Panel newPanel(String title) {
    Panel panel = new Panel(title);
    GridLayout layout = new GridLayout(2, 2);
    layout.setWidth(100.0f, Unit.PERCENTAGE);
    layout.setMargin(true);/*from   w w  w  . ja  v a2s.  com*/
    layout.setSpacing(true);
    layout.setColumnExpandRatio(0, 0.2f);
    layout.setColumnExpandRatio(1, 0.8f);
    layout.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    panel.setContent(layout);
    return panel;
}

From source file:org.vaadin.addons.sitekit.flow.AbstractFlowViewlet.java

License:Apache License

@Override
public final void attach() {
    super.attach();

    final GridLayout layout = new GridLayout(1, 3);
    layout.setSizeFull();//from  ww  w . j  a  v a  2  s .  c  o  m
    this.setCompositionRoot(layout);
    layout.setRowExpandRatio(1, 1.0f);
    layout.setMargin(false);
    layout.setSpacing(true);

    topLayout = new HorizontalLayout();
    layout.addComponent(topLayout, 0, 0);

    topBackButton = new Button(getSite().localize("button-back"));
    topBackButton.setEnabled(false);
    topBackButton.addListener(this);
    topLayout.addComponent(topBackButton);
    topLayout.setExpandRatio(topBackButton, 0.0f);

    topPathLabel = new Label("", Label.CONTENT_XHTML);

    topLayout.addComponent(topPathLabel);
    topLayout.setComponentAlignment(topPathLabel, Alignment.MIDDLE_LEFT);
    topLayout.setExpandRatio(topPathLabel, 1f);

    topRightLayout = new HorizontalLayout();
    topLayout.addComponent(topRightLayout);
    topLayout.setComponentAlignment(topRightLayout, Alignment.MIDDLE_RIGHT);
    topLayout.setExpandRatio(topRightLayout, 0.0f);
    topLayout.setWidth(100, Unit.PERCENTAGE);

    bottomLayout = new HorizontalLayout();
    layout.addComponent(bottomLayout, 0, 2);

    bottomBackButton = new Button(getSite().localize("button-back"));
    bottomBackButton.setEnabled(false);
    bottomBackButton.addListener(this);
    bottomLayout.addComponent(bottomBackButton);
    bottomLayout.setExpandRatio(bottomBackButton, 0f);

    bottomPathLabel = new Label("", Label.CONTENT_XHTML);

    bottomLayout.addComponent(bottomPathLabel);
    bottomLayout.setExpandRatio(bottomPathLabel, 1f);
    bottomLayout.setComponentAlignment(bottomPathLabel, Alignment.MIDDLE_LEFT);

    bottomRightLayout = new HorizontalLayout();
    bottomLayout.addComponent(bottomRightLayout);
    bottomLayout.setComponentAlignment(bottomRightLayout, Alignment.MIDDLE_RIGHT);
    bottomLayout.setExpandRatio(bottomRightLayout, 0f);
    bottomLayout.setWidth(100, Unit.PERCENTAGE);

    tabSheet = new TabSheet();
    tabSheet.setStyleName("flow-sheet");
    tabSheet.hideTabs(true);
    tabSheet.setSizeFull();
    layout.addComponent(tabSheet, 0, 1);

    addFlowlets();

    tabSheet.setSelectedTab((Component) getRootFlowlet());
}

From source file:org.vaadin.addons.sitekit.module.audit.view.AuditLogFlowlet.java

License:Apache License

@Override
public void initialize() {
    // Get entity manager from site context and prepare container.
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<AuditLogEntry>(entityManager, true, false, false, AuditLogEntry.class,
            1000, new String[] { "created" }, new boolean[] { false }, "auditLogEntryId");

    // Get descriptors and set container properties.
    final List<FilterDescriptor> filterDescriptors = new ArrayList<FilterDescriptor>();
    filterDescriptors.add(new FilterDescriptor("startTime", "created", getSite().localize("filter-start-time"),
            new TimestampField(), 130, ">=", Date.class, new DateTime().withTimeAtStartOfDay().toDate()));
    filterDescriptors.add(new FilterDescriptor("endTime", "created", getSite().localize("filter-end-time"),
            new TimestampField(), 130, "<=", Date.class,
            new DateTime().withTimeAtStartOfDay().plusDays(1).toDate()));
    final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister
            .getFieldSetDescriptor(AuditLogEntry.class).getFieldDescriptors();
    ContainerUtil.addContainerProperties(entityContainer, fieldDescriptors);

    // Initialize layout
    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/* w  w w .j a v a 2 s  .co  m*/
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);
    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    // Initialize grid
    entityGrid = new Grid(new Table(), entityContainer);
    entityGrid.setFields(fieldDescriptors);
    entityGrid.setFilters(filterDescriptors);
    gridLayout.addComponent(entityGrid, 0, 1);

    final Button viewButton = getSite().getButton("view");
    buttonLayout.addComponent(viewButton);
    viewButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final AuditLogEntry entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final AuditLogEntryFlowlet contentView = getFlow().forward(AuditLogEntryFlowlet.class);
            contentView.edit(entity, false);
        }
    });

}

From source file:org.vaadin.addons.sitekit.module.content.view.ContentFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();//w w w  .jav a  2 s  .c o m
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    contentEditor = new ValidatingEditor(
            FieldSetDescriptorRegister.getFieldSetDescriptor(Content.class).getFieldDescriptors());
    contentEditor.setCaption("Content");
    contentEditor.addListener(this);
    gridLayout.addComponent(contentEditor, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 1);

    saveButton = getSite().getButton("save");
    buttonLayout.addComponent(saveButton);
    saveButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (isValid()) {
                contentEditor.commit();
                ContentDao.saveContent(entityManager, entity);
                editPrivilegesButton.setEnabled(true);
            } else {
                Notification.show(getSite().localize("message-invalid-form-content"),
                        Notification.Type.HUMANIZED_MESSAGE);
            }
        }
    });

    discardButton = getSite().getButton("discard");
    buttonLayout.addComponent(discardButton);
    discardButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            contentEditor.discard();
        }
    });

    editPrivilegesButton = getSite().getButton("edit-privileges");
    buttonLayout.addComponent(editPrivilegesButton);
    editPrivilegesButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            final PrivilegesFlowlet privilegesFlowlet = getFlow().getFlowlet(PrivilegesFlowlet.class);
            privilegesFlowlet.edit(entity.getPage(), entity.getContentId(), "view", "edit");
            getFlow().forward(PrivilegesFlowlet.class);
        }
    });
}

From source file:org.vaadin.addons.sitekit.module.content.view.ContentsFlowlet.java

License:Apache License

@Override
public void initialize() {
    // Get entity manager from site context and prepare container.
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Content>(entityManager, true, false, false, Content.class, 1000,
            new String[] { "page" }, new boolean[] { true }, "contentId");

    // Get descriptors and set container properties.
    final List<FilterDescriptor> filterDescriptors = new ArrayList<FilterDescriptor>();
    final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister
            .getFieldSetDescriptor(Content.class).getFieldDescriptors();
    ContainerUtil.addContainerProperties(entityContainer, fieldDescriptors);

    // Initialize layout
    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/*from w  w  w. j av  a  2  s . c o  m*/
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);
    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    // Initialize grid
    entityGrid = new Grid(new Table(), entityContainer);
    entityGrid.setFields(fieldDescriptors);
    entityGrid.setFilters(filterDescriptors);
    gridLayout.addComponent(entityGrid, 0, 1);

    final Button addButton = getSite().getButton("add");
    buttonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Content content = new Content();
            content.setCreated(new Date());
            content.setModified(content.getCreated());
            content.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final ContentFlowlet contentView = getFlow().forward(ContentFlowlet.class);
            contentView.edit(content, true);
        }
    });

    final Button editButton = getSite().getButton("edit");
    buttonLayout.addComponent(editButton);
    editButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Content entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final ContentFlowlet contentView = getFlow().forward(ContentFlowlet.class);
            contentView.edit(entity, false);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    buttonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            entityContainer.removeItem(entityGrid.getSelectedItemId());
            entityContainer.commit();
        }
    });
}

From source file:org.vaadin.addons.sitekit.site.FixedWidthView.java

License:Apache License

/**
 * {@inheritDoc}/*from w w  w.j  av a  2  s  .  c o m*/
 */
@Override
protected void initializeComponents() {
    final int columnCount = 5;
    final int rowCount = 3;

    final GridLayout layout = this;
    layout.setMargin(true);
    layout.setColumns(columnCount);
    layout.setRows(rowCount);
    layout.setColumnExpandRatio(0, MARGIN_COLUMN_EXPAND_RATIO);
    layout.setColumnExpandRatio(MARGIN_COLUMN_RIGTH_INDEX, MARGIN_COLUMN_EXPAND_RATIO);
    layout.setRowExpandRatio(1, 1.0f);
    layout.setSizeFull();
    layout.setMargin(false);
    layout.setSpacing(true);

    final AbstractComponent logoComponent = getComponent("logo");
    logoComponent.setWidth(NAVIGATION_COLUMN_WIDTH, Unit.PIXELS);
    layout.addComponent(logoComponent, 1, 0);

    final AbstractComponent navigationComponent = getComponent("navigation");
    navigationComponent.setWidth(NAVIGATION_COLUMN_WIDTH, Unit.PIXELS);
    navigationComponent.setHeight(NAVIGATION_HEIGHT, Unit.PIXELS);
    layout.addComponent(navigationComponent, 1, 1);

    final AbstractComponent headerComponent = getComponent("header");
    headerComponent.setWidth(CONTENT_COLUMN_WIDTH, Unit.PIXELS);
    headerComponent.setSizeFull();
    layout.addComponent(headerComponent, 2, 0);

    final AbstractComponent contentComponent = getComponent("content");
    contentComponent.setWidth(CONTENT_COLUMN_WIDTH, Unit.PIXELS);
    contentComponent.setSizeFull();
    layout.addComponent(contentComponent, 2, 1);

    final AbstractComponent footerComponent = getComponent("footer");
    headerComponent.setWidth(CONTENT_COLUMN_WIDTH, Unit.PIXELS);
    layout.addComponent(footerComponent, 2, 2);
}