Example usage for com.vaadin.ui Alignment TOP_CENTER

List of usage examples for com.vaadin.ui Alignment TOP_CENTER

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment TOP_CENTER.

Prototype

Alignment TOP_CENTER

To view the source code for com.vaadin.ui Alignment TOP_CENTER.

Click Source Link

Usage

From source file:com.esofthead.mycollab.reporting.CustomizeReportOutputWindow.java

License:Open Source License

public CustomizeReportOutputWindow(final String viewId, final String reportTitle, final Class<B> beanCls,
        final ISearchableService<S> searchableService, final VariableInjector<S> variableInjector) {
    super("Export");
    this.setModal(true);
    this.setWidth("1000px");
    this.setResizable(false);
    this.center();
    this.viewId = viewId;
    this.variableInjector = variableInjector;

    MVerticalLayout contentLayout = new MVerticalLayout();
    setContent(contentLayout);/*from  ww  w .  j  a va  2 s  .c  o m*/

    final OptionGroup optionGroup = new OptionGroup();
    optionGroup.addStyleName("sortDirection");
    optionGroup.addItems(AppContext.getMessage(FileI18nEnum.CSV), AppContext.getMessage(FileI18nEnum.PDF),
            AppContext.getMessage(FileI18nEnum.EXCEL));
    optionGroup.setValue(AppContext.getMessage(FileI18nEnum.CSV));
    contentLayout.with(
            new MHorizontalLayout(ELabel.h3(AppContext.getMessage(GenericI18Enum.ACTION_EXPORT)), optionGroup)
                    .alignAll(Alignment.MIDDLE_LEFT));

    contentLayout.with(ELabel.h3(AppContext.getMessage(GenericI18Enum.ACTION_SELECT_COLUMNS)));
    listBuilder = new ListBuilder();
    listBuilder.setImmediate(true);
    listBuilder.setColumns(0);
    listBuilder.setLeftColumnCaption(AppContext.getMessage(GenericI18Enum.OPT_AVAILABLE_COLUMNS));
    listBuilder.setRightColumnCaption(AppContext.getMessage(GenericI18Enum.OPT_VIEW_COLUMNS));
    listBuilder.setWidth(100, Sizeable.Unit.PERCENTAGE);
    listBuilder.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT);
    final BeanItemContainer<TableViewField> container = new BeanItemContainer<>(TableViewField.class,
            this.getAvailableColumns());
    listBuilder.setContainerDataSource(container);
    Iterator<TableViewField> iterator = getAvailableColumns().iterator();
    while (iterator.hasNext()) {
        TableViewField field = iterator.next();
        listBuilder.setItemCaption(field, AppContext.getMessage(field.getDescKey()));
    }
    final Collection<TableViewField> viewColumnIds = this.getViewColumns();
    listBuilder.setValue(viewColumnIds);
    contentLayout.with(listBuilder).withAlign(listBuilder, Alignment.TOP_CENTER);

    contentLayout.with(ELabel.h3(AppContext.getMessage(GenericI18Enum.ACTION_PREVIEW)));
    sampleTableDisplay = new Table();
    for (TableViewField field : getAvailableColumns()) {
        sampleTableDisplay.addContainerProperty(field.getField(), String.class, "",
                AppContext.getMessage(field.getDescKey()), null, Table.Align.LEFT);
        sampleTableDisplay.setColumnWidth(field.getField(), field.getDefaultWidth());
    }
    sampleTableDisplay.setWidth("100%");
    sampleTableDisplay.addItem(buildSampleData(), 1);
    sampleTableDisplay.setPageLength(1);
    contentLayout.with(sampleTableDisplay);
    filterColumns();

    listBuilder.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            filterColumns();
        }
    });

    Button resetBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    listBuilder.setValue(getDefaultColumns());
                    filterColumns();
                }
            });
    resetBtn.addStyleName(UIConstants.BUTTON_LINK);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    close();
                }
            });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);

    final Button exportBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    exportBtn.addStyleName(UIConstants.BUTTON_ACTION);
    OnDemandFileDownloader pdfFileDownloader = new OnDemandFileDownloader(new LazyStreamSource() {
        @Override
        protected StreamResource.StreamSource buildStreamSource() {
            return new StreamResource.StreamSource() {
                @Override
                public InputStream getStream() {
                    Collection<TableViewField> columns = (Collection<TableViewField>) listBuilder.getValue();
                    // Save custom table view def
                    CustomViewStoreService customViewStoreService = AppContextUtil
                            .getSpringBean(CustomViewStoreService.class);
                    CustomViewStore viewDef = new CustomViewStore();
                    viewDef.setSaccountid(AppContext.getAccountId());
                    viewDef.setCreateduser(AppContext.getUsername());
                    viewDef.setViewid(viewId);
                    viewDef.setViewinfo(FieldDefAnalyzer.toJson(new ArrayList<>(columns)));
                    customViewStoreService.saveOrUpdateViewLayoutDef(viewDef);

                    SimpleReportTemplateExecutor reportTemplateExecutor = new SimpleReportTemplateExecutor.AllItems<>(
                            reportTitle, new RpFieldsBuilder(columns), exportType, beanCls, searchableService);
                    ReportStreamSource streamSource = new ReportStreamSource(reportTemplateExecutor) {
                        @Override
                        protected void initReportParameters(Map<String, Object> parameters) {
                            parameters.put(SimpleReportTemplateExecutor.CRITERIA, variableInjector.eval());
                        }
                    };
                    return streamSource.getStream();
                }
            };
        }

        @Override
        public String getFilename() {
            String exportTypeVal = (String) optionGroup.getValue();
            if (AppContext.getMessage(FileI18nEnum.CSV).equals(exportTypeVal)) {
                exportType = ReportExportType.CSV;
            } else if (AppContext.getMessage(FileI18nEnum.EXCEL).equals(exportTypeVal)) {
                exportType = ReportExportType.EXCEL;
            } else {
                exportType = ReportExportType.PDF;
            }
            return exportType.getDefaultFileName();
        }
    });
    pdfFileDownloader.extend(exportBtn);

    MHorizontalLayout buttonControls = new MHorizontalLayout(resetBtn, cancelBtn, exportBtn);
    contentLayout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT);
}

From source file:com.esofthead.mycollab.shell.view.SetupNewInstanceView.java

License:Open Source License

public SetupNewInstanceView() {
    this.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    MVerticalLayout content = new MVerticalLayout().withWidth("600px");
    this.with(content);
    content.with(ELabel.h2("Last step, you are almost there!").withWidthUndefined());
    content.with(ELabel.h3("All fields are required *").withStyleName("overdue").withWidthUndefined());
    content.with(/*from w w  w  .  j  a  v  a2  s  . c o m*/
            new ELabel(AppContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO), ContentMode.HTML)
                    .withStyleName(UIConstants.META_COLOR));
    GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 8, "200px");
    formLayoutHelper.getLayout().setWidth("600px");
    final TextField adminField = formLayoutHelper.addComponent(new TextField(), "Admin email", 0, 0);
    final PasswordField passwordField = formLayoutHelper.addComponent(new PasswordField(), "Admin password", 0,
            1);
    final PasswordField retypePasswordField = formLayoutHelper.addComponent(new PasswordField(),
            "Retype Admin password", 0, 2);
    final DateFormatField dateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 3);

    final DateFormatField shortDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_SHORT_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 4);

    final DateFormatField longDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_LONG_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 5);

    final TimeZoneSelectionField timeZoneSelectionField = formLayoutHelper.addComponent(
            new TimeZoneSelectionField(false), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0,
            6);
    timeZoneSelectionField.setValue(TimeZone.getDefault().getID());
    final LanguageSelectionField languageBox = formLayoutHelper.addComponent(new LanguageSelectionField(),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 0, 7);
    languageBox.setValue(Locale.US.toLanguageTag());
    content.with(formLayoutHelper.getLayout());

    Button installBtn = new Button("Setup", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            String adminName = adminField.getValue();
            String password = passwordField.getValue();
            String retypePassword = retypePasswordField.getValue();
            if (!StringUtils.isValidEmail(adminName)) {
                NotificationUtil.showErrorNotification("Invalid email value");
                return;
            }

            if (!password.equals(retypePassword)) {
                NotificationUtil.showErrorNotification("Password is not match");
                return;
            }

            String dateFormat = dateFormatField.getValue();
            String shortDateFormat = shortDateFormatField.getValue();
            String longDateFormat = longDateFormatField.getValue();
            if (!isValidDayPattern(dateFormat) || !isValidDayPattern(shortDateFormat)
                    || !isValidDayPattern(longDateFormat)) {
                NotificationUtil.showErrorNotification("Invalid date format");
                return;
            }
            String language = languageBox.getValue();
            String timezoneDbId = timeZoneSelectionField.getValue();
            BillingAccountMapper billingAccountMapper = AppContextUtil
                    .getSpringBean(BillingAccountMapper.class);
            BillingAccountExample ex = new BillingAccountExample();
            ex.createCriteria().andIdEqualTo(AppContext.getAccountId());
            List<BillingAccount> billingAccounts = billingAccountMapper.selectByExample(ex);
            BillingAccount billingAccount = billingAccounts.get(0);
            billingAccount.setDefaultlanguagetag(language);
            billingAccount.setDefaultyymmddformat(dateFormat);
            billingAccount.setDefaultmmddformat(shortDateFormat);
            billingAccount.setDefaulthumandateformat(longDateFormat);
            billingAccount.setDefaulttimezone(timezoneDbId);
            billingAccountMapper.updateByPrimaryKey(billingAccount);

            BillingAccountService billingAccountService = AppContextUtil
                    .getSpringBean(BillingAccountService.class);

            billingAccountService.createDefaultAccountData(adminName, password, timezoneDbId, language, true,
                    true, AppContext.getAccountId());
            ((DesktopApplication) UI.getCurrent()).doLogin(adminName, password, false);

        }
    });
    installBtn.addStyleName(UIConstants.BUTTON_ACTION);
    content.with(installBtn).withAlign(installBtn, Alignment.TOP_RIGHT);
}

From source file:com.esofthead.mycollab.vaadin.mvp.view.NotPresentedView.java

License:Open Source License

public NotPresentedView() {
    this.withSpacing(true).withFullWidth();
    this.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    final Label titleIcon = new Label(FontAwesome.EXCLAMATION_CIRCLE.getHtml(), ContentMode.HTML);
    titleIcon.setStyleName("warning-icon");
    titleIcon.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    titleIcon.setWidthUndefined();/*from w ww. j  av a  2  s  .c o  m*/
    this.with(titleIcon);

    Label label = ELabel.h2(AppContext.getMessage(GenericI18Enum.NOTIFICATION_FEATURE_NOT_AVAILABLE_IN_VERSION))
            .withWidthUndefined();
    this.with(label).withAlign(label, Alignment.MIDDLE_CENTER);

    RestTemplate restTemplate = new RestTemplate();
    try {
        String result = restTemplate.getForObject("https://api.mycollab.com/api/storeweb", String.class);
        Label webPage = new Label(result, ContentMode.HTML);
        webPage.setHeight("480px");
        this.with(new MVerticalLayout(webPage).withMargin(false).withAlign(webPage, Alignment.TOP_CENTER));
    } catch (Exception e) {
        Div informDiv = new Div()
                .appendText("Can not load the store page. You can check the online edition at ")
                .appendChild(new A("https://www.mycollab.com/pricing/download/", "_blank").appendText("here"));
        ELabel webPage = new ELabel(informDiv.write(), ContentMode.HTML).withWidthUndefined();
        this.with(new MVerticalLayout(webPage).withAlign(webPage, Alignment.TOP_CENTER));
    }
}

From source file:com.esofthead.mycollab.vaadin.ui.DateComboboxSelectionField.java

License:Open Source License

@Override
protected Component initContent() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);/*from   ww w.  ja  va 2s. c o m*/

    layout.addComponent(cboMonth);
    layout.setComponentAlignment(cboMonth, Alignment.TOP_CENTER);

    layout.addComponent(cboDate);
    layout.setComponentAlignment(cboDate, Alignment.TOP_CENTER);

    layout.addComponent(cboYear);
    layout.setComponentAlignment(cboYear, Alignment.TOP_CENTER);
    return layout;
}

From source file:com.esofthead.mycollab.vaadin.ui.Depot.java

License:Open Source License

public Depot(final Label titleLbl, final AbstractOrderedLayout headerElement,
        final ComponentContainer component, final String headerWidth, final String headerLeftWidth) {
    this.setStyleName("depotComp");
    this.setMargin(new MarginInfo(true, false, false, false));
    this.header = new HorizontalLayout();
    this.header.setStyleName("depotHeader");
    this.header.setWidth(headerWidth);
    this.bodyContent = component;
    if (headerElement != null) {
        this.headerContent = headerElement;
    } else {/*ww  w  .  j av  a  2s . com*/
        this.headerContent = new HorizontalLayout();
        this.headerContent.setSpacing(true);
        this.headerContent.setMargin(true);
        this.headerContent.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
        this.headerContent.setVisible(false);
    }

    this.headerContent.setStyleName("header-elements");
    this.headerContent.setWidthUndefined();
    this.headerContent.setSizeUndefined();

    this.addComponent(this.header);

    final HorizontalLayout headerLeft = new HorizontalLayout();
    headerLeft.setMargin(false);
    this.headerLbl = titleLbl;
    this.headerLbl.setStyleName("h2");
    this.headerLbl.setWidth("100%");
    headerLeft.addComponent(this.headerLbl);
    headerLeft.setStyleName("depot-title");
    headerLeft.addLayoutClickListener(new LayoutClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void layoutClick(final LayoutClickEvent event) {
            Depot.this.isOpenned = !Depot.this.isOpenned;
            if (Depot.this.isOpenned) {
                Depot.this.bodyContent.setVisible(true);
                Depot.this.removeStyleName("collapsed");
            } else {
                Depot.this.bodyContent.setVisible(false);
                Depot.this.addStyleName("collapsed");
            }
        }
    });
    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.addComponent(headerLeft);
    headerWrapper.setStyleName("header-wrapper");
    headerWrapper.setWidth(headerLeftWidth);
    this.header.addComponent(headerWrapper);
    this.header.setComponentAlignment(headerWrapper, Alignment.MIDDLE_LEFT);
    this.header.addComponent(this.headerContent);
    this.header.setComponentAlignment(this.headerContent, Alignment.TOP_RIGHT);
    this.header.setExpandRatio(headerWrapper, 1.0f);

    final CustomComponent customComp = new CustomComponent(this.bodyContent);
    customComp.setWidth("100%");
    this.bodyContent.addStyleName("depotContent");

    this.addComponent(customComp);
    this.setComponentAlignment(customComp, Alignment.TOP_CENTER);
}

From source file:com.esofthead.mycollab.vaadin.ui.FormContainer.java

License:Open Source License

public FormContainer() {
    this.addStyleName("form");
    this.setWidth("100%");
    this.setDefaultComponentAlignment(Alignment.TOP_CENTER);
}

From source file:com.esofthead.mycollab.vaadin.ui.StyleCalendarExp.java

License:Open Source License

public StyleCalendarExp() {
    this.setWidth("230px");
    this.setHeightUndefined();
    this.setSpacing(false);
    this.setStyleName("stylecalendar-ext");
    this.setMargin(new MarginInfo(true, false, false, false));

    styleCalendar.setRenderHeader(false);
    styleCalendar.setRenderWeekNumbers(false);
    styleCalendar.setImmediate(true);/*w  ww. j  a  v a2  s. c o  m*/
    styleCalendar.setWidth("100%");
    setDateOptionsGenerator();

    btnShowNextYear = new Button();
    btnShowNextYear.setIcon(MyCollabResource.newResource("icons/16/cal_year_next.png"));
    btnShowNextYear.setStyleName("link");

    btnShowNextMonth = new Button();
    btnShowNextMonth.setIcon(MyCollabResource.newResource("icons/16/cal_month_next.png"));
    btnShowNextMonth.setStyleName("link");

    btnShowPreviousMonth = new Button();
    btnShowPreviousMonth.setIcon(MyCollabResource.newResource("icons/16/cal_month_pre.png"));
    btnShowPreviousMonth.setStyleName("link");

    btnShowPreviousYear = new Button();
    btnShowPreviousYear.setIcon(MyCollabResource.newResource("icons/16/cal_year_pre.png"));
    btnShowPreviousYear.setStyleName("link");

    lbSelectedDate.setValue(AppContext.formatDate(new Date()));
    lbSelectedDate.addStyleName("calendarDateLabel");
    lbSelectedDate.setWidth("80");

    HorizontalLayout layoutControl = new HorizontalLayout();
    layoutControl.setStyleName("calendarHeader");
    layoutControl.setWidth("100%");
    layoutControl.setHeight("35px");

    HorizontalLayout layoutButtonPrevious = new HorizontalLayout();
    layoutButtonPrevious.setSpacing(true);
    layoutButtonPrevious.addComponent(btnShowPreviousYear);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousYear, Alignment.MIDDLE_LEFT);
    layoutButtonPrevious.addComponent(btnShowPreviousMonth);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousMonth, Alignment.MIDDLE_LEFT);
    layoutControl.addComponent(layoutButtonPrevious);
    layoutControl.setComponentAlignment(layoutButtonPrevious, Alignment.MIDDLE_LEFT);

    layoutControl.addComponent(lbSelectedDate);
    layoutControl.setComponentAlignment(lbSelectedDate, Alignment.MIDDLE_CENTER);

    HorizontalLayout layoutButtonNext = new HorizontalLayout();
    layoutButtonNext.setSpacing(true);
    layoutButtonNext.addComponent(btnShowNextMonth);
    layoutButtonNext.setComponentAlignment(btnShowNextMonth, Alignment.MIDDLE_RIGHT);
    layoutButtonNext.addComponent(btnShowNextYear);
    layoutButtonNext.setComponentAlignment(btnShowNextYear, Alignment.MIDDLE_RIGHT);
    layoutControl.addComponent(layoutButtonNext);
    layoutControl.setComponentAlignment(layoutButtonNext, Alignment.MIDDLE_RIGHT);

    this.addComponent(layoutControl);
    this.setComponentAlignment(layoutControl, Alignment.TOP_CENTER);

    this.addComponent(styleCalendar);
    this.setExpandRatio(styleCalendar, 1.0f);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.Depot.java

License:Open Source License

public Depot(String title, ComponentContainer content) {
    this.addStyleName("depotComp");
    this.setMargin(false);
    header = new MHorizontalLayout().withHeight("40px").withStyleName("depotHeader");
    bodyContent = content;//from ww  w.  j  a v  a  2  s.c  o  m
    bodyContent.setWidth("100%");
    headerContent = new MHorizontalLayout().withMargin(true).withFullHeight();
    headerContent.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    headerContent.setVisible(false);
    headerContent.setStyleName("header-elements");
    headerContent.setWidthUndefined();
    this.addComponent(header);

    headerLbl = new Label(title);
    final MHorizontalLayout headerLeft = new MHorizontalLayout(headerLbl).withStyleName("depot-title")
            .withAlign(headerLbl, Alignment.MIDDLE_LEFT).withFullWidth();
    headerLeft.addLayoutClickListener(new LayoutClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void layoutClick(final LayoutClickEvent event) {
            isOpened = !isOpened;
            if (isOpened) {
                bodyContent.setVisible(true);
                removeStyleName("collapsed");
            } else {
                bodyContent.setVisible(false);
                addStyleName("collapsed");
            }
        }
    });
    header.with(headerLeft, headerContent).withAlign(headerLeft, Alignment.MIDDLE_LEFT)
            .withAlign(headerContent, Alignment.MIDDLE_RIGHT).expand(headerLeft);

    final CustomComponent customComp = new CustomComponent(bodyContent);
    customComp.setWidth("100%");
    bodyContent.addStyleName("depotContent");

    this.addComponent(customComp);
    this.setComponentAlignment(customComp, Alignment.TOP_CENTER);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.StyleCalendarExp.java

License:Open Source License

public StyleCalendarExp() {
    this.setWidth("230px");
    this.setHeightUndefined();
    this.setSpacing(false);
    this.setStyleName("stylecalendar-ext");
    this.setMargin(new MarginInfo(true, false, false, false));

    styleCalendar.setRenderHeader(false);
    styleCalendar.setRenderWeekNumbers(false);
    styleCalendar.setImmediate(true);/*from  www.  j a  v a2s.  c  om*/
    styleCalendar.setWidth("100%");
    setDateOptionsGenerator();

    btnShowNextYear = new Button();
    btnShowNextYear.setIcon(new AssetResource("icons/16/cal_year_next.png"));
    btnShowNextYear.setStyleName(UIConstants.BUTTON_LINK);

    btnShowNextMonth = new Button();
    btnShowNextMonth.setIcon(new AssetResource("icons/16/cal_month_next.png"));
    btnShowNextMonth.setStyleName(UIConstants.BUTTON_LINK);

    btnShowPreviousMonth = new Button();
    btnShowPreviousMonth.setIcon(new AssetResource("icons/16/cal_month_pre.png"));
    btnShowPreviousMonth.setStyleName(UIConstants.BUTTON_LINK);

    btnShowPreviousYear = new Button();
    btnShowPreviousYear.setIcon(new AssetResource("icons/16/cal_year_pre.png"));
    btnShowPreviousYear.setStyleName(UIConstants.BUTTON_LINK);

    lbSelectedDate.setValue(AppContext.formatDate(new Date()));
    lbSelectedDate.addStyleName("calendarDateLabel");
    lbSelectedDate.setWidth("80");

    HorizontalLayout layoutControl = new HorizontalLayout();
    layoutControl.setStyleName("calendarHeader");
    layoutControl.setWidth("100%");
    layoutControl.setHeight("35px");

    HorizontalLayout layoutButtonPrevious = new HorizontalLayout();
    layoutButtonPrevious.setSpacing(true);
    layoutButtonPrevious.addComponent(btnShowPreviousYear);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousYear, Alignment.MIDDLE_LEFT);
    layoutButtonPrevious.addComponent(btnShowPreviousMonth);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousMonth, Alignment.MIDDLE_LEFT);
    layoutControl.addComponent(layoutButtonPrevious);
    layoutControl.setComponentAlignment(layoutButtonPrevious, Alignment.MIDDLE_LEFT);

    layoutControl.addComponent(lbSelectedDate);
    layoutControl.setComponentAlignment(lbSelectedDate, Alignment.MIDDLE_CENTER);

    MHorizontalLayout layoutButtonNext = new MHorizontalLayout();
    layoutButtonNext.addComponent(btnShowNextMonth);
    layoutButtonNext.setComponentAlignment(btnShowNextMonth, Alignment.MIDDLE_RIGHT);
    layoutButtonNext.addComponent(btnShowNextYear);
    layoutButtonNext.setComponentAlignment(btnShowNextYear, Alignment.MIDDLE_RIGHT);
    layoutControl.addComponent(layoutButtonNext);
    layoutControl.setComponentAlignment(layoutButtonNext, Alignment.MIDDLE_RIGHT);

    this.addComponent(layoutControl);
    this.setComponentAlignment(layoutControl, Alignment.TOP_CENTER);

    this.addComponent(styleCalendar);
    this.setExpandRatio(styleCalendar, 1.0f);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.table.CustomizedTableWindow.java

License:Open Source License

public CustomizedTableWindow(final String viewId, final AbstractPagedBeanTable<?, ?> table) {
    super(AppContext.getMessage(GenericI18Enum.OPT_CUSTOMIZE_VIEW));
    this.viewId = viewId;
    this.setWidth("400px");
    this.setResizable(false);
    this.setModal(true);
    this.center();

    this.tableItem = table;
    customViewStoreService = AppContextUtil.getSpringBean(CustomViewStoreService.class);

    final MVerticalLayout contentLayout = new MVerticalLayout();
    this.setContent(contentLayout);

    listBuilder = new ListBuilder();
    listBuilder.setImmediate(true);//from   ww w.  j a va  2  s .  c o  m
    listBuilder.setColumns(0);
    listBuilder.setLeftColumnCaption(AppContext.getMessage(GenericI18Enum.OPT_AVAILABLE_COLUMNS));
    listBuilder.setRightColumnCaption(AppContext.getMessage(GenericI18Enum.OPT_VIEW_COLUMNS));
    listBuilder.setWidth(100, Sizeable.Unit.PERCENTAGE);
    listBuilder.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    final BeanItemContainer<TableViewField> container = new BeanItemContainer<>(TableViewField.class,
            this.getAvailableColumns());
    listBuilder.setContainerDataSource(container);
    Iterator<TableViewField> iterator = getAvailableColumns().iterator();
    while (iterator.hasNext()) {
        TableViewField field = iterator.next();
        listBuilder.setItemCaption(field, AppContext.getMessage(field.getDescKey()));
    }
    this.setSelectedViewColumns();
    contentLayout.with(listBuilder).withAlign(listBuilder, Alignment.TOP_CENTER);

    Button restoreLink = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    List<TableViewField> defaultSelectedColumns = tableItem.getDefaultSelectedColumns();
                    if (defaultSelectedColumns != null) {
                        final List<TableViewField> selectedColumns = new ArrayList<>();
                        final BeanItemContainer<TableViewField> container = (BeanItemContainer<TableViewField>) listBuilder
                                .getContainerDataSource();
                        final Collection<TableViewField> itemIds = container.getItemIds();

                        for (TableViewField column : defaultSelectedColumns) {
                            for (final TableViewField viewField : itemIds) {
                                if (column.getField().equals(viewField.getField())) {
                                    selectedColumns.add(viewField);
                                }
                            }
                        }

                        listBuilder.setValue(selectedColumns);
                    }

                }
            });
    restoreLink.setStyleName(UIConstants.BUTTON_LINK);
    contentLayout.with(restoreLink).withAlign(restoreLink, Alignment.TOP_RIGHT);

    final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @SuppressWarnings("unchecked")
                @Override
                public void buttonClick(final ClickEvent event) {
                    List<TableViewField> selectedColumns = (List<TableViewField>) listBuilder.getValue();
                    table.setDisplayColumns(selectedColumns);
                    // Save custom table view def
                    CustomViewStore viewDef = new CustomViewStore();
                    viewDef.setSaccountid(AppContext.getAccountId());
                    viewDef.setCreateduser(AppContext.getUsername());
                    viewDef.setViewid(viewId);
                    viewDef.setViewinfo(FieldDefAnalyzer.toJson(new ArrayList<>(selectedColumns)));
                    customViewStoreService.saveOrUpdateViewLayoutDef(viewDef);
                    close();
                }
            });
    saveBtn.setStyleName(UIConstants.BUTTON_ACTION);
    saveBtn.setIcon(FontAwesome.SAVE);

    final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    close();
                }
            });
    cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);

    MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, saveBtn);
    contentLayout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT);
}