Example usage for com.vaadin.ui VerticalLayout setMargin

List of usage examples for com.vaadin.ui VerticalLayout setMargin

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setMargin.

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:com.scipionyx.butterflyeffect.frontend.core.ui.MainUI.java

License:Apache License

/**
 * /* w  ww.  ja v a2  s . c om*/
 */
@Override
protected void init(VaadinRequest request) {

    // Top Menu

    final VerticalLayout root = new VerticalLayout();
    root.setSizeFull();
    root.setMargin(new MarginInfo(false, false, false, false));
    root.setSpacing(false);

    root.addComponent(topFactory.instance());

    setContent(root);

    viewContainer = new Panel();
    viewContainer.setStyleName(ValoTheme.PANEL_BORDERLESS);
    viewContainer.setSizeFull();

    root.addComponent(viewContainer);
    root.setExpandRatio(viewContainer, 1.0f);

    // Define the access denied view
    viewProvider.setAccessDeniedViewClass(AccessDeniedView.class);

}

From source file:com.selzlein.lojavirtual.vaadin.page.SettingsView.java

License:Open Source License

private void createView() {
    ui = (LspsUI) getUI();/*from www . ja va2s .  c o  m*/
    user = ui.getUser().getPerson();
    userRights = user.getRights();

    setTitle(ui.getMessage(TITLE));

    Panel panel = new Panel();
    panel.addStyleName("l-border-none");
    setContent(panel);

    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName("l-settings");
    layout.setSizeFull();
    layout.setSpacing(true);
    layout.setMargin(true);
    panel.setContent(layout);

    //user data and settings will be laid out next to each other
    HorizontalLayout topSection = new HorizontalLayout();
    topSection.setSpacing(true);
    topSection.setWidth("100%");
    layout.addComponent(topSection);

    VerticalLayout userData = createUserDataSection(ui, user);
    topSection.addComponent(userData);
    topSection.setExpandRatio(userData, 1);

    Label spacer = new Label();
    spacer.setWidth("20px");
    topSection.addComponent(spacer);

    VerticalLayout settings = createSettingsSection(ui);
    topSection.addComponent(settings);
    topSection.setExpandRatio(settings, 1);

    //substitution section
    VerticalLayout substitution = createSubstitutionSection();
    layout.addComponent(substitution);
    layout.setExpandRatio(substitution, 2);

    //buttons
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button saveButton = new Button(ui.getMessage("action.save"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (save()) {
                if (requestReload) {
                    JavaScript.getCurrent().execute("window.location.reload()");
                } else {
                    close();
                }
            }
        }
    });
    saveButton.setData(BUTTON_TYPE_SAVE);
    buttons.addComponent(saveButton);
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
    layout.addComponent(buttons);
}

From source file:com.selzlein.lojavirtual.vaadin.popup.TodoDelegation.java

License:Open Source License

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

    LspsUI ui = (LspsUI) getUI();//  ww w . ja  va 2 s  .  com
    setCaption(ui.getMessage("todo.delegationTitle"));

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

    Label help = new Label(ui.getMessage("todo.delegationHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    Collection<Person> allUsers = new ArrayList<Person>(
            personService.findPersons(new PersonCriteria()).getData());
    Set<Person> substitutes = ui.getUser().getPerson().getDirectSubstitutes();
    Set<String> substitutesIds = new HashSet<String>();
    for (Person p : substitutes) {
        substitutesIds.add(p.getId());
    }

    delegates = new OptionGroup(ui.getMessage("todo.delegates"));
    delegates.setMultiSelect(true);
    delegates.addStyleName("ui-spacing");
    delegates.setRequired(true);
    delegates.setSizeFull();
    for (Person p : allUsers) {
        delegates.addItem(p.getId());
        delegates.setItemCaption(p.getId(), p.getFullName());
    }
    delegates.setValue(substitutesIds);
    layout.addComponent(delegates);
    layout.setExpandRatio(delegates, 1);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    layout.addComponent(buttons);

    @SuppressWarnings("serial")
    Button delegateButton = new Button(ui.getMessage("action.delegate"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            delegate();
        }
    });
    buttons.addComponent(delegateButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.siemens.ct.osgi.vaadin.pm.bundleview.BundleView.java

License:Open Source License

@SuppressWarnings("serial")
@Override// w ww  .j  ava 2 s .  co m
public Component getView(Application application) {
    if (view == null) {
        VerticalLayout verticalLayout = new VerticalLayout();
        verticalLayout.setMargin(true);
        verticalLayout.setSpacing(true);

        table = new Table();
        table.addContainerProperty("Bundle Symbolic Name", String.class, new ThemeResource("icons/bundle.png"));
        table.addContainerProperty("Version", String.class, null);
        table.addContainerProperty("State", String.class, null);
        table.addContainerProperty("Active", CheckBox.class, null);
        table.setWidth("100%");
        table.setPageLength(8);
        table.setSortContainerPropertyId("Bundle Symbolic Name");
        table.setSortAscending(true);
        table.setImmediate(true);

        refreshTable();
        verticalLayout.addComponent(table);

        HorizontalLayout horizontalLayout = new HorizontalLayout();
        horizontalLayout.setSpacing(true);

        Button refreshButton = new Button("Refresh Table");
        refreshButton.addListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                refreshTable();
            }
        });
        horizontalLayout.addComponent(refreshButton);

        Button selectAllButton = new Button("Select All");
        selectAllButton.addListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                for (Bundle bundle : bundles) {
                    try {
                        bundle.start();
                    } catch (BundleException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    refreshTable();
                }
            }
        });
        horizontalLayout.addComponent(selectAllButton);

        Button deselectAllButton = new Button("Deselect All");
        deselectAllButton.addListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                for (Bundle bundle : bundles) {
                    try {
                        bundle.stop();
                    } catch (BundleException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    refreshTable();
                }
            }
        });
        horizontalLayout.addComponent(deselectAllButton);

        verticalLayout.addComponent(horizontalLayout);
        view = verticalLayout;
    }
    return view;
}

From source file:com.siemens.ct.osgi.vaadin.pm.main.MainApplication.java

License:Open Source License

private Window getAboutDialog() {
    if (aboutWindow == null) {
        aboutWindow = new Window("About...");
        aboutWindow.setModal(true);/*w ww.  ja  v a 2s  .c  o  m*/
        aboutWindow.setWidth("400px");

        VerticalLayout layout = (VerticalLayout) aboutWindow.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName("blue");

        CssLayout titleLayout = new CssLayout();
        H2 title = new H2("Dynamic Vaadin OSGi Demo");
        titleLayout.addComponent(title);
        SmallText description = new SmallText("<br>Copyright (c) Siemens AG, Kai Tdter and others.<br>"
                + "Licensed under Eclipse Public License (EPL).<br><br>"
                + "This software contains modules licenced under<br>"
                + " the Apache Software Foundation 2.0 license (ASF) and EPL<br><br>"
                + "Many thanks to Chris Brind, Neil Bartlett and<br>"
                + " Petter Holmstrm for their OSGi and Vaadin<br>"
                + " related work, blogs, and bundles.<br><br>"
                + "The icons are from the Silk icon set by Mark James<br>"
                + "<a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/lab/icons/silk/</a>");
        description.setSizeUndefined();
        description.setContentMode(Label.CONTENT_XHTML);

        titleLayout.addComponent(description);
        aboutWindow.addComponent(titleLayout);

        @SuppressWarnings("serial")
        Button close = new Button("Close", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                (aboutWindow.getParent()).removeWindow(aboutWindow);
            }

        });
        layout.addComponent(close);
        layout.setComponentAlignment(close, "right");
    }
    return aboutWindow;
}

From source file:com.siemens.ct.osgi.vaadin.pm.tableview.TableView.java

License:Open Source License

@Override
public Component getView(Application application) {
    if (view == null) {
        VerticalLayout verticalLayout = new VerticalLayout();
        verticalLayout.setMargin(true);

        table = new Table();
        table.addContainerProperty("Name", String.class, null);
        table.addContainerProperty("First Name", String.class, null);
        table.addContainerProperty("Last Name", String.class, null);
        table.addContainerProperty("Company", String.class, null);
        table.setWidth("100%");
        table.setPageLength(9);//  ww w.  ja v a  2s.c om

        table.setImmediate(true);

        verticalLayout.addComponent(table);
        view = verticalLayout;

        synchronized (this) {
            if (personManager != null) {
                refreshTable();
            }
        }

    }
    return view;
}

From source file:com.skysql.manager.ManagerUI.java

License:Open Source License

/**
 * Inits the layout./*from ww  w. j  a v  a  2s .  c  om*/
 */
private void initLayout() {

    VerticalLayout main = new VerticalLayout();
    main.setMargin(new MarginInfo(false, true, false, true));
    main.setSpacing(true);
    main.setSizeFull();

    setContent(main);

    VaadinSession session = getSession();

    AnimatorProxy proxy = new AnimatorProxy();
    main.addComponent(proxy);
    session.setAttribute(AnimatorProxy.class, proxy);

    VerticalLayout topMiddleLayout = new VerticalLayout();
    main.addComponent(topMiddleLayout);
    session.setAttribute(VerticalLayout.class, topMiddleLayout);

    TopPanel topPanel = new TopPanel();
    topMiddleLayout.addComponent(topPanel);
    session.setAttribute(TopPanel.class, topPanel);

    overviewPanel = new OverviewPanel();
    topMiddleLayout.addComponent(overviewPanel);
    session.setAttribute(OverviewPanel.class, overviewPanel);

    tabbedPanel = new TabbedPanel(session);
    main.addComponent(tabbedPanel.getTabSheet());
    main.setExpandRatio(tabbedPanel.getTabSheet(), 1f);
    session.setAttribute(TabbedPanel.class, tabbedPanel);

    overviewPanel.refresh();

}

From source file:com.skysql.manager.ui.CalendarDialog.java

License:Open Source License

/**
 * Initializes a modal window to edit schedule event.
 *
 * @param event the event//from  w  ww  . ja v a  2 s  .  com
 * @param newEvent the new event
 */
private void createCalendarEventPopup(CalendarCustomEvent event, boolean newEvent) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);

    scheduleEventPopup = new Window(null, layout);
    scheduleEventPopup.setWidth("400px");
    scheduleEventPopup.setModal(true);
    scheduleEventPopup.center();

    Date occurrence = event.getOccurrence();
    if (!newEvent && occurrence != null) {
        Form form = new Form();
        form.setCaption("This is a repeat occurrence");
        layout.addComponent(form);

        DateField dateField = new DateField("Occurrence Start");
        if (useSecondResolution) {
            dateField.setResolution(Resolution.SECOND);
        } else {
            dateField.setResolution(Resolution.MINUTE);
        }
        dateField.setValue(event.getStart());
        dateField.setEnabled(false);
        form.addField("dateField", dateField);
        form.setFooter(null);

        HorizontalLayout editLayout = new HorizontalLayout();
        editLayout.setSpacing(true);
        layout.addComponent(editLayout);

        final Label label = new Label("Click to change the original event below:");
        editLayout.addComponent(label);
        editLayout.setComponentAlignment(label, Alignment.BOTTOM_LEFT);

        editOriginalButton = new Button("Edit", new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent clickEvent) {
                scheduleEventForm.setEnabled(true);
                applyEventButton.setEnabled(true);
                label.setValue("Editing original event:");
                editOriginalButton.setVisible(false);
            }
        });
        editLayout.addComponent(editOriginalButton);

        scheduleEventForm.setEnabled(false);
    } else {
        scheduleEventForm.setEnabled(true);
    }

    layout.addComponent(scheduleEventForm);

    applyEventButton = new Button("Add", new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            commitCalendarEvent();
        }
    });
    Button cancel = new Button("Cancel", new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            discardCalendarEvent();
        }
    });
    deleteEventButton = new Button("Delete", new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            deleteCalendarEvent();
        }
    });
    scheduleEventPopup.addListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            discardCalendarEvent();
        }
    });

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(deleteEventButton);
    buttons.addComponent(cancel);
    buttons.addComponent(applyEventButton);
    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);
}

From source file:com.skysql.manager.ui.CalendarDialog.java

License:Open Source License

/**
 * Show delete popup.//from  w w w  .  jav  a  2  s .  c o m
 *
 * @param event the event
 */
private void showDeletePopup(final CalendarCustomEvent event) {
    if (event == null) {
        return;
    }

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);

    deleteSchedulePopup = new Window("Delete Recurring Event", layout);
    deleteSchedulePopup.setWidth("740px");
    deleteSchedulePopup.setModal(true);
    deleteSchedulePopup.center();
    deleteSchedulePopup.setContent(layout);
    deleteSchedulePopup.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            UI.getCurrent().removeWindow(deleteSchedulePopup);
        }
    });

    Label warning = new Label(
            "Do you want to delete the original event, or this and all future occurrences of the event, or only the selected occurrence?");
    layout.addComponent(warning);

    Button cancel = new Button("Cancel", new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(deleteSchedulePopup);
        }
    });

    Button deleteAll = new Button("Delete Original Event", new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent dummy) {
            String scheduleID = (String) event.getData();
            Schedule.delete(scheduleID);

            schedule.getScheduleList().remove(scheduleID);

            ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID);
            for (CalendarCustomEvent removeEvent : eventsList) {
                if (dataSource.containsEvent(removeEvent)) {
                    dataSource.removeEvent(removeEvent);
                }
            }

            UI.getCurrent().removeWindow(deleteSchedulePopup);

            UI.getCurrent().removeWindow(scheduleEventPopup);

        }
    });

    Button deleteFuture = new Button("Delete All Future Events", new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent dummy) {
            String scheduleID = (String) event.getData();
            ScheduleRecord scheduleRecord = schedule.getScheduleList().get(scheduleID);
            VEvent vEvent = iCalSupport.readVEvent(scheduleRecord.getICal());
            ManagerUI.log("before Delete All Future Events\n" + vEvent);
            iCalSupport.deleteAllFuture(vEvent, event.getStart());
            ManagerUI.log("after Delete All Future Events\n" + vEvent);
            scheduleRecord.setICal(vEvent.toString());

            Schedule.update(scheduleID, vEvent.toString());
            ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID);
            for (CalendarCustomEvent removeEvent : eventsList) {
                if (dataSource.containsEvent(removeEvent)) {
                    dataSource.removeEvent(removeEvent);
                }
            }

            schedule.getScheduleList().put(scheduleID, scheduleRecord);

            addEventsToMap(scheduleID, vEvent, event.getNode());
            eventsList = eventsMap.get(scheduleID);
            for (CalendarCustomEvent addEvent : eventsList) {
                if (!dataSource.containsEvent(addEvent)) {
                    dataSource.addEvent(addEvent);
                }
            }

            UI.getCurrent().removeWindow(deleteSchedulePopup);

            UI.getCurrent().removeWindow(scheduleEventPopup);

        }
    });

    Button deleteSelected = new Button("Delete Only This Event", new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent dummy) {
            String scheduleID = (String) event.getData();
            ScheduleRecord scheduleRecord = schedule.getScheduleList().get(scheduleID);
            VEvent vEvent = iCalSupport.readVEvent(scheduleRecord.getICal());
            ManagerUI.log("before Exclude\n" + vEvent);
            iCalSupport.addExcludedDate(vEvent, event.getStart());
            ManagerUI.log("after Exclude\n" + vEvent);
            scheduleRecord.setICal(vEvent.toString());

            Schedule.update(scheduleID, vEvent.toString());
            ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID);
            for (CalendarCustomEvent removeEvent : eventsList) {
                if (dataSource.containsEvent(removeEvent)) {
                    dataSource.removeEvent(removeEvent);
                }
            }

            schedule.getScheduleList().put(scheduleID, scheduleRecord);

            addEventsToMap(scheduleID, vEvent, event.getNode());
            eventsList = eventsMap.get(scheduleID);
            for (CalendarCustomEvent addEvent : eventsList) {
                if (!dataSource.containsEvent(addEvent)) {
                    dataSource.addEvent(addEvent);
                }
            }

            UI.getCurrent().removeWindow(deleteSchedulePopup);

            UI.getCurrent().removeWindow(scheduleEventPopup);

        }
    });

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(cancel);
    buttons.addComponent(deleteAll);
    buttons.addComponent(deleteFuture);
    buttons.addComponent(deleteSelected);
    deleteSelected.focus();

    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);

    if (!UI.getCurrent().getWindows().contains(deleteSchedulePopup)) {
        UI.getCurrent().addWindow(deleteSchedulePopup);
    }
}

From source file:com.skysql.manager.ui.ChartsDialog.java

License:Open Source License

/**
 * Instantiates a new charts dialog.// www .  ja v a  2  s  .c  o  m
 *
 * @param chartsLayout the charts layout
 * @param chartButton the chart button
 */
public ChartsDialog(final ChartsLayout chartsLayout, final ChartButton chartButton) {

    this.chartButton = chartButton;
    this.chartsLayout = chartsLayout;

    dialogWindow = new ModalWindow("Monitors to Chart mapping", "775px");

    HorizontalLayout wrapper = new HorizontalLayout();
    //wrapper.setWidth("100%");
    wrapper.setMargin(true);

    UI.getCurrent().addWindow(dialogWindow);

    newUserChart = (chartButton != null) ? new UserChart((UserChart) chartButton.getData()) : newUserChart();

    ArrayList<String> monitorIDs = newUserChart.getMonitorIDs();
    MonitorsLayout monitorsLayout = new MonitorsLayout(monitorIDs);
    wrapper.addComponent(monitorsLayout);

    VerticalLayout separator = new VerticalLayout();
    separator.setSizeFull();
    Embedded rightArrow = new Embedded(null, new ThemeResource("img/right_arrow.png"));
    separator.addComponent(rightArrow);
    separator.setComponentAlignment(rightArrow, Alignment.MIDDLE_CENTER);
    wrapper.addComponent(separator);

    ChartPreviewLayout chartPreviewLayout = new ChartPreviewLayout(newUserChart, chartsLayout.getTime(),
            chartsLayout.getInterval());
    wrapper.addComponent(chartPreviewLayout);
    monitorsLayout.addChartPreview(chartPreviewLayout);

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
        }
    });

    Button okButton = new Button(chartButton != null ? "Save Changes" : "Add Chart");
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            try {
                ChartButton newChartButton = new ChartButton(newUserChart);
                newChartButton.setChartsLayout(chartsLayout);
                newChartButton.setEditable(true);
                if (chartButton != null) {
                    chartsLayout.replaceComponent(chartButton, newChartButton);
                } else {
                    chartsLayout.addComponent(newChartButton);
                }

            } catch (Exception e) {
                ManagerUI.error(e.getMessage());
            }

            dialogWindow.close();
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.addComponent(buttonsBar);

}