Java Code Examples for com.vaadin.ui.CssLayout#addComponent()

The following examples show how to use com.vaadin.ui.CssLayout#addComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubaTokenList.java    From cuba with Apache License 2.0 6 votes vote down vote up
public CubaTokenList(WebTokenList<T> owner) {
    this.owner = owner;

    composition = new CssLayout();
    composition.setWidthUndefined();
    composition.setStyleName(TOKENLIST_COMPOSITION_STYLENAME);

    tokenContainerWrapper = new CssLayout();
    tokenContainerWrapper.setStyleName(TOKENLIST_WRAPPER_STYLENAME);

    tokenContainer = new CubaScrollBoxLayout();
    tokenContainer.setStyleName(TOKENLIST_SCROLLBOX_STYLENAME);
    tokenContainer.setWidthUndefined();
    tokenContainer.setMargin(new MarginInfo(true, false, false, false));

    tokenContainerWrapper.addComponent(tokenContainer);
    composition.addComponent(tokenContainerWrapper);
    setPrimaryStyleName(TOKENLIST_STYLENAME);

    // do not trigger overridden method
    super.setWidth(-1, Unit.PIXELS);
}
 
Example 2
Source File: CubaFileUploadWrapper.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void initLayout(UploadComponent uploadComponent) {
    this.uploadButton = uploadComponent;

    container = new CssLayout();
    container.addStyleName("c-fileupload-container");

    fileNameButton = new CubaButton();
    fileNameButton.setWidth(100, Unit.PERCENTAGE);
    fileNameButton.addStyleName(ValoTheme.BUTTON_LINK);
    fileNameButton.addStyleName("c-fileupload-filename");
    setFileNameButtonCaption(null);
    container.addComponent(fileNameButton);

    container.addComponent(uploadComponent);

    clearButton = new CubaButton("");
    clearButton.setStyleName("c-fileupload-clear");
    container.addComponent(clearButton);
    setShowClearButton(showClearButton);

    setShowFileName(false);
    setWidthUndefined();
}
 
Example 3
Source File: WebFtsField.java    From cuba with Apache License 2.0 6 votes vote down vote up
public WebFtsField() {
    component = new CssLayout();
    component.setPrimaryStyleName(FTS_FIELD_STYLENAME);

    searchField = new CubaTextField();
    searchField.setStyleName("c-ftsfield-text");
    searchField.addShortcutListener(
            new ShortcutListenerDelegate("fts", KeyCode.ENTER, null)
                    .withHandler((sender, target) ->
                            openSearchWindow()
                    ));

    searchBtn = new CubaButton();
    searchBtn.setStyleName("c-ftsfield-button");
    searchBtn.addClickListener(event ->
            openSearchWindow()
    );

    component.addComponent(searchField);
    component.addComponent(searchBtn);

    adjustHeight();
    adjustWidth();
}
 
Example 4
Source File: CubaCurrencyField.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void initLayout() {
    container = new CssLayout();
    container.setSizeFull();
    container.setPrimaryStyleName(CURRENCYFIELD_LAYOUT_STYLENAME);

    container.addComponent(currencyLabel);

    if (useWrapper()) {
        ie9InputWrapper = new CssLayout(textField);
        ie9InputWrapper.setSizeFull();
        ie9InputWrapper.setPrimaryStyleName(IE9_INPUT_WRAP_STYLENAME);

        container.addComponent(ie9InputWrapper);
    } else {
        container.addComponent(textField);
    }

    setFocusDelegate(textField);
}
 
Example 5
Source File: RowUtil.java    From cia with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the row component.
 *
 * @param row         the row
 * @param component   the component
 * @param description the description
 */
public static void createRowComponent(final ResponsiveRow row, final Component component,
		final String description) {
	final CssLayout layout = new CssLayout();
	layout.addStyleName(".v-layout-content-pagemode-panel-level2");
	Responsive.makeResponsive(layout);
	layout.setSizeUndefined();

	final Label descriptionLabel = new Label(description);
	descriptionLabel.addStyleName(ITEMBOX);
	Responsive.makeResponsive(descriptionLabel);
	descriptionLabel.setWidth(100, Unit.PERCENTAGE);
	layout.addComponent(descriptionLabel);

	component.addStyleName(ITEMBOX);
	component.addStyleName(TITLE);
	Responsive.makeResponsive(component);
	component.setWidth(100, Unit.PERCENTAGE);
	layout.addComponent(component);

	row.addColumn().withDisplayRules(DISPLAY_SIZE_XS_DEVICE, DISPLAYS_SIZE_XM_DEVICE, DISPLAY_SIZE_MD_DEVICE,
			DISPLAY_SIZE_LG_DEVICE).withComponent(layout);
}
 
Example 6
Source File: RowUtil.java    From cia with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the row item.
 *
 * @param row         the row
 * @param button      the button
 * @param description the description
 */
public static void createRowItem(final ResponsiveRow row, final Button button, final String description) {
	final CssLayout layout = new CssLayout();
	layout.addStyleName("v-layout-content-overview-panel-level2");
	Responsive.makeResponsive(layout);
	layout.setSizeUndefined();

	button.addStyleName(ITEMBOX);
	button.addStyleName(TITLE);
	Responsive.makeResponsive(button);
	button.setWidth(100, Unit.PERCENTAGE);
	layout.addComponent(button);

	final Label descriptionLabel = new Label(description);
	descriptionLabel.addStyleName(ITEMBOX);
	Responsive.makeResponsive(descriptionLabel);
	descriptionLabel.setWidth(100, Unit.PERCENTAGE);
	layout.addComponent(descriptionLabel);

	row.addColumn().withDisplayRules(DISPLAY_SIZE_XS_DEVICE, DISPLAYS_SIZE_XM_DEVICE, DISPLAY_SIZE_MD_DEVICE,
			DISPLAY_SIZE_LG_DEVICE).withComponent(layout);
}
 
Example 7
Source File: GenericChartWrapper.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
final protected void displayChart() {
    removeAllComponents();
    final JFreeChart chart = createChart();
    final JFreeChartWrapper chartWrapper = new JFreeChartWrapper(chart);

    final CssLayout borderWrap = new CssLayout();
    borderWrap.addComponent(chartWrapper);
    borderWrap.setStyleName("chart-wrapper");
    borderWrap.setHeight(height + "px");
    borderWrap.setWidth(width + "px");
    chartWrapper.setHeight(height + "px");
    chartWrapper.setWidth(width + "px");
    chartWrapper.setGraphHeight(height);
    chartWrapper.setGraphWidth(width);
    this.addComponent(borderWrap);
    final Component legendBox = createLegendBox();
    if (legendBox != null) {
        this.addComponent(legendBox);
    }
}
 
Example 8
Source File: ProjectSubscribersComp.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected Component initContent() {
    ProjectMemberService projectMemberService = AppContextUtil.getSpringBean(ProjectMemberService.class);
    List<SimpleUser> members = projectMemberService.getActiveUsersInProject(projectId, AppUI.getAccountId());
    CssLayout container = new CssLayout();
    container.setStyleName("followers-container");
    final CheckBox selectAllCheckbox = new CheckBox("All", defaultSelectAll);
    selectAllCheckbox.addValueChangeListener(valueChangeEvent -> {
        boolean val = selectAllCheckbox.getValue();
        for (FollowerCheckbox followerCheckbox : memberSelections) {
            followerCheckbox.setValue(val);
        }
    });
    container.addComponent(selectAllCheckbox);
    for (SimpleUser user : members) {
        final FollowerCheckbox memberCheckbox = new FollowerCheckbox(user);
        memberCheckbox.addValueChangeListener(valueChangeEvent -> {
            if (!memberCheckbox.getValue()) {
                selectAllCheckbox.setValue(false);
            }
        });
        if (defaultSelectAll || selectedUsers.contains(user.getUsername())) {
            memberCheckbox.setValue(true);
        }
        memberSelections.add(memberCheckbox);
        container.addComponent(memberCheckbox);
    }
    return container;
}
 
Example 9
Source File: ProjectMembersWidget.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Component generateRow(IBeanList<SimpleProjectMember> host, SimpleProjectMember member, int rowIndex) {
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withStyleName("list-row");
    Image userAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(), 48);
    userAvatar.addStyleName(WebThemes.CIRCLE_BOX);
    layout.addComponent(userAvatar);

    MVerticalLayout content = new MVerticalLayout().withMargin(false);
    content.addComponent(ELabel.html(buildAssigneeValue(member)).withStyleName(WebThemes.TEXT_ELLIPSIS));
    layout.with(content).expand(content);

    CssLayout footer = new CssLayout();

    String roleVal = member.getRoleName() + "&nbsp;&nbsp;";
    ELabel memberRole = ELabel.html(roleVal).withDescription(UserUIContext.getMessage(ProjectRoleI18nEnum.SINGLE))
            .withStyleName(WebThemes.META_INFO);
    footer.addComponent(memberRole);

    String memberWorksInfo = ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml() +
            new Span().appendText("" + member.getNumOpenTasks()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_TASKS)) +
            "&nbsp;&nbsp;" +
            ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG).getHtml() +
            new Span().appendText("" + member.getNumOpenBugs()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_BUGS)) + "&nbsp;&nbsp;"
            + VaadinIcons.MONEY.getHtml() + "&nbsp;" + new Span().appendText("" + NumberUtils.roundDouble(2,
            member.getTotalBillableLogTime())).setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) + "&nbsp;&nbsp;" +
            VaadinIcons.GIFT.getHtml() + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime()))
            .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS));

    ELabel memberWorkStatus = ELabel.html(memberWorksInfo).withStyleName(WebThemes.META_INFO);
    footer.addComponent(memberWorkStatus);

    content.addComponent(footer);
    return layout;
}
 
Example 10
Source File: ProjectSearchItemPresenter.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void onGo(HasComponents container, ScreenData<?> data) {
    BoardContainer boardContainer = (BoardContainer) container;
    CssLayout contentWrapper = boardContainer.getContentWrapper();
    contentWrapper.removeAllComponents();
    contentWrapper.addComponent(view);

    String params = (String) data.getParams();
    view.displayResults(params);
}
 
Example 11
Source File: EditableTicketRowRenderer.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public EditableTicketRowRenderer(ProjectTicket ticket) {
    this.ticket = ticket;
    withMargin(false).withFullWidth().addStyleName(WebThemes.BORDER_LIST_ROW);

    if (ticket.isTask()) {
        addStyleName("task");
    } else if (ticket.isBug()) {
        addStyleName("bug");
    } else if (ticket.isRisk()) {
        addStyleName("risk");
    }

    toggleTicketField = new ToggleTicketSummaryField(ticket);
    MHorizontalLayout headerLayout = new MHorizontalLayout(ELabel.fontIcon(ProjectAssetsManager.getAsset(ticket.getType()))
            .withUndefinedWidth(), toggleTicketField).expand(toggleTicketField).withFullWidth()
            .withMargin(new MarginInfo(false, true, false, false));

    TicketComponentFactory popupFieldFactory = AppContextUtil.getSpringBean(TicketComponentFactory.class);
    AbstractComponent assigneeField = wrapListenerComponent(popupFieldFactory.createAssigneePopupField(ticket));
    assigneeField.removeStyleName(WebThemes.BLOCK_POPUP_EDIT);
    headerLayout.with(assigneeField, toggleTicketField).expand(toggleTicketField);

    CssLayout footer = new CssLayout();
    footer.addComponent(popupFieldFactory.createCommentsPopupField(ticket));
    footer.addComponent(wrapListenerComponent(popupFieldFactory.createPriorityPopupField(ticket)));
    footer.addComponent(popupFieldFactory.createFollowersPopupField(ticket));
    footer.addComponent(wrapListenerComponent(popupFieldFactory.createStatusPopupField(ticket)));
    footer.addComponent(wrapListenerComponent(popupFieldFactory.createStartDatePopupField(ticket)));
    footer.addComponent(wrapListenerComponent(popupFieldFactory.createEndDatePopupField(ticket)));
    footer.addComponent(wrapListenerComponent(popupFieldFactory.createDueDatePopupField(ticket)));
    if (!SiteConfiguration.isCommunityEdition()) {
        footer.addComponent(popupFieldFactory.createBillableHoursPopupField(ticket));
        footer.addComponent(popupFieldFactory.createNonBillableHoursPopupField(ticket));
    }
    this.with(headerLayout, footer);
}
 
Example 12
Source File: HiddenAdminViewImpl.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 5 votes vote down vote up
@Override
public void postConstruct() {	
	super.postConstruct();
	setSizeFull();
	layout = new CssLayout();
	layout.setSizeFull();
	setCompositionRoot(layout);
	
	
	final Label label = new Label("This is admin only view. Navbar link is was hidden.");
	label.addStyleName(ValoTheme.LABEL_H2);
	layout.addComponent(label);		
	
}
 
Example 13
Source File: AdminViewImpl.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 5 votes vote down vote up
@Override
public void postConstruct() {	
	super.postConstruct();
	setSizeFull();
	layout = new CssLayout();
	layout.setSizeFull();
	setCompositionRoot(layout);
	
	
	final Label label = new Label("This is admin only view");
	label.addStyleName(ValoTheme.LABEL_H2);
	layout.addComponent(label);		
	
}
 
Example 14
Source File: AbstractMenuItemFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the button link.
 *
 * @param row
 *            the panel content
 * @param linkText
 *            the link text
 * @param icon
 *            the icon
 * @param command
 *            the command
 * @param description
 *            the description
 */
protected final void createButtonLink(final ResponsiveRow row,final String linkText,final Resource icon, final ClickListener command, final String description) {
	final CssLayout layout = new CssLayout();
	layout.addStyleName("v-layout-content-overview-panel-level2");
	Responsive.makeResponsive(layout);
	layout.setSizeUndefined();


	final Button button = new Button(linkText);
	Responsive.makeResponsive(button);
	button.setStyleName(LINK_STYLE_NAME);
	button.addStyleName("title");
	button.addClickListener(command);
	button.setIcon(icon);
	button.setWidth(100, Unit.PERCENTAGE);


	layout.addComponent(button);

	final Label descriptionLabel = new Label(description);
	descriptionLabel.addStyleName("itembox");
	Responsive.makeResponsive(descriptionLabel);
	descriptionLabel.setWidth(100, Unit.PERCENTAGE);
	layout.addComponent(descriptionLabel);

	row.addColumn().withDisplayRules(DISPLAY_SIZE_XS_DEVICE,DISPLAYS_SIZE_XM_DEVICE,DISPLAY_SIZE_MD_DEVICE,DISPLAY_SIZE_LG_DEVICE).withComponent(layout);
}
 
Example 15
Source File: DashboardMenu.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the wrapper which contains the menu item and the adjacent label
 * for displaying the occurred events
 * 
 * @param menuItemButton
 *            the menu item
 * @param notificationLabel
 *            the label for displaying the occurred events
 * @return Component of type CssLayout
 */
private static Component buildLabelWrapper(final ValoMenuItemButton menuItemButton,
        final Component notificationLabel) {
    final CssLayout dashboardWrapper = new CssLayout(menuItemButton);
    dashboardWrapper.addStyleName("labelwrapper");
    dashboardWrapper.addStyleName(ValoTheme.MENU_ITEM);
    notificationLabel.addStyleName(ValoTheme.MENU_BADGE);
    notificationLabel.setWidthUndefined();
    notificationLabel.setVisible(false);
    notificationLabel.setId(UIComponentIdProvider.NOTIFICATION_MENU_ID + menuItemButton.getCaption().toLowerCase());
    dashboardWrapper.addComponent(notificationLabel);
    return dashboardWrapper;
}
 
Example 16
Source File: LoginView.java    From gazpachoquest with GNU General Public License v3.0 4 votes vote down vote up
protected CssLayout createCompositionRoot() {
    CssLayout root = new CssLayout();
    root.setSizeFull();
    root.addStyleName(Reindeer.LAYOUT_BLUE);

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSizeFull();
    loginLayout.addStyleName("login-layout");
    root.addComponent(loginLayout);

    final CssLayout loginPanel = new CssLayout();
    loginPanel.addStyleName("login-panel");
    loginLayout.addComponent(loginPanel);

    HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth("100%");
    labels.setMargin(true);
    labels.addStyleName("labels");
    loginPanel.addComponent(labels);

    Label welcome = new Label("Welcome");
    welcome.setSizeUndefined();
    welcome.addStyleName(Reindeer.LABEL_H2);
    labels.addComponent(welcome);
    labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT);

    Label title = new Label("Gazpacho Quest");
    title.setSizeUndefined();
    title.addStyleName(Reindeer.LABEL_H1);
    labels.addComponent(title);
    labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);

    HorizontalLayout fields = new HorizontalLayout();

    fields.setWidth("100%");
    fields.setSpacing(true);
    fields.setMargin(true);
    fields.addStyleName("fields");

    invitation = new TextField("Invitation");
    invitation.setSizeUndefined();
    invitation.focus();
    // invitation.setValue("YAS5ICHRBE");
    fields.addComponent(invitation);

    login = new Button("Start");
    login.addClickListener(createLoginButtonListener());
    fields.addComponent(login);
    fields.setComponentAlignment(login, Alignment.BOTTOM_LEFT);

    loginPanel.addComponent(fields);

    return root;
}
 
Example 17
Source File: WinServerEdit.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void attach() {
    setHeight(TAB_HEIGHT);
    setMargin(false, true, false, true);
    setSpacing(false);

    Form form = new Form();
    form.setSizeFull();
    form.addStyleName("win-server-edit-form");

    // サーバ名
    serverNameField = new TextField(ViewProperties.getCaption("field.serverName"));
    form.getLayout().addComponent(serverNameField);

    // ホスト名
    hostNameField = new TextField(ViewProperties.getCaption("field.hostName"));
    hostNameField.setWidth("100%");
    form.getLayout().addComponent(hostNameField);

    // コメント
    commentField = new TextField(ViewProperties.getCaption("field.comment"));
    commentField.setWidth("100%");
    form.getLayout().addComponent(commentField);

    // プラットフォーム
    CssLayout cloudLayout = new CssLayout();
    cloudLayout.setWidth("100%");
    cloudLayout.setCaption(ViewProperties.getCaption("field.cloud"));
    cloudLabel = new Label();
    cloudLayout.addComponent(cloudLabel);
    form.getLayout().addComponent(cloudLayout);

    // サーバ種別
    CssLayout imageLayout = new CssLayout();
    imageLayout.setWidth("100%");
    imageLayout.setCaption(ViewProperties.getCaption("field.image"));
    imageLabel = new Label();
    imageLayout.addComponent(imageLabel);
    form.getLayout().addComponent(imageLayout);

    // OS
    CssLayout osLayout = new CssLayout();
    osLayout.setWidth("100%");
    osLayout.setCaption(ViewProperties.getCaption("field.os"));
    osLabel = new Label();
    osLayout.addComponent(osLabel);
    form.getLayout().addComponent(osLayout);

    // ロードバランサでない場合
    if (BooleanUtils.isNotTrue(instance.getInstance().getLoadBalancer())) {
        // サービスを有効にするかどうか
        String enableService = Config.getProperty("ui.enableService");

        // サービスを有効にする場合
        if (StringUtils.isEmpty(enableService) || BooleanUtils.toBoolean(enableService)) {
            // 利用可能サービス
            Panel panel = new Panel();
            serviceTable = new AvailableServiceTable();
            panel.addComponent(serviceTable);
            form.getLayout().addComponent(panel);
            panel.setSizeFull();

            // サービス選択ボタン
            Button attachServiceButton = new Button(ViewProperties.getCaption("button.serverAttachService"));
            attachServiceButton.setDescription(ViewProperties.getCaption("description.serverAttachService"));
            attachServiceButton.setIcon(Icons.SERVICETAB.resource());
            attachServiceButton.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    attachServiceButtonClick(event);
                }
            });

            HorizontalLayout layout = new HorizontalLayout();
            layout.setSpacing(true);
            layout.addComponent(attachServiceButton);
            Label label = new Label(ViewProperties.getCaption("label.serverAttachService"));
            layout.addComponent(label);
            layout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
            form.getLayout().addComponent(layout);
        }
    }

    addComponent(form);
}
 
Example 18
Source File: MyCloudAdd.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void attach() {
    // myCloud名
    cloudNameField = new TextField(ViewProperties.getCaption("field.cloudName"));
    getLayout().addComponent(cloudNameField);

    // コメント
    commentField = new TextField(ViewProperties.getCaption("field.comment"));
    commentField.setWidth("100%");
    getLayout().addComponent(commentField);

    // テンプレート選択テーブル
    templateTable = new SelectTemplateTable();
    getLayout().addComponent(templateTable);

    // テンプレート説明欄
    final Label nameLabel = new Label();
    final Label descriptionLabel = new Label();

    Panel descriptionPanel = new Panel();
    CssLayout layout = new CssLayout();
    layout.addStyleName("template-desc");
    descriptionPanel.setHeight("80px");
    descriptionPanel.setContent(layout);
    layout.setSizeFull();
    layout.addComponent(nameLabel);
    layout.addComponent(descriptionLabel);
    getLayout().addComponent(descriptionPanel);

    templateTable.addListener(new ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (templateTable.getValue() == null) {
                return;
            }

            TemplateDto template = findTemplate(templateTable.getValue());
            nameLabel.setValue(template.getTemplate().getTemplateNameDisp() + ":");
            descriptionLabel.setValue(template.getTemplate().getTemplateDescriptionDisp());
        }
    });

    cloudNameField.focus();

    initValidation();
}
 
Example 19
Source File: PieChartWrapper.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected final ComponentContainer createLegendBox() {
    final CssLayout mainLayout = new CssLayout();
    mainLayout.addStyleName("legend-box");
    mainLayout.setSizeUndefined();
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true))
                .withStyleName("inline-block").withUndefinedWidth();
        layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

        final Comparable key = (Comparable) keys.get(i);
        int colorIndex = i % CHART_COLOR_STR.size();
        final String color = "<div style = \" width:13px;height:13px;background: #"
                + CHART_COLOR_STR.get(colorIndex) + "\" />";
        final ELabel lblCircle = ELabel.html(color);

        String btnCaption;
        if (enumKeyCls == null) {
            if (key instanceof Key) {
                btnCaption = String.format("%s (%d)", StringUtils.trim(((Key) key).getDisplayName(), 20, true),
                        pieDataSet.getValue(key).intValue());
            } else {
                btnCaption = String.format("%s (%d)", key, pieDataSet.getValue(key).intValue());
            }
        } else {
            btnCaption = String.format("%s(%d)", UserUIContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        MButton btnLink = new MButton(StringUtils.trim(btnCaption, 25, true), clickEvent -> {
            if (key instanceof Key) {
                clickLegendItem(((Key) key).getKey());
            } else {
                clickLegendItem(key.toString());
            }
        }).withStyleName(WebThemes.BUTTON_LINK).withDescription(btnCaption);

        layout.with(lblCircle, btnLink);
        mainLayout.addComponent(layout);
    }
    mainLayout.setWidth("100%");
    return mainLayout;
}
 
Example 20
Source File: FileDownloadWindow.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    CssLayout iconWrapper = new CssLayout();
    final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName()));
    iconEmbed.addStyleName("icon-48px");
    iconWrapper.addComponent(iconEmbed);
    layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper infoLayout = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.ONE_COLUMN);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {
            descLbl.setValue("&nbsp;");
            descLbl.setContentMode(ContentMode.HTML);
        }
        infoLayout.addComponent(descLbl, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(), AppUI.getAccountId());
    if (user == null) {
        infoLayout.addComponent(new UserLink(UserUIContext.getUsername(), UserUIContext.getUserAvatarId(),
                UserUIContext.getUserDisplayName()), UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    } else {
        infoLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()),
                UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    }

    final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize()));
    infoLayout.addComponent(size, UserUIContext.getMessage(FileI18nEnum.OPT_SIZE), 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(DateTimeUtils.toLocalDateTime(content.getCreated()));
    infoLayout.addComponent(dateCreate, UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME), 0, 3);

    layout.addComponent(infoLayout.getLayout());

    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withIcon(VaadinIcons.DOWNLOAD).withStyleName(WebThemes.BUTTON_ACTION);
    List<Resource> resources = new ArrayList<>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close())
            .withStyleName(WebThemes.BUTTON_OPTION);
    MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, downloadBtn);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
    this.setContent(layout);
}