Example usage for com.vaadin.ui GridLayout setDefaultComponentAlignment

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

Introduction

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

Prototype

@Override
    public void setDefaultComponentAlignment(Alignment defaultAlignment) 

Source Link

Usage

From source file:com.esofthead.mycollab.mobile.module.project.view.ProjectDashboardViewImpl.java

License:Open Source License

@Override
public void displayDashboard() {
    mainLayout.removeAllComponents();//from  w  w  w .  j av a  2  s.co m
    SimpleProject currentProject = CurrentProjectVariables.getProject();
    VerticalLayout projectInfo = new VerticalLayout();
    projectInfo.setStyleName("project-info-layout");
    projectInfo.setWidth("100%");
    projectInfo.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Label projectIcon = new Label("<span aria-hidden=\"true\" data-icon=\"&#xe614\"></span>");
    projectIcon.setStyleName("project-icon");
    projectIcon.setContentMode(ContentMode.HTML);
    projectIcon.setWidthUndefined();
    projectInfo.addComponent(projectIcon);

    Label projectName = new Label(StringUtils.trim(currentProject.getName(), 50, true));
    projectName.setWidth("100%");
    projectName.setStyleName("project-name");
    projectInfo.addComponent(projectName);

    GridLayout projectModulesList = new GridLayout(2, 3);
    projectModulesList.setStyleName("project-modules-layout");
    projectModulesList.setWidth("100%");
    projectModulesList.setSpacing(true);
    projectModulesList.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_MESSAGE), "&#xf04f;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_MILESTONE), "&#xf075;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TASK), "&#xe60f;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_BUG), "&#xf188;"));

    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_FILE), "&#xf017;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_RISK), "&#xf02d;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_PROBLEM), "&#xf0d2;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_TIME), "&#xe612;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_STANDAUP), "&#xf0c0;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_USERS), "&#xe601;"), 0, 2,
            1, 2);

    mainLayout.addComponent(projectInfo);
    mainLayout.addComponent(projectModulesList);
}

From source file:com.esofthead.mycollab.module.project.view.TimeTrackingSummaryViewImpl.java

License:Open Source License

@Override
public void display() {
    projects = ApplicationContextUtil.getSpringBean(ProjectService.class)
            .getProjectsUserInvolved(AppContext.getUsername(), AppContext.getAccountId());
    if (CollectionUtils.isNotEmpty(projects)) {
        itemTimeLoggingService = ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class);

        final CssLayout headerWrapper = new CssLayout();
        headerWrapper.setWidth("100%");
        headerWrapper.setStyleName("projectfeed-hdr-wrapper");

        HorizontalLayout loggingPanel = new HorizontalLayout();

        HorizontalLayout controlBtns = new HorizontalLayout();
        controlBtns.setMargin(new MarginInfo(true, false, true, false));

        final Label layoutHeader = new Label(
                ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME).getHtml() + " Time Tracking",
                ContentMode.HTML);
        layoutHeader.addStyleName("h2");

        final MHorizontalLayout header = new MHorizontalLayout().withWidth("100%");
        header.with(layoutHeader).withAlign(layoutHeader, Alignment.MIDDLE_LEFT).expand(layoutHeader);

        final CssLayout contentWrapper = new CssLayout();
        contentWrapper.setWidth("100%");
        contentWrapper.addStyleName(UIConstants.CONTENT_WRAPPER);

        headerWrapper.addComponent(header);
        this.addComponent(headerWrapper);
        contentWrapper.addComponent(controlBtns);

        MHorizontalLayout controlsPanel = new MHorizontalLayout().withWidth("100%");

        contentWrapper.addComponent(controlsPanel);
        contentWrapper.addComponent(loggingPanel);
        this.addComponent(contentWrapper);

        final Button backBtn = new Button("Back to Workboard");
        backBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override/*from   ww  w.ja  v  a2s.  com*/
            public void buttonClick(final ClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null));

            }
        });

        backBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        backBtn.setIcon(FontAwesome.ARROW_LEFT);

        controlBtns.addComponent(backBtn);

        VerticalLayout selectionLayoutWrapper = new VerticalLayout();
        selectionLayoutWrapper.setWidth("100%");
        selectionLayoutWrapper.addStyleName("time-tracking-summary-search-panel");
        controlsPanel.addComponent(selectionLayoutWrapper);

        final GridLayout selectionLayout = new GridLayout(9, 2);
        selectionLayout.setSpacing(true);
        selectionLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        selectionLayout.setMargin(true);
        selectionLayoutWrapper.addComponent(selectionLayout);

        Label fromLb = new Label("From:");
        fromLb.setWidthUndefined();
        selectionLayout.addComponent(fromLb, 0, 0);

        this.fromDateField = new PopupDateFieldExt();
        this.fromDateField.setResolution(Resolution.DAY);
        this.fromDateField.setDateFormat(AppContext.getUserDateFormat());
        this.fromDateField.setWidth("100px");
        selectionLayout.addComponent(this.fromDateField, 1, 0);

        Label toLb = new Label("To:");
        toLb.setWidthUndefined();
        selectionLayout.addComponent(toLb, 2, 0);

        this.toDateField = new PopupDateFieldExt();
        this.toDateField.setResolution(Resolution.DAY);
        this.toDateField.setDateFormat(AppContext.getUserDateFormat());
        this.toDateField.setWidth("100px");
        selectionLayout.addComponent(this.toDateField, 3, 0);

        Label groupLb = new Label("Group:");
        groupLb.setWidthUndefined();
        selectionLayout.addComponent(groupLb, 0, 1);

        this.groupField = new ValueComboBox(false, GROUPBY_PROJECT, GROUPBY_DATE, GROUPBY_USER);
        this.groupField.setWidth("100px");
        selectionLayout.addComponent(this.groupField, 1, 1);

        Label sortLb = new Label("Sort:");
        sortLb.setWidthUndefined();
        selectionLayout.addComponent(sortLb, 2, 1);

        this.orderField = new ItemOrderComboBox();
        this.orderField.setWidth("100px");
        selectionLayout.addComponent(this.orderField, 3, 1);

        Label projectLb = new Label("Project:");
        projectLb.setWidthUndefined();
        selectionLayout.addComponent(projectLb, 4, 0);

        this.projectField = new UserInvolvedProjectsListSelect();
        initListSelectStyle(this.projectField);
        selectionLayout.addComponent(this.projectField, 5, 0, 5, 1);

        Label userLb = new Label("User:");
        userLb.setWidthUndefined();
        selectionLayout.addComponent(userLb, 6, 0);

        this.userField = new UserInvolvedProjectsMemberListSelect(getProjectIds());
        initListSelectStyle(this.userField);
        selectionLayout.addComponent(this.userField, 7, 0, 7, 1);

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

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        fromDate = fromDateField.getValue();
                        toDate = toDateField.getValue();
                        searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate));
                        searchTimeReporting();
                    }
                });
        queryBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

        selectionLayout.addComponent(queryBtn, 8, 0);

        loggingPanel.setWidth("100%");
        loggingPanel.setHeight("80px");
        loggingPanel.setSpacing(true);

        totalHoursLoggingLabel = new Label("Total Hours Logging: 0 Hrs", ContentMode.HTML);
        totalHoursLoggingLabel.addStyleName(UIConstants.LAYOUT_LOG);
        totalHoursLoggingLabel.addStyleName(UIConstants.TEXT_LOG_DATE_FULL);
        loggingPanel.addComponent(totalHoursLoggingLabel);
        loggingPanel.setExpandRatio(totalHoursLoggingLabel, 1.0f);
        loggingPanel.setComponentAlignment(totalHoursLoggingLabel, Alignment.MIDDLE_LEFT);

        Button exportBtn = new Button("Export", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                exportButtonControl.setPopupVisible(true);

            }
        });
        exportButtonControl = new SplitButton(exportBtn);
        exportButtonControl.setWidthUndefined();
        exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK);
        exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);

        VerticalLayout popupButtonsControl = new VerticalLayout();
        exportButtonControl.setContent(popupButtonsControl);

        Button exportPdfBtn = new Button("Pdf");
        FileDownloader pdfDownloader = new FileDownloader(constructStreamResource(ReportExportType.PDF));
        pdfDownloader.extend(exportPdfBtn);
        exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
        exportPdfBtn.setStyleName("link");
        popupButtonsControl.addComponent(exportPdfBtn);

        Button exportExcelBtn = new Button("Excel");
        FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL));
        excelDownloader.extend(exportExcelBtn);
        exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
        exportExcelBtn.setStyleName("link");
        popupButtonsControl.addComponent(exportExcelBtn);

        controlBtns.addComponent(exportButtonControl);
        controlBtns.setComponentAlignment(exportButtonControl, Alignment.TOP_RIGHT);
        controlBtns.setComponentAlignment(backBtn, Alignment.TOP_LEFT);
        controlBtns.setSizeFull();

        this.timeTrackingWrapper = new VerticalLayout();
        this.timeTrackingWrapper.setWidth("100%");
        contentWrapper.addComponent(this.timeTrackingWrapper);

        Calendar date = new GregorianCalendar();
        date.set(Calendar.DAY_OF_MONTH, 1);

        fromDate = date.getTime();
        date.add(Calendar.DAY_OF_MONTH, date.getActualMaximum(Calendar.DAY_OF_MONTH));
        toDate = date.getTime();

        fromDateField.setValue(fromDate);
        toDateField.setValue(toDate);

        searchCriteria = new ItemTimeLoggingSearchCriteria();

        searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate));
    } else {
        final Button backBtn = new Button("Back to Workboard");
        backBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null));

            }
        });

        backBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        backBtn.setIcon(FontAwesome.ARROW_LEFT);

        VerticalLayout contentWrapper = new VerticalLayout();
        contentWrapper.setSpacing(true);

        Label infoLbl = new Label("You are not involved in any project yet to track time working");
        infoLbl.setWidthUndefined();
        contentWrapper.setMargin(true);
        contentWrapper.addComponent(infoLbl);
        contentWrapper.setComponentAlignment(infoLbl, Alignment.MIDDLE_CENTER);

        contentWrapper.addComponent(backBtn);
        contentWrapper.setComponentAlignment(backBtn, Alignment.MIDDLE_CENTER);
        this.addComponent(contentWrapper);
        this.setComponentAlignment(contentWrapper, Alignment.MIDDLE_CENTER);
    }
}

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);/*  w ww. j  a  v  a2s  .c  o  m*/
    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.spinkit.demo.DemoUI.java

License:Apache License

private Component spinnersContainer(String primaryStyleName) {
    int types = SpinnerType.values().length;
    GridLayout spinners = new GridLayout(4, (types / 4 + types % 4));
    spinners.setSizeFull();/*from  ww  w  .  ja v  a2s .  co m*/
    spinners.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    spinners.setSpacing(true);
    spinners.setWidth(100, Unit.PERCENTAGE);
    StringToEnumConverter converter = new StringToEnumConverter();
    for (SpinnerType type : SpinnerType.values()) {
        Spinner spinner = new Spinner(type);
        spinner.setCaption(converter.convertToPresentation(type, String.class, getLocale()));
        if (primaryStyleName != null) {
            spinner.setPrimaryStyleName(primaryStyleName);
        }
        spinners.addComponent(spinner);
    }
    return spinners;
}

From source file:org.vaadin.spinkit.demo.DemoUI.java

License:Apache License

private Component spinnerSizesContainer() {
    int types = SpinnerSize.values().length;
    GridLayout spinners = new GridLayout(4, (types / 4 + types % 4));
    spinners.setSizeFull();//  www .  j a v  a  2  s. c  o  m
    spinners.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    spinners.setSpacing(true);

    ComboBox selector = new ComboBox("Select spinner type", Arrays.asList(SpinnerType.values()));
    selector.setNullSelectionAllowed(false);
    selector.setPageLength(0);
    selector.setValue(SpinnerType.ROTATING_PLANE);
    selector.addValueChangeListener(e -> {
        for (Component c : spinners) {
            if (c instanceof Spinner) {
                ((Spinner) c).setType((SpinnerType) selector.getValue());
            }
        }
    });

    StringToEnumConverter converter = new StringToEnumConverter();
    for (SpinnerSize size : SpinnerSize.values()) {
        Spinner spinner = new Spinner(SpinnerType.ROTATING_PLANE);
        spinner.setSize(size);
        spinner.setCaption(converter.convertToPresentation(size, String.class, getLocale()));
        spinners.addComponent(spinner);
    }

    VerticalLayout l = new VerticalLayout();
    l.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    l.setSizeFull();
    l.setMargin(false);
    l.setSpacing(true);
    l.addComponents(selector, spinners);
    l.setExpandRatio(spinners, 1);
    return l;
}