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

The following examples show how to use com.vaadin.ui.CssLayout#setWidth() . 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: 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 2
Source File: BlockWidget.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public BlockWidget(String title) {
    titleLbl = ELabel.h2("");
    super.addComponent(titleLbl);

    bodyLayout = new CssLayout();
    bodyLayout.setWidth("100%");
    super.addComponent(bodyLayout);
    this.setTitle(title);
}
 
Example 3
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 4
Source File: LoadBalancerPanel.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void attach() {
    setSizeFull();
    addStyleName(Reindeer.PANEL_LIGHT);

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setSizeFull();
    layout.addStyleName("loadbalancer-tab");
    layout.setSpacing(false);
    layout.setMargin(false);

    // スプリットパネル
    SplitPanel splitPanel = new SplitPanel();
    splitPanel.setOrientation(SplitPanel.ORIENTATION_VERTICAL);
    splitPanel.setSplitPosition(40);
    splitPanel.setSizeFull();
    layout.addComponent(splitPanel);

    // スプリットパネル上段
    VerticalLayout upperLayout = new VerticalLayout();
    upperLayout.setSizeFull();
    upperLayout.setSpacing(false);
    upperLayout.setMargin(false);

    CssLayout upperTopLayout = new CssLayout();
    Label label = new Label(ViewProperties.getCaption("label.loadbalancer"));
    upperTopLayout.setWidth("100%");
    upperTopLayout.setMargin(true);
    upperTopLayout.addStyleName("loadbalancer-table-label");
    upperTopLayout.addComponent(label);
    upperTopLayout.setHeight("28px");
    upperLayout.addComponent(upperTopLayout);

    loadBalancerTable = new LoadBalancerTable(sender);
    loadBalancerTable.setContainerDataSource(new LoadBalancerDtoContainer());
    upperLayout.addComponent(loadBalancerTable);
    loadBalancerTable.addListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            tableRowSelected(event);
        }
    });

    loadBalancerButtonsBottom = new LoadBalancerButtonsBottom(sender);
    upperLayout.addComponent(loadBalancerButtonsBottom);
    upperLayout.setExpandRatio(loadBalancerTable, 10);
    splitPanel.addComponent(upperLayout);

    // スプリットパネル下段
    loadBalancerDesc = new LoadBalancerDesc(sender);
    splitPanel.addComponent(loadBalancerDesc);
}
 
Example 5
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;
}