Example usage for com.vaadin.ui VerticalLayout setSpacing

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

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:com.save.employee.EmployeeInformationTabSheet.java

public EmployeeInformationTabSheet() {
    VerticalLayout v = new VerticalLayout();
    v.setCaption("Personal Information");
    v.setWidth("100%");
    v.setMargin(true);/*from   ww w.  j a  v a 2s .com*/
    v.setSpacing(true);
    //        v.addComponent(new PersonalInformationForm(this, getEmployeeId(), null, null));
    addComponent(v);

    v = new VerticalLayout();
    v.setCaption("Employment Information");
    v.setWidth("100%");
    v.setMargin(true);
    v.setSpacing(true);
    //        v.addComponent(new EmploymentInformationForm(this, getEmployeeId()));
    addComponent(v);
}

From source file:com.save.employee.EmployeeInformationTabSheet.java

public EmployeeInformationTabSheet(HorizontalSplitPanel hsplit, int employeeId) {
    this.hsplit = hsplit;
    this.employeeId = employeeId;

    VerticalLayout v = new VerticalLayout();
    v.setCaption("Personal Information");
    v.setWidth("100%");
    v.setMargin(true);/*w w  w .  j  a  va2  s.co  m*/
    v.setSpacing(true);
    v.addComponent(new PersonalInformationForm(hsplit, employeeId, null, null));
    addComponent(v);

    v = new VerticalLayout();
    v.setCaption("Employment Information");
    v.setWidth("100%");
    v.setMargin(true);
    v.setSpacing(true);
    v.addComponent(new EmploymentInformationForm(hsplit, employeeId));
    addComponent(v);
}

From source file:com.save.employee.RemoveAccountWindow.java

VerticalLayout getVLayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);
    vlayout.setMargin(true);/* w  w w.  j  a va2s.  c o m*/
    vlayout.setSizeFull();

    final TextArea remarks = new TextArea("Remarks: ");
    remarks.setRows(2);
    remarks.setWidth("100%");
    vlayout.addComponent(remarks);

    Button removeBtn = new Button("REMOVE ACCOUNT?");
    removeBtn.setWidth("100%");
    removeBtn.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add Remarks!", Notification.Type.ERROR_MESSAGE);
            return;
        }

        boolean result = employeeService.removeAccount(getEmployeeId(),
                remarks.getValue().trim().toLowerCase());
        if (result) {
            close();
        }
    });
    vlayout.addComponent(removeBtn);

    return vlayout;
}

From source file:com.save.reports.maintenance.MaintenanceReportUI.java

Window exportLargeData() {
    Window sub = new Window("EXPORT LARGE DATA");
    sub.setWidth("300px");
    sub.setModal(true);// ww w  . j  a  va2s .com
    sub.center();

    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    v.setMargin(true);
    v.setSpacing(true);

    Label status = new Label("Exporting large amount of data will take longer and will eat a lot of memory.",
            ContentMode.HTML);
    status.setContentMode(ContentMode.HTML);
    v.addComponent(status);

    Button b = new CommonButton("PROCEED TO EXPORT?");
    b.addClickListener((Button.ClickEvent e) -> {
        sub.close();
        processExportDataToExcel();
    });
    v.addComponent(b);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();
    return sub;
}

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

License:Apache License

/**
 * //from  ww  w.j  a  va 2  s.c  o m
 */
@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();/*www  .  j  a  v a2  s.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.page.SettingsView.java

License:Open Source License

private VerticalLayout createSettingsSection(LspsUI ui) {
    VerticalLayout settings = new VerticalLayout();
    settings.setSpacing(true);

    Label settingsHeader = new Label("<h2>" + ui.getMessage("settings.applicationSection") + "</h2>",
            ContentMode.HTML);/*w  ww  .j av  a 2  s  .  c om*/
    settings.addComponent(settingsHeader);

    this.languages = new OptionGroup(ui.getMessage("settings.language"));
    languages.addStyleName("ui-spacing");
    languages.addItem("en_US");
    languages.setItemCaption("en_US", "English");
    languages.addItem("de_DE");
    languages.setItemCaption("de_DE", "Deutsch");
    languages.addItem("sk_SK");
    languages.setItemCaption("sk_SK", "Slovensky");
    languages.setValue(ui.getLocale().toString());
    settings.addComponent(languages);

    this.themes = new OptionGroup(ui.getMessage("settings.theme"));
    themes.addStyleName("ui-spacing");
    for (String s : Constants.THEMES) {
        themes.addItem(s);
    }
    for (String themeName : vaadinThemeCache.getThemeNames()) {
        themes.addItem(themeName);
    }
    String userTheme = ui.getUser().getSettingString("theme", Constants.DEFAULT_THEME);
    themes.setValue(userTheme);
    settings.addComponent(themes);

    return settings;
}

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

License:Open Source License

private VerticalLayout createSubstitutionSection() {
    VerticalLayout substitution = new VerticalLayout();
    substitution.addStyleName("l-substitutes");
    substitution.setSpacing(true);
    substitution.setSizeFull();//from  w w w. j  a  v  a  2s  .co m

    Label substitutionHeader = new Label("<h2>" + ui.getMessage("settings.substitutionSection") + "</h2>",
            ContentMode.HTML);
    substitution.addComponent(substitutionHeader);

    Label substitutionHelp = new Label(ui.getMessage("settings.substitutionHelp"));
    substitutionHelp.setStyleName("form-help");
    substitution.addComponent(substitutionHelp);

    this.substitutionActive = new CheckBox(ui.getMessage("settings.substitutionActive"));
    substitutionActive.addStyleName("ui-spacing");
    substitutionActive.setValue(user.isSubstitutionActive());
    substitution.addComponent(substitutionActive);

    //substitutes
    selectedPersons = user.getDirectSubstitutes();
    this.substitutes = new OptionGroup(ui.getMessage("settings.substitutes"));
    refreshSubstitutes("");

    TextField substituteFilter = new TextField(ui.getMessage("action.filter"));
    substituteFilter.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            substitutes.removeAllItems();
            refreshSubstitutes(event.getProperty().getValue().toString());
        }
    });
    substitution.addComponent(substituteFilter);
    Panel substitutesPanel = new Panel();
    substitutesPanel.addStyleName("l-border-none");
    substitutesPanel.setSizeFull();
    substitutesPanel.setContent(substitutes);
    substitution.addComponent(substitutesPanel);
    substitution.setExpandRatio(substitutesPanel, 2);

    return substitution;
}

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

License:Open Source License

@SuppressWarnings("serial")
private void createView() {
    final LspsUI ui = (LspsUI) getUI();

    setTitle(ui.getMessage(TITLE));/*from   w  ww  . j a v  a2  s  . c o m*/

    VerticalLayout layout = new VerticalLayout();
    setContent(layout);

    table = new Table();
    table.setSizeFull();
    table.setSelectable(true);
    table.setMultiSelectMode(MultiSelectMode.SIMPLE);
    table.setSortEnabled(false);
    table.setColumnReorderingAllowed(true);
    table.setColumnCollapsingAllowed(true);

    table.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Object sel = event.getProperty().getValue();
            if (sel instanceof Set) {
                selection = (Set<Long>) sel;
            } else if (sel instanceof Long) {
                selection = Collections.singleton((Long) sel);
            } else {
                selection = Collections.emptySet();
            }

            //enable todo actions only if the sel is non-empty
            actionBtn.setEnabled(selection.size() > 0);
        }
    });
    table.addItemClickListener(new ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            if (table.isMultiSelect()) {
                return; //don't do anything if in selection mode
            }
            if (event.getButton() != MouseButton.LEFT || event.isDoubleClick()) {
                return; //ignore right-clicks
            }

            final Item item = event.getItem();
            final Long todoId = (Long) item.getItemProperty("id").getValue();
            try {
                ((LspsUI) getUI()).openTodo(todoId);
            } catch (Exception e) {
                Utils.log(e, "could not open to-do " + todoId, log);
                final LspsUI ui = (LspsUI) getUI();
                ui.showErrorMessage("app.unknownErrorOccurred", e); //todo.openFailed?
            }
        }
    });

    table.setContainerDataSource(container);

    Object[] defaultColumns = new Object[] { "title", "notes", "priority", "authorization", "modelInstanceId",
            "issuedDate" };
    //load table settings
    String settings = ui.getUser().getSettingString(SETTINGS_KEY, null);
    if (settings == null) {
        table.setVisibleColumns(defaultColumns);
        originalSettings = getColumnSettings();
    } else {
        originalSettings = settings;
        try {
            applyTableSettings(settings);
        } catch (Exception e) {
            table.setVisibleColumns(defaultColumns);
            Utils.log(e, "could not load todo list settings", log);
        }
    }

    table.setColumnHeader("title", ui.getMessage("todo.title"));
    table.setColumnHeader("notes", ui.getMessage("todo.notes"));
    table.setColumnHeader("priority", ui.getMessage("todo.priority"));
    table.setColumnHeader("authorization", ui.getMessage("todo.authorizationShort"));
    table.setColumnHeader("modelInstanceId", ui.getMessage("todo.process"));
    table.setColumnHeader("issuedDate", ui.getMessage("todo.issued"));

    table.setColumnAlignment("modelInstanceId", Table.Align.CENTER);
    if (table.getItemIds().size() > 0) {
        table.setColumnExpandRatio("title", 2);
        table.setColumnExpandRatio("notes", 1);
    }

    //localize todo titles
    table.addGeneratedColumn("title", new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            @SuppressWarnings("unchecked")
            BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId);
            return ui.localizeEngineText(item.getBean().getTitle());
        }
    });

    //show icons for authorization
    table.addGeneratedColumn("authorization", new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            @SuppressWarnings("unchecked")
            BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId);
            String icon;
            String text;
            switch (item.getBean().getAuthorization()) {
            case INITIAL_PERFORMER:
                icon = "auth_performer.gif";
                text = ui.getMessage("todo.authorizationPerformer");
                break;
            case DELEGATE:
                icon = "auth_delegate.gif";
                text = ui.getMessage("todo.authorizationDelegate");
                break;
            case SUBSTITUTE:
                icon = "auth_substitute.gif";
                text = ui.getMessage("todo.authorizationSubstitute");
                break;
            case NOT_PERMITTED:
            default:
                icon = "auth_unknown.gif";
                text = ui.getMessage("todo.authorizationUnknown");
                break;
            }
            Embedded authIcon = new Embedded(null, new ThemeResource("../icons/" + icon));
            authIcon.setDescription(text);

            if (item.getBean().getAllocatedTo() != null) {
                HorizontalLayout layout = new HorizontalLayout();
                layout.setSpacing(true);

                layout.addComponent(authIcon);

                Embedded lockedIcon = new Embedded(null, new ThemeResource("../icons/lock.gif"));
                lockedIcon.setDescription(
                        ui.getMessage("todo.lockedBy", item.getBean().getAllocatedToFullName()));
                layout.addComponent(lockedIcon);
                return layout;
            } else {
                return authIcon;
            }
        }
    });

    //format date
    final SimpleDateFormat df = new SimpleDateFormat(ui.getMessage("app.dateTimeFormat"));
    table.addGeneratedColumn("issuedDate", new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            @SuppressWarnings("unchecked")
            BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId);
            return df.format(item.getBean().getIssuedDate());
        }
    });

    layout.addComponent(table);
    layout.setExpandRatio(table, 1);
}

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

License:Open Source License

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

    LspsUI ui = (LspsUI) getUI();/*from www.j a v a 2  s. c  o  m*/
    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);
}