Example usage for com.vaadin.ui Label setWidthUndefined

List of usage examples for com.vaadin.ui Label setWidthUndefined

Introduction

In this page you can find the example usage for com.vaadin.ui Label setWidthUndefined.

Prototype

@Override
    public void setWidthUndefined() 

Source Link

Usage

From source file:fi.semantum.strategia.widget.Indicator.java

License:Open Source License

public static void updateIndicators(final Main main, final Base base, boolean canWrite) {

    final Database database = main.getDatabase();

    List<IndicatorDescription> descs = new ArrayList<IndicatorDescription>();
    fillIndicatorDescriptions(main, base, "", descs);

    boolean isMap = base instanceof Strategiakartta;

    if (isMap && (!descs.isEmpty() || canWrite)) {

        HorizontalLayout indiHeader = new HorizontalLayout();
        indiHeader.setSpacing(true);//w ww .ja  v a  2  s .c  o  m

        Label header = new Label("Indikaattorit (ennuste)");
        main.propertyCells.add(Utils.excelRow(header.getValue()));
        header.setHeight("32px");
        header.addStyleName(ValoTheme.LABEL_HUGE);
        header.addStyleName(ValoTheme.LABEL_BOLD);
        indiHeader.addComponent(header);
        indiHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER);

        if (canWrite) {

            final Image editIndicators = new Image(null, new ThemeResource("chart_line_edit.png"));
            editIndicators.setHeight("24px");
            editIndicators.setWidth("24px");
            editIndicators.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 2661060702097338722L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Utils.loseFocus(editIndicators);
                    manageIndicators(main, main.getUIState().currentItem);
                }

            });

            indiHeader.addComponent(editIndicators);
            indiHeader.setComponentAlignment(editIndicators, Alignment.BOTTOM_CENTER);

        }

        main.properties.addComponent(indiHeader);
        main.properties.setComponentAlignment(indiHeader, Alignment.MIDDLE_CENTER);

        VerticalLayout indicators = new VerticalLayout();

        boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI);

        Property time = Property.find(database, Property.AIKAVALI);

        int index = 0;
        for (final IndicatorDescription desc : descs) {

            ArrayList<String> excelRow = new ArrayList<String>();

            Indicator indicator = desc.indicator;

            final HorizontalLayout hl = new HorizontalLayout();
            hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty");
            hl.setSpacing(true);

            Label l = new Label(desc.caption);
            excelRow.add(l.getValue().replace("%nbsp", ""));
            l.setContentMode(ContentMode.HTML);
            l.setWidth("450px");
            l.addStyleName("propertyName");
            l.setData(desc);
            hl.addComponent(l);
            hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT);

            String value = updateIndicatorValue(main, hl, base, indicator, canWrite);
            excelRow.add(value);

            Label unit = new Label(indicator.getUnit());
            unit.setWidth("100px");
            hl.addComponent(unit);
            hl.setComponentAlignment(unit, Alignment.MIDDLE_LEFT);
            excelRow.add(unit.getValue());

            Label comment = new Label(indicator.getValueShortComment());
            comment.setWidth("150px");
            hl.addComponent(comment);
            hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT);
            excelRow.add(comment.getValue());

            if (showYears) {

                HorizontalLayout hl2 = new HorizontalLayout();
                hl2.setWidth("70px");
                hl2.setHeight("100%");
                hl.addComponent(hl2);
                hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT);

                String years = time.getPropertyValue(indicator);
                if (years == null)
                    years = Property.AIKAVALI_KAIKKI;

                final Label region = new Label(years);
                region.setWidthUndefined();

                excelRow.add(region.getValue());

                hl2.addComponent(region);
                hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER);

            }

            final Image wiki = new Image();
            wiki.setSource(new ThemeResource("table_edit.png"));
            wiki.setHeight("24px");
            wiki.setWidth("24px");
            wiki.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 2661060702097338722L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Wiki.openWiki(main, desc.indicator);
                }

            });

            hl.addComponent(wiki);
            hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER);

            indicators.addComponent(hl);
            indicators.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);

            main.propertyCells.add(excelRow);

        }

        indicators.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 3295743025581923380L;

            private String extractData(Component c) {
                if (c instanceof AbstractComponent) {
                    Object data = ((AbstractComponent) c).getData();
                    if (data instanceof IndicatorDescription) {
                        IndicatorDescription desc = (IndicatorDescription) data;
                        return desc.indicator.getDescription(database);
                    }
                }
                return null;
            }

            @Override
            public void layoutClick(LayoutClickEvent event) {

                String desc = extractData(event.getClickedComponent());
                if (desc == null)
                    return;

                String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">";
                content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">"
                        + desc + "</div>";
                content += "</div>";

                Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE);
                n.setHtmlContentAllowed(true);
                n.show(Page.getCurrent());

            }

        });

        main.properties.addComponent(indicators);
        main.properties.setComponentAlignment(indicators, Alignment.MIDDLE_CENTER);

    }

}

From source file:fi.semantum.strategia.widget.Meter.java

License:Open Source License

public static String updateMeterValue(final Main main, HorizontalLayout hl, final Base base, final Meter meter,
        boolean canWrite) {

    final Database database = main.getDatabase();

    HorizontalLayout hl2 = new HorizontalLayout();
    hl2.setWidth("300px");
    hl2.setHeight("100%");
    hl.addComponent(hl2);//from   w  w  w.  j  a  v a  2  s. c o  m
    hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT);

    final Indicator i = meter.getPossibleIndicator(database);
    if (i != null) {

        Datatype datatype = i.getDatatype(database);
        if (datatype instanceof EnumerationDatatype) {

            EnumerationDatatype enu = (EnumerationDatatype) datatype;

            Object value = i.getValue();
            AbstractField<?> combo = enu.getEditor(main, base, i, false, null);

            hl2.addComponent(combo);
            hl2.setComponentAlignment(combo, Alignment.MIDDLE_CENTER);

            return value != null ? value.toString() : "null";

        }

    }

    final Label label = new Label(meter.describe(database, main.getUIState().forecastMeters));
    label.setWidthUndefined();

    hl2.addComponent(label);
    hl2.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
    hl2.setExpandRatio(label, 1.0f);

    return label.getValue();

}

From source file:fi.semantum.strategia.widget.Meter.java

License:Open Source License

public static void updateMeters(final Main main, boolean canWrite) {

    if (main.getUIState().currentItem instanceof Strategiakartta)
        return;/*from   www. jav a2 s  .c om*/

    final Database database = main.getDatabase();

    final Base base = main.getUIState().currentItem;

    List<MeterDescription> descs = makeMeterDescriptions(main, base, false);
    if (!descs.isEmpty() || canWrite) {

        HorizontalLayout meterHeader = new HorizontalLayout();
        meterHeader.setSpacing(true);

        Label header = new Label("Mittarit");
        main.propertyCells.add(Utils.excelRow(header.getValue()));
        header.setHeight("32px");
        header.addStyleName(ValoTheme.LABEL_HUGE);
        header.addStyleName(ValoTheme.LABEL_BOLD);
        meterHeader.addComponent(header);
        meterHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER);

        if (canWrite) {

            final Image editMeters = new Image(null, new ThemeResource("chart_bar_edit.png"));
            editMeters.setHeight("24px");
            editMeters.setWidth("24px");
            editMeters.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 2661060702097338722L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Utils.loseFocus(editMeters);
                    manageMeters(main, main.getUIState().currentItem);
                }

            });

            meterHeader.addComponent(editMeters);
            meterHeader.setComponentAlignment(editMeters, Alignment.BOTTOM_CENTER);

        }

        main.properties.addComponent(meterHeader);
        main.properties.setComponentAlignment(meterHeader, Alignment.MIDDLE_CENTER);

        VerticalLayout meters = new VerticalLayout();

        boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI);

        Property time = Property.find(database, Property.AIKAVALI);

        int index = 0;
        for (final MeterDescription desc : descs) {

            ArrayList<String> excelRow = new ArrayList<String>();

            final Meter meter = desc.meter;

            final HorizontalLayout hl = new HorizontalLayout();
            hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty");
            hl.setSpacing(true);

            Label l = new Label(desc.caption);
            excelRow.add(l.getValue().replace("%nbsp", ""));
            l.setContentMode(ContentMode.HTML);
            l.setWidth("450px");
            l.addStyleName("propertyName");
            l.setData(desc);
            hl.addComponent(l);
            hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT);

            String value = updateMeterValue(main, hl, base, meter, canWrite);
            excelRow.add(value);

            String shortComment = "";
            Indicator indicator = meter.getPossibleIndicator(database);
            if (indicator != null)
                shortComment = indicator.getValueShortComment();
            Label comment = new Label(shortComment);
            comment.setWidth("150px");
            hl.addComponent(comment);
            hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT);
            excelRow.add(comment.getValue());

            if (showYears) {

                HorizontalLayout hl2 = new HorizontalLayout();
                hl2.setWidth("70px");
                hl2.setHeight("100%");
                hl.addComponent(hl2);
                hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT);

                String years = time.getPropertyValue(meter);
                if (years == null)
                    years = Property.AIKAVALI_KAIKKI;

                final Label region = new Label(years);
                region.setWidthUndefined();

                excelRow.add(region.getValue());

                hl2.addComponent(region);
                hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER);

            }

            AbsoluteLayout image = new AbsoluteLayout();
            image.setWidth("32px");
            image.setHeight("32px");
            image.addStyleName("meterColor" + index);

            String color = meter.getTrafficColor(database);

            Styles styles = Page.getCurrent().getStyles();
            styles.add(
                    ".fi_semantum_strategia div." + "meterColor" + index + " { background: " + color + "; }");

            hl.addComponent(image);
            hl.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
            hl.setExpandRatio(image, 0.0f);

            meters.addComponent(hl);
            meters.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);

            ThemeResource res = desc.meter.showInMap ? new ThemeResource("zoom.png")
                    : new ThemeResource("zoom_out.png");

            final Image show = new Image();
            show.setSource(res);
            show.setHeight("24px");
            show.setWidth("24px");
            if (canWrite) {
                show.setDescription("Klikkaamalla voit valita, nytetnk mittaria strategiakartassa");
                show.addClickListener(new MouseEvents.ClickListener() {

                    private static final long serialVersionUID = 7156984656942915939L;

                    @Override
                    public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                        desc.meter.setShowInMap(!desc.meter.showInMap);
                        Updates.update(main, true);
                    }

                });
            }

            hl.addComponent(show);
            hl.setComponentAlignment(show, Alignment.MIDDLE_CENTER);

            final Image wiki = new Image();
            wiki.setSource(new ThemeResource("table_edit.png"));
            wiki.setHeight("24px");
            wiki.setWidth("24px");
            wiki.setDescription("Klikkaamalla voit siirty tausta-asiakirjaan");
            wiki.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 7156984656942915939L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Wiki.openWiki(main, desc.meter);
                }

            });

            hl.addComponent(wiki);
            hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER);

            if (canWrite) {
                final Button principalButton = new Button();
                if (meter.isPrincipal) {
                    principalButton.setCaption("Poista kokonaisarvio");
                } else {
                    principalButton.setCaption("Aseta kokonaisarvioksi");
                }
                principalButton.setStyleName(ValoTheme.BUTTON_TINY);
                principalButton.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 8247560202892661226L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        if (meter.isPrincipal) {
                            meter.isPrincipal = false;
                        } else {
                            for (Meter m : base.getMeters(database))
                                m.isPrincipal = false;
                            meter.isPrincipal = true;
                        }
                        Updates.update(main, true);

                    }

                });
                hl.addComponent(principalButton);
                hl.setComponentAlignment(principalButton, Alignment.MIDDLE_CENTER);
            }

            main.propertyCells.add(excelRow);

        }

        meters.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 3295743025581923380L;

            private String extractData(Component c) {
                if (c instanceof AbstractComponent) {
                    Object data = ((AbstractComponent) c).getData();
                    if (data instanceof MeterDescription) {
                        MeterDescription desc = (MeterDescription) data;
                        return desc.meter.getDescription(database);
                    }
                }
                return null;
            }

            @Override
            public void layoutClick(LayoutClickEvent event) {

                String desc = extractData(event.getClickedComponent());
                if (desc == null)
                    return;

                String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">";
                content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">"
                        + desc + "</div>";
                content += "</div>";

                Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE);
                n.setHtmlContentAllowed(true);
                n.show(Page.getCurrent());

            }

        });

        main.properties.addComponent(meters);
        main.properties.setComponentAlignment(meters, Alignment.MIDDLE_CENTER);

    }

}

From source file:nl.kpmg.lcm.ui.Application.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    getPage().setTitle("Local Catalog Manager");

    final VerticalLayout root = new VerticalLayout();
    root.setSizeFull();//from  w  w  w.jav a2s.  c o  m
    root.setMargin(true);
    root.setSpacing(true);
    setContent(root);

    final CssLayout navigationBar = new CssLayout();
    navigationBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);

    Label logo = new Label("LCM");
    logo.addStyleName("logo");
    logo.setWidthUndefined();

    navigationBar.addComponent(logo);
    navigationBar.addComponent(createNavigationButton("Metadata", MetadataOverviewViewImpl.VIEW_NAME));
    navigationBar.addComponent(createNotImplementedButton("Analytics"));
    navigationBar.addComponent(createNavigationButton("Transfer", TransferViewImpl.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("Administration", AdministrationViewImpl.VIEW_NAME));
    navigationBar.addComponent(createLogoutButton("Logout"));
    root.addComponent(navigationBar);

    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    root.addComponent(viewContainer);
    root.setExpandRatio(viewContainer, 1.0f);

    navigator = new Navigator(this, viewContainer);
    navigator.addProvider(viewProvider);
    navigator.navigateTo("login");
}

From source file:org.eclipse.hawkbit.ui.tenantconfiguration.authentication.CertificateAuthenticationConfigurationItem.java

License:Open Source License

public CertificateAuthenticationConfigurationItem(
        final TenantConfigurationManagement tenantConfigurationManagement, final VaadinMessageSource i18n) {
    super(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED, tenantConfigurationManagement, i18n);

    super.init("label.configuration.auth.header");
    configurationEnabled = isConfigEnabled();

    detailLayout = new VerticalLayout();
    detailLayout.setImmediate(true);//  w ww. j  a  v a  2 s .  co  m

    final HorizontalLayout caRootAuthorityLayout = new HorizontalLayout();
    caRootAuthorityLayout.setSpacing(true);

    final Label caRootAuthorityLabel = new LabelBuilder().name("SSL Issuer Hash:").buildLabel();
    caRootAuthorityLabel.setDescription(
            "The SSL Issuer iRules.X509 hash, to validate against the controller request certifcate.");
    caRootAuthorityLabel.setWidthUndefined();

    caRootAuthorityTextField = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent();
    caRootAuthorityTextField.setWidth("100%");
    caRootAuthorityTextField.addTextChangeListener(event -> caRootAuthorityChanged());

    caRootAuthorityLayout.addComponent(caRootAuthorityLabel);
    caRootAuthorityLayout.setExpandRatio(caRootAuthorityLabel, 0);
    caRootAuthorityLayout.addComponent(caRootAuthorityTextField);
    caRootAuthorityLayout.setExpandRatio(caRootAuthorityTextField, 1);
    caRootAuthorityLayout.setWidth("100%");

    detailLayout.addComponent(caRootAuthorityLayout);

    if (isConfigEnabled()) {
        caRootAuthorityTextField.setValue(getCaRootAuthorityValue());
        setDetailVisible(true);
    }
}

From source file:org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutocleanupConfigurationItem.java

License:Open Source License

private Label newLabel(final String msgKey) {
    final Label label = new LabelBuilder().name(i18n.getMessage(msgKey)).buildLabel();
    label.setWidthUndefined();
    return label;
}

From source file:org.hip.vif.web.util.RatingsTable.java

License:Open Source License

private Label createLabel(final String inText) {
    final Label out = new Label(inText);
    out.setWidthUndefined();
    return out;//from   w ww  .j a v a2 s  .c om
}

From source file:org.jumpmind.vaadin.ui.common.CommonUiUtils.java

License:Open Source License

public static Label createSeparator() {
    Label separator = new Label(" ");
    separator.setStyleName("vrule");
    separator.setHeight(100, Unit.PERCENTAGE);
    separator.setWidthUndefined();
    return separator;
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.QueryPanel.java

License:Open Source License

public QueryPanel(IDb db, ISettingsProvider settingsProvider, IButtonBar buttonBar, String user) {
    this.settingsProvider = settingsProvider;
    this.db = db;
    this.user = user;
    this.buttonBar = buttonBar;
    this.sqlArea = buildSqlEditor();
    this.shortCutListeners.add(createExecuteSqlShortcutListener());

    VerticalLayout resultsLayout = new VerticalLayout();
    resultsLayout.setSizeFull();//from   w  w  w.j  a v a 2 s.co  m

    resultsTabs = CommonUiUtils.createTabSheet();
    resultStatuses = new HashMap<Component, String>();

    HorizontalLayout statusBar = new HorizontalLayout();
    statusBar.addStyleName(ValoTheme.PANEL_WELL);
    statusBar.setMargin(new MarginInfo(true, true, true, true));
    statusBar.setWidth(100, Unit.PERCENTAGE);

    status = new Label("No Results");
    statusBar.addComponent(status);

    setSelectedTabChangeListener();

    resultsLayout.addComponents(resultsTabs, statusBar);
    resultsLayout.setExpandRatio(resultsTabs, 1);

    addComponents(sqlArea, resultsLayout);

    setSplitPosition(400, Unit.PIXELS);

    emptyResults = new VerticalLayout();
    emptyResults.setSizeFull();
    Label label = new Label("New results will appear here");
    label.setWidthUndefined();
    emptyResults.addComponent(label);
    emptyResults.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
    resultStatuses.put(emptyResults, "No Results");

    if (!settingsProvider.get().getProperties().is(SQL_EXPLORER_SHOW_RESULTS_IN_NEW_TABS)) {
        createGeneralResultsTab();
    }
}

From source file:org.lucidj.browser.ComponentPalette.java

License:Apache License

private boolean add_component_to_palette(ComponentDescriptor component) {
    String canonical_name = component.getComponentClass();
    String icon_title = component.getIconTitle();

    log.info("*** => ADDING component {} ({})", canonical_name, component);

    int base_width = 6;
    int margin_h_size_px = base_width / 2;
    int margin_v_size_px = base_width;
    int icon_size_px = base_width * 6;
    int font_size_px = 2 * base_width + 2;
    int icon_box_width_px = base_width * 12;

    String icon_html = "<div style='text-align: center; height:auto; display:inline-block; " + "margin:"
            + margin_v_size_px + "px " + margin_h_size_px + "px;" + "width:" + icon_box_width_px
            + "px; line-height:1.1em;'>" + "<img src='" + component.getIconUrl() + "' " + "width='"
            + icon_size_px + "px' height='" + icon_size_px + "px' />"
            + "<div style='white-space:normal; word-wrap:break-word; font-weight: 400;" + "font-size:"
            + font_size_px + "px;'>" + icon_title + "</div>" + "</div>";

    Label icon_label = new Label(icon_html, ContentMode.HTML);
    icon_label.setWidthUndefined();

    // Put the component in a D&D wrapper and allow dragging it
    final DragAndDropWrapper icon_dd_wrap = new DragAndDropWrapper(icon_label);
    icon_dd_wrap.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT);

    // Set the wrapper to wrap tightly around the component
    icon_dd_wrap.setSizeUndefined();// w ww.ja  v  a2 s.c  o  m
    icon_dd_wrap.setData(component);

    // Set canonical_name for drag-drop AND on the Label for double-click
    icon_dd_wrap.setId(canonical_name);
    icon_label.setId(canonical_name);

    // Remember this association
    component_to_vaadin.put(component, icon_dd_wrap);

    // Add the wrapper, not the component, to the layout
    self.addComponent(icon_dd_wrap);
    return (true);
}