Example usage for com.vaadin.ui CssLayout setWidth

List of usage examples for com.vaadin.ui CssLayout setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui CssLayout setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.mycollab.module.crm.view.lead.LeadConvertInfoWindow.java

License:Open Source License

public Layout initContent() {
    CssLayout contentLayout = new CssLayout();
    contentLayout.setWidth("100%");
    contentLayout.setStyleName("lead-convert-window");

    contentLayout.addComponent(createBody());
    ComponentContainer buttonControls = createButtonControls();
    if (buttonControls != null) {
        contentLayout.addComponent(buttonControls);
    }//  ww  w  .  jav  a2  s . c  o m

    return contentLayout;
}

From source file:com.mycollab.module.crm.view.opportunity.OpportunityContactListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    MHorizontalLayout controlsBtnWrap = new MHorizontalLayout().withSpacing(false).withFullWidth();

    MHorizontalLayout notesWrap = new MHorizontalLayout(
            new ELabel(UserUIContext.getMessage(GenericI18Enum.OPT_NOTE)).withWidthUndefined()).withFullWidth();

    CssLayout noteBlock = new CssLayout();
    noteBlock.setWidth("100%");
    noteBlock.setStyleName("list-note-block");
    for (OptionI18nEnum.OpportunityContactRole role : CrmDataTypeFactory.getOpportunityContactRoleList()) {
        ELabel note = new ELabel(UserUIContext.getMessage(role))
                .withStyleName("note-label", colormap.get(role.name())).withWidthUndefined()
                .withHeightUndefined();/*  ww w .j  a  va 2  s. c  o  m*/
        noteBlock.addComponent(note);
    }
    notesWrap.with(noteBlock).expand(noteBlock);
    controlsBtnWrap.addComponent(notesWrap);

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_CONTACT)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.setSizeUndefined();
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(ContactI18nEnum.OPT_ADD_EDIT_CONTACT_ROLES));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> EventBusFactory.getInstance()
                .post(new OpportunityEvent.GotoContactRoleEdit(this, opportunity)));
        final Button selectBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT),
                clickEvent -> {
                    OpportunityContactSelectionWindow contactsWindow = new OpportunityContactSelectionWindow(
                            OpportunityContactListComp.this);
                    ContactSearchCriteria criteria = new ContactSearchCriteria();
                    criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
                    UI.getCurrent().addWindow(contactsWindow);
                    contactsWindow.setSearchCriteria(criteria);
                    controlsBtn.setPopupVisible(false);
                });
        selectBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));
        OptionPopupContent buttonControlLayout = new OptionPopupContent();
        buttonControlLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlLayout);

        controlsBtnWrap.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);
    }

    return controlsBtnWrap;
}

From source file:com.mycollab.module.crm.view.setting.CrmSettingContainer.java

License:Open Source License

public CrmSettingContainer() {
    this.setWidth("100%");

    final CssLayout contentWrapper = new CssLayout();
    contentWrapper.setWidth("100%");
    this.addComponent(contentWrapper);

    settingTab = new VerticalTabsheet();
    settingTab.setSizeFull();//from ww  w.j  av a2s . com
    settingTab.setNavigatorWidth("250px");
    settingTab.setNavigatorStyleName("sidebar-menu");
    settingTab.setHeight(null);

    buildComponents();
    contentWrapper.addComponent(settingTab);

}

From source file:com.mycollab.module.project.view.settings.ComponentListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");

    MHorizontalLayout layout = new MHorizontalLayout();
    layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);//from  w w  w.ja v  a 2  s  . c  om

    this.selectOptionButton = new SelectionOptionButton(tableItem);
    layout.addComponent(this.selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();
    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.COMPONENTS)) {
        tableActionControls.addDeleteActionItem();
    }

    tableActionControls.addMailActionItem();
    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    layout.with(tableActionControls, selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel,
            Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

From source file:com.mycollab.module.project.view.settings.ProjectRoleListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");
    MHorizontalLayout layout = new MHorizontalLayout();
    layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);//from  w ww. j a v a 2 s .c o  m

    selectOptionButton = new SelectionOptionButton(this.tableItem);
    layout.addComponent(this.selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();
    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.ROLES)) {
        tableActionControls.addDeleteActionItem();
    }

    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    layout.with(this.tableActionControls, this.selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel,
            Alignment.MIDDLE_LEFT);
    return layoutWrapper;
}

From source file:com.mycollab.module.project.view.settings.ProjectRoleReadViewImpl.java

License:Open Source License

public ProjectRoleReadViewImpl() {
    withMargin(new MarginInfo(true, false, true, false));
    headerText = HeaderWithFontAwesome.h2(FontAwesome.USERS,
            UserUIContext.getMessage(ProjectRoleI18nEnum.DETAIL));
    headerText.setSizeUndefined();/*from  w  w  w . j  a v  a  2 s. c  o m*/
    this.addComponent(constructHeader());

    previewForm = initPreviewForm();
    ComponentContainer actionControls = createButtonControls();

    addHeaderRightContent(actionControls);

    CssLayout contentWrapper = new CssLayout();
    contentWrapper.setWidth("100%");
    contentWrapper.setStyleName(WebThemes.CONTENT_WRAPPER);

    previewLayout = new DefaultReadViewLayout("");
    contentWrapper.addComponent(previewLayout);
    previewLayout.addBody(previewForm);
    this.addComponent(contentWrapper);
}

From source file:com.mycollab.module.project.view.settings.VersionListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");
    MHorizontalLayout layout = new MHorizontalLayout();
    layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);/*  w w  w.  j  a  va 2s .  c o  m*/

    this.selectOptionButton = new SelectionOptionButton(this.tableItem);
    layout.addComponent(this.selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();

    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.VERSIONS)) {
        tableActionControls.addDeleteActionItem();
    }

    tableActionControls.addMailActionItem();
    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    layout.with(tableActionControls, selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel,
            Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

From source file:com.mycollab.module.project.view.user.ProjectActivityStreamPagedList.java

License:Open Source License

@Override
protected void doSearch() {
    totalCount = projectActivityStreamService.getTotalActivityStream(
            ((BasicSearchRequest<ActivityStreamSearchCriteria>) searchRequest).getSearchCriteria());
    totalPage = (totalCount - 1) / searchRequest.getNumberOfItems() + 1;
    if (searchRequest.getCurrentPage() > totalPage) {
        searchRequest.setCurrentPage(totalPage);
    }//from w  w w.  j av a 2  s. com

    if (totalPage > 1) {
        if (controlBarWrapper != null) {
            removeComponent(controlBarWrapper);
        }
        this.addComponent(createPageControls());
    } else {
        if (getComponentCount() == 2) {
            removeComponent(getComponent(1));
        }
    }

    List<ProjectActivityStream> currentListData = projectActivityStreamService
            .getProjectActivityStreams((BasicSearchRequest<ActivityStreamSearchCriteria>) searchRequest);
    this.listContainer.removeAllComponents();
    Date currentDate = new GregorianCalendar(2100, 1, 1).getTime();

    CssLayout currentFeedBlock = new CssLayout();
    AuditLogRegistry auditLogRegistry = AppContextUtil.getSpringBean(AuditLogRegistry.class);

    try {
        for (ProjectActivityStream activityStream : currentListData) {
            if (ProjectTypeConstants.PAGE.equals(activityStream.getType())) {
                ProjectPageService pageService = AppContextUtil.getSpringBean(ProjectPageService.class);
                Page page = pageService.getPage(activityStream.getTypeid(), UserUIContext.getUsername());
                if (page != null) {
                    activityStream.setNamefield(page.getSubject());
                }
            }

            Date itemCreatedDate = activityStream.getCreatedtime();

            if (!DateUtils.isSameDay(currentDate, itemCreatedDate)) {
                currentFeedBlock = new CssLayout();
                currentFeedBlock.setStyleName("feed-block");
                feedBlocksPut(currentDate, itemCreatedDate, currentFeedBlock);
                currentDate = itemCreatedDate;
            }
            StringBuilder content = new StringBuilder();
            String itemType = ProjectLocalizationTypeMap.getType(activityStream.getType());
            String assigneeParam = buildAssigneeValue(activityStream);
            String itemParam = buildItemValue(activityStream);

            if (ActivityStreamConstants.ACTION_CREATE.equals(activityStream.getAction())) {
                content.append(
                        UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_CREATE_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
            } else if (ActivityStreamConstants.ACTION_UPDATE.equals(activityStream.getAction())) {
                content.append(
                        UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_UPDATE_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
                if (activityStream.getAssoAuditLog() != null) {
                    content.append(auditLogRegistry.generatorDetailChangeOfActivity(activityStream));
                }
            } else if (ActivityStreamConstants.ACTION_COMMENT.equals(activityStream.getAction())) {
                content.append(
                        UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_COMMENT_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
                if (activityStream.getAssoAuditLog() != null) {
                    content.append("<p><ul><li>\"").append(
                            StringUtils.trimHtmlTags(activityStream.getAssoAuditLog().getChangeset(), 200))
                            .append("\"</li></ul></p>");
                }
            } else if (ActivityStreamConstants.ACTION_DELETE.equals(activityStream.getAction())) {
                content.append(
                        UserUIContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_DELETE_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
            }
            Label actionLbl = new Label(content.toString(), ContentMode.HTML);
            CssLayout streamWrapper = new CssLayout();
            streamWrapper.setWidth("100%");
            streamWrapper.addStyleName("stream-wrapper");
            streamWrapper.addComponent(actionLbl);
            currentFeedBlock.addComponent(streamWrapper);
        }
    } catch (Exception e) {
        throw new MyCollabException(e);
    }
}

From source file:com.mycollab.module.user.accountsettings.customize.view.LogoEditWindow.java

License:Open Source License

private void editPhoto(byte[] imageData) {
    try {/*w ww  .j a  v a2  s .  c o m*/
        originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
        throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

    MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false))
            .withFullWidth();

    final String logoPath = MyCollabUI.getBillingAccount().getLogopath();
    Resource defaultPhoto = AccountAssetsResolver.createLogoResource(logoPath, 150);
    previewImage = new Embedded(null, defaultPhoto);
    previewImage.setWidth("100px");
    previewBox.addComponent(previewImage);
    previewBox.setComponentAlignment(previewImage, Alignment.TOP_LEFT);

    MVerticalLayout previewBoxRight = new MVerticalLayout().withSpacing(false)
            .withMargin(new MarginInfo(false, true, false, true));

    previewBoxRight
            .addComponent(ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_IMAGE_EDIT_INSTRUCTION)));

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> EventBusFactory.getInstance()
                    .post(new SettingEvent.GotoGeneralSetting(LogoEditWindow.this, null)))
                            .withStyleName(WebThemes.BUTTON_OPTION);

    MButton acceptBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), clickEvent -> {
        if (scaleImageData != null && scaleImageData.length > 0) {
            try {
                BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                AccountLogoService accountLogoService = AppContextUtil.getSpringBean(AccountLogoService.class);
                accountLogoService.upload(UserUIContext.getUsername(), image, MyCollabUI.getAccountId());
                Page.getCurrent().getJavaScript().execute("window.location.reload();");
            } catch (IOException e) {
                throw new MyCollabException("Error when saving account logo", e);
            }
        }
    }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SAVE)
            .withClickShortcut(ShortcutAction.KeyCode.ENTER);

    MHorizontalLayout controlBtns = new MHorizontalLayout(acceptBtn, cancelBtn);
    previewBoxRight.with(controlBtns).withAlign(controlBtns, Alignment.TOP_LEFT);
    previewBox.with(previewBoxRight).expand(previewBoxRight);
    content.addComponent(previewBox);

    CssLayout cropBox = new CssLayout();
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage),
            "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(150 / 28);
    cropField.addValueChangeListener(valueChangeEvent -> {
        VCropSelection newSelection = (VCropSelection) valueChangeEvent.getProperty().getValue();
        int x1 = newSelection.getXTopLeft();
        int y1 = newSelection.getYTopLeft();
        int x2 = newSelection.getXBottomRight();
        int y2 = newSelection.getYBottomRight();
        if (x2 > x1 && y2 > y1) {
            BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            try {
                ImageIO.write(subImage, "png", outStream);
                scaleImageData = outStream.toByteArray();
                displayPreviewImage();
            } catch (IOException e) {
                LOG.error("Error while scale image: ", e);
            }
        }
    });
    currentPhotoBox.setWidth("650px");
    currentPhotoBox.setHeight("650px");
    currentPhotoBox.addComponent(cropField);
    cropBox.addComponent(currentPhotoBox);

    content.with(previewBox, ELabel.hr(), cropBox);
}

From source file:com.mycollab.module.user.ui.components.ImagePreviewCropWindow.java

License:Open Source License

public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) {
    super(UserUIContext.getMessage(ShellI18nEnum.OPT_PREVIEW_EDIT_IMAGE));
    MVerticalLayout content = new MVerticalLayout();
    withModal(true).withResizable(false).withWidth("700px").withCenter().withContent(content);

    try {/* ww w.  ja va2s  .c o  m*/
        originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
        throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

    MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false))
            .withFullWidth();

    previewPhoto = new VerticalLayout();
    previewPhoto.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    previewPhoto.setWidth("100px");

    previewBox.with(previewPhoto).withAlign(previewPhoto, Alignment.TOP_LEFT);

    VerticalLayout previewBoxTitle = new VerticalLayout();
    previewBoxTitle.setMargin(new MarginInfo(false, true, false, true));
    previewBoxTitle
            .addComponent(ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_IMAGE_EDIT_INSTRUCTION)));

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MButton acceptBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), clickEvent -> {
        if (scaleImageData != null && scaleImageData.length > 0) {
            try {
                BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                imageSelectionCommand.process(image);
                close();
            } catch (IOException e) {
                throw new MyCollabException("Error when saving user avatar", e);
            }
        }
    }).withIcon(FontAwesome.CHECK).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout controlBtns = new MHorizontalLayout(acceptBtn, cancelBtn);

    previewBoxTitle.addComponent(controlBtns);
    previewBoxTitle.setComponentAlignment(controlBtns, Alignment.TOP_LEFT);
    previewBox.with(previewBoxTitle).expand(previewBoxTitle);

    CssLayout cropBox = new CssLayout();
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage),
            "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(1.0f);
    cropField.addValueChangeListener(valueChangeEvent -> {
        VCropSelection newSelection = (VCropSelection) valueChangeEvent.getProperty().getValue();
        int x1 = newSelection.getXTopLeft();
        int y1 = newSelection.getYTopLeft();
        int x2 = newSelection.getXBottomRight();
        int y2 = newSelection.getYBottomRight();
        if (x2 > x1 && y2 > y1) {
            BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            try {
                ImageIO.write(subImage, "png", outStream);
                scaleImageData = outStream.toByteArray();
                displayPreviewImage();
            } catch (IOException e) {
                LOG.error("Error while scale image: ", e);
            }
        }
    });
    currentPhotoBox.setWidth("520px");
    currentPhotoBox.setHeight("470px");
    currentPhotoBox.addComponent(cropField);
    cropBox.addComponent(currentPhotoBox);

    content.with(previewBox, ELabel.hr(), cropBox);
    displayPreviewImage();
}