Example usage for com.vaadin.ui Label setIcon

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

Introduction

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

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

From source file:org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.java

License:Open Source License

private void createOptionGroup() {
    actionTypeOptionGroup = new FlexibleOptionGroup();
    actionTypeOptionGroup.addItem(ActionTypeOption.SOFT);
    actionTypeOptionGroup.addItem(ActionTypeOption.FORCED);
    actionTypeOptionGroup.addItem(ActionTypeOption.AUTO_FORCED);
    selectDefaultOption();/*from w  w  w . j ava  2  s.  c o m*/

    final FlexibleOptionGroupItemComponent forceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.FORCED);
    forceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    // set Id for Forced radio button.
    forceItem.setId("save.action.radio.forced");
    addComponent(forceItem);
    final Label forceLabel = new Label();
    forceLabel.setStyleName("statusIconPending");
    forceLabel.setIcon(FontAwesome.BOLT);
    forceLabel.setCaption("Forced");
    forceLabel.setDescription(i18n.getMessage("tooltip.forced.item"));
    forceLabel.setStyleName("padding-right-style");
    addComponent(forceLabel);

    final FlexibleOptionGroupItemComponent softItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.SOFT);
    softItem.setId(UIComponentIdProvider.ACTION_DETAILS_SOFT_ID);
    softItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(softItem);
    final Label softLabel = new Label();
    softLabel.setSizeFull();
    softLabel.setCaption("Soft");
    softLabel.setDescription(i18n.getMessage("tooltip.soft.item"));
    softLabel.setStyleName("padding-right-style");
    addComponent(softLabel);

    final FlexibleOptionGroupItemComponent autoForceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.AUTO_FORCED);
    autoForceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    // setted Id for Time Forced radio button.
    autoForceItem.setId(UIComponentIdProvider.ACTION_TYPE_OPTION_GROUP_SAVE_TIMEFORCED);
    addComponent(autoForceItem);
    final Label autoForceLabel = new Label();
    autoForceLabel.setStyleName("statusIconPending");
    autoForceLabel.setIcon(FontAwesome.HISTORY);
    autoForceLabel.setCaption("Time Forced");
    autoForceLabel.setDescription(i18n.getMessage("tooltip.timeforced.item"));
    autoForceLabel.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(autoForceLabel);

    forcedTimeDateField = new DateField();
    forcedTimeDateField.setInvalidAllowed(false);
    forcedTimeDateField.setInvalidCommitted(false);
    forcedTimeDateField.setEnabled(false);
    forcedTimeDateField.setStyleName("dist-window-forcedtime");

    final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
    forcedTimeDateField.setValue(
            Date.from(LocalDateTime.now().plusWeeks(2).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
    forcedTimeDateField.setImmediate(true);
    forcedTimeDateField.setTimeZone(tz);
    forcedTimeDateField.setLocale(HawkbitCommonUtil.getLocale());
    forcedTimeDateField.setResolution(Resolution.MINUTE);
    forcedTimeDateField.addStyleName(ValoTheme.DATEFIELD_SMALL);
    addComponent(forcedTimeDateField);
}

From source file:org.eclipse.hawkbit.ui.management.miscs.AbstractActionTypeOptionGroupLayout.java

License:Open Source License

protected void addForcedItemWithLabel() {
    final FlexibleOptionGroupItemComponent forceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.FORCED);
    forceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    forceItem.setId(UIComponentIdProvider.SAVE_ACTION_RADIO_FORCED);
    addComponent(forceItem);//  www  .j a  v a2  s .  c om
    final Label forceLabel = new Label();
    forceLabel.setStyleName("statusIconPending");
    forceLabel.setIcon(FontAwesome.BOLT);
    forceLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_FORCED));
    forceLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_FORCED_ITEM));
    forceLabel.setStyleName("padding-right-style");
    addComponent(forceLabel);
}

From source file:org.eclipse.hawkbit.ui.management.miscs.ActionTypeOptionGroupAssignmentLayout.java

License:Open Source License

private void addAutoForceItemWithLabelAndDateField() {
    final FlexibleOptionGroupItemComponent autoForceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.AUTO_FORCED);
    autoForceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    autoForceItem.setId(UIComponentIdProvider.ACTION_TYPE_OPTION_GROUP_SAVE_TIMEFORCED);
    addComponent(autoForceItem);/* w  w  w  .  j  a  v  a2  s.co  m*/
    final Label autoForceLabel = new Label();
    autoForceLabel.setStyleName("statusIconPending");
    autoForceLabel.setIcon(FontAwesome.HISTORY);
    autoForceLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_TIME_FORCED));
    autoForceLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_TIMEFORCED_ITEM));
    autoForceLabel.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(autoForceLabel);

    forcedTimeDateField = new DateField();
    forcedTimeDateField.setInvalidAllowed(false);
    forcedTimeDateField.setInvalidCommitted(false);
    forcedTimeDateField.setEnabled(false);
    forcedTimeDateField.setStyleName("dist-window-forcedtime");

    final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
    forcedTimeDateField.setValue(
            Date.from(LocalDateTime.now().plusWeeks(2).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
    forcedTimeDateField.setImmediate(true);
    forcedTimeDateField.setTimeZone(tz);
    forcedTimeDateField.setLocale(HawkbitCommonUtil.getCurrentLocale());
    forcedTimeDateField.setResolution(Resolution.MINUTE);
    forcedTimeDateField.addStyleName(ValoTheme.DATEFIELD_SMALL);
    addComponent(forcedTimeDateField);
}

From source file:org.eclipse.hawkbit.ui.management.miscs.ActionTypeOptionGroupLayout.java

License:Open Source License

private void createOptionGroup() {
    actionTypeOptionGroup = new FlexibleOptionGroup();
    actionTypeOptionGroup.addItem(ActionTypeOption.SOFT);
    actionTypeOptionGroup.addItem(ActionTypeOption.FORCED);
    actionTypeOptionGroup.addItem(ActionTypeOption.AUTO_FORCED);
    selectDefaultOption();//from   w ww . ja v a 2  s.  c  o  m

    final FlexibleOptionGroupItemComponent forceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.FORCED);
    forceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    forceItem.setId(UIComponentIdProvider.SAVE_ACTION_RADIO_FORCED);
    addComponent(forceItem);
    final Label forceLabel = new Label();
    forceLabel.setStyleName("statusIconPending");
    forceLabel.setIcon(FontAwesome.BOLT);
    forceLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_FORCED));
    forceLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_FORCED_ITEM));
    forceLabel.setStyleName("padding-right-style");
    addComponent(forceLabel);

    final FlexibleOptionGroupItemComponent softItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.SOFT);
    softItem.setId(UIComponentIdProvider.ACTION_DETAILS_SOFT_ID);
    softItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(softItem);
    final Label softLabel = new Label();
    softLabel.setSizeFull();
    softLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_SOFT));
    softLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_SOFT_ITEM));
    softLabel.setStyleName("padding-right-style");
    addComponent(softLabel);

    final FlexibleOptionGroupItemComponent autoForceItem = actionTypeOptionGroup
            .getItemComponent(ActionTypeOption.AUTO_FORCED);
    autoForceItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    autoForceItem.setId(UIComponentIdProvider.ACTION_TYPE_OPTION_GROUP_SAVE_TIMEFORCED);
    addComponent(autoForceItem);
    final Label autoForceLabel = new Label();
    autoForceLabel.setStyleName("statusIconPending");
    autoForceLabel.setIcon(FontAwesome.HISTORY);
    autoForceLabel.setCaption(i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_TIME_FORCED));
    autoForceLabel.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_TIMEFORCED_ITEM));
    autoForceLabel.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE);
    addComponent(autoForceLabel);

    forcedTimeDateField = new DateField();
    forcedTimeDateField.setInvalidAllowed(false);
    forcedTimeDateField.setInvalidCommitted(false);
    forcedTimeDateField.setEnabled(false);
    forcedTimeDateField.setStyleName("dist-window-forcedtime");

    final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
    forcedTimeDateField.setValue(
            Date.from(LocalDateTime.now().plusWeeks(2).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
    forcedTimeDateField.setImmediate(true);
    forcedTimeDateField.setTimeZone(tz);
    forcedTimeDateField.setLocale(HawkbitCommonUtil.getLocale());
    forcedTimeDateField.setResolution(Resolution.MINUTE);
    forcedTimeDateField.addStyleName(ValoTheme.DATEFIELD_SMALL);
    addComponent(forcedTimeDateField);
}

From source file:org.eclipse.hawkbit.ui.rollout.rollout.AutoStartOptionGroupLayout.java

License:Open Source License

private void createOptionGroup() {
    autoStartOptionGroup = new FlexibleOptionGroup();
    autoStartOptionGroup.addItem(AutoStartOption.MANUAL);
    autoStartOptionGroup.addItem(AutoStartOption.AUTO_START);
    autoStartOptionGroup.addItem(AutoStartOption.SCHEDULED);
    selectDefaultOption();//  w  ww.  ja va2  s .  co m

    final FlexibleOptionGroupItemComponent manualItem = autoStartOptionGroup
            .getItemComponent(AutoStartOption.MANUAL);
    manualItem.setStyleName(STYLE_DIST_WINDOW_AUTO_START);
    // set Id for Forced radio button.
    manualItem.setId(UIComponentIdProvider.ROLLOUT_START_MANUAL_ID);
    addComponent(manualItem);
    final Label manualLabel = new Label();
    manualLabel.setStyleName("statusIconPending");
    manualLabel.setIcon(FontAwesome.HAND_PAPER_O);
    manualLabel.setCaption(i18n.getMessage("caption.rollout.start.manual"));
    manualLabel.setDescription(i18n.getMessage("caption.rollout.start.manual.desc"));
    manualLabel.setStyleName("padding-right-style");
    addComponent(manualLabel);

    final FlexibleOptionGroupItemComponent autoStartItem = autoStartOptionGroup
            .getItemComponent(AutoStartOption.AUTO_START);
    autoStartItem.setId(UIComponentIdProvider.ROLLOUT_START_AUTO_ID);
    autoStartItem.setStyleName(STYLE_DIST_WINDOW_AUTO_START);
    addComponent(autoStartItem);
    final Label autoStartLabel = new Label();
    autoStartLabel.setSizeFull();
    autoStartLabel.setIcon(FontAwesome.PLAY);
    autoStartLabel.setCaption(i18n.getMessage("caption.rollout.start.auto"));
    autoStartLabel.setDescription(i18n.getMessage("caption.rollout.start.auto.desc"));
    autoStartLabel.setStyleName("padding-right-style");
    addComponent(autoStartLabel);

    final FlexibleOptionGroupItemComponent scheduledItem = autoStartOptionGroup
            .getItemComponent(AutoStartOption.SCHEDULED);
    scheduledItem.setStyleName(STYLE_DIST_WINDOW_AUTO_START);
    // setted Id for Time Forced radio button.
    scheduledItem.setId(UIComponentIdProvider.ROLLOUT_START_SCHEDULED_ID);
    addComponent(scheduledItem);
    final Label scheduledLabel = new Label();
    scheduledLabel.setStyleName("statusIconPending");
    scheduledLabel.setIcon(FontAwesome.CLOCK_O);
    scheduledLabel.setCaption(i18n.getMessage("caption.rollout.start.scheduled"));
    scheduledLabel.setDescription(i18n.getMessage("caption.rollout.start.scheduled.desc"));
    scheduledLabel.setStyleName(STYLE_DIST_WINDOW_AUTO_START);
    addComponent(scheduledLabel);

    startAtDateField = new DateField();
    startAtDateField.setInvalidAllowed(false);
    startAtDateField.setInvalidCommitted(false);
    startAtDateField.setEnabled(false);
    startAtDateField.setStyleName("dist-window-forcedtime");

    final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone();
    startAtDateField.setValue(Date
            .from(LocalDateTime.now().plusMinutes(30).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant()));
    startAtDateField.setImmediate(true);
    startAtDateField.setTimeZone(tz);
    startAtDateField.setLocale(HawkbitCommonUtil.getCurrentLocale());
    startAtDateField.setResolution(Resolution.MINUTE);
    startAtDateField.addStyleName(ValoTheme.DATEFIELD_SMALL);
    addComponent(startAtDateField);
}

From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java

License:BSD License

protected Panel createTextAreaPanel(ConfigurationParameter parameter, Validator validator) {
    Panel paramPanel = new Panel();
    paramPanel.setStyleName("dashboard");
    paramPanel.setWidth("100%");

    GridLayout paramLayout = new GridLayout(2, 3);
    paramLayout.setSpacing(true);//from  ww  w . j av  a2s  .  c  om
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label label = new Label(parameter.getName());
    label.setIcon(VaadinIcons.COG);
    label.addStyleName(ValoTheme.LABEL_LARGE);
    label.addStyleName(ValoTheme.LABEL_BOLD);
    label.setSizeUndefined();
    paramLayout.addComponent(label, 0, 0, 1, 0);
    paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

    logger.info(parameter.getName() + " " + parameter.getValue());
    Label valueLabel = new Label("Value:");
    valueLabel.setSizeUndefined();
    TextArea textField = new TextArea();
    textField.addValidator(validator);
    textField.setNullSettingAllowed(true);
    textField.setNullRepresentation("");
    textField.setValidationVisible(false);
    textField.setRows(4);
    textField.setWidth("80%");
    textField.setId(parameter.getName());

    if (parameter instanceof ConfigurationParameterIntegerImpl) {
        StringToIntegerConverter plainIntegerConverter = new StringToIntegerConverter() {
            protected java.text.NumberFormat getFormat(Locale locale) {
                NumberFormat format = super.getFormat(locale);
                format.setGroupingUsed(false);
                return format;
            };
        };

        // either set for the field or in your field factory for multiple fields
        textField.setConverter(plainIntegerConverter);
    } else if (parameter instanceof ConfigurationParameterLongImpl) {
        StringToLongConverter plainLongConverter = new StringToLongConverter() {
            protected java.text.NumberFormat getFormat(Locale locale) {
                NumberFormat format = super.getFormat(locale);
                format.setGroupingUsed(false);
                return format;
            };
        };

        // either set for the field or in your field factory for multiple fields
        textField.setConverter(plainLongConverter);
    }

    textFields.put(parameter.getName(), textField);

    BeanItem<ConfigurationParameter> parameterItem = new BeanItem<ConfigurationParameter>(parameter);

    if (parameter.getValue() != null) {
        textField.setPropertyDataSource(parameterItem.getItemProperty("value"));
    }

    paramLayout.addComponent(valueLabel, 0, 1);
    paramLayout.addComponent(textField, 1, 1);
    paramLayout.setComponentAlignment(valueLabel, Alignment.TOP_RIGHT);

    Label paramDescriptionLabel = new Label("Description:");
    paramDescriptionLabel.setSizeUndefined();
    TextArea descriptionTextField = new TextArea();
    descriptionTextField.setRows(4);
    descriptionTextField.setWidth("80%");
    descriptionTextField.setId(parameter.getName());

    paramLayout.addComponent(paramDescriptionLabel, 0, 2);
    paramLayout.addComponent(descriptionTextField, 1, 2);
    paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT);

    descriptionTextFields.put(parameter.getName(), descriptionTextField);

    if (parameter.getDescription() != null) {
        descriptionTextField.setValue(parameter.getDescription());
    }

    paramPanel.setContent(paramLayout);

    return paramPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java

License:BSD License

protected Panel createMapPanel(final ConfigurationParameterMapImpl parameter) {
    Panel paramPanel = new Panel();
    paramPanel.setStyleName("dashboard");
    paramPanel.setWidth("100%");

    GridLayout paramLayout = new GridLayout(2, 3);
    paramLayout.setSpacing(true);//  w ww . ja v  a 2 s . co  m
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label label = new Label(parameter.getName());
    label.setIcon(VaadinIcons.COG);
    label.addStyleName(ValoTheme.LABEL_LARGE);
    label.addStyleName(ValoTheme.LABEL_BOLD);
    label.setSizeUndefined();
    paramLayout.addComponent(label, 0, 0, 1, 0);
    paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

    final Map<String, String> valueMap = parameter.getValue();

    final GridLayout mapLayout = new GridLayout(5, (valueMap.size() != 0 ? valueMap.size() : 1) + 1);
    mapLayout.setMargin(true);
    mapLayout.setSpacing(true);

    int i = 0;

    for (final String key : valueMap.keySet()) {
        final Label keyLabel = new Label("Key");
        final Label valueLabel = new Label("Value");

        final TextField keyField = new TextField();
        keyField.setValue(key);

        final TextField valueField = new TextField();
        valueField.setValue(valueMap.get(key));

        mapLayout.addComponent(keyLabel, 0, i);
        mapLayout.addComponent(keyField, 1, i);
        mapLayout.addComponent(valueLabel, 2, i);
        mapLayout.addComponent(valueField, 3, i);
        final String mapKey = parameter.getName() + i;
        TextFieldKeyValuePair pair = new TextFieldKeyValuePair();
        pair.key = keyField;
        pair.value = valueField;

        this.mapTextFields.put(mapKey, pair);

        final Button removeButton = new Button("remove");
        removeButton.setStyleName(ValoTheme.BUTTON_LINK);
        removeButton.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                valueMap.remove(key);
                mapLayout.removeComponent(keyLabel);
                mapLayout.removeComponent(valueLabel);
                mapLayout.removeComponent(keyField);
                mapLayout.removeComponent(valueField);
                mapLayout.removeComponent(removeButton);

                mapTextFields.remove(mapKey);
            }
        });

        mapLayout.addComponent(removeButton, 4, i);

        i++;
    }

    final Button addButton = new Button("add");
    addButton.setStyleName(ValoTheme.BUTTON_LINK);
    addButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final Label keyLabel = new Label("Key");
            final Label valueLabel = new Label("Value");

            final TextField keyField = new TextField();

            final TextField valueField = new TextField();

            mapLayout.insertRow(mapLayout.getRows());

            mapLayout.removeComponent(addButton);
            mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() - 2);
            mapLayout.addComponent(keyField, 1, mapLayout.getRows() - 2);
            mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() - 2);
            mapLayout.addComponent(valueField, 3, mapLayout.getRows() - 2);

            final String mapKey = parameter.getName() + mapTextFields.size();
            TextFieldKeyValuePair pair = new TextFieldKeyValuePair();
            pair.key = keyField;
            pair.value = valueField;

            mapTextFields.put(mapKey, pair);

            final Button removeButton = new Button("remove");
            removeButton.setStyleName(ValoTheme.BUTTON_LINK);
            removeButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    mapLayout.removeComponent(keyLabel);
                    mapLayout.removeComponent(valueLabel);
                    mapLayout.removeComponent(keyField);
                    mapLayout.removeComponent(valueField);

                    mapLayout.removeComponent(removeButton);

                    mapTextFields.remove(mapKey);
                }
            });

            mapLayout.addComponent(removeButton, 4, mapLayout.getRows() - 2);

            mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1);
        }
    });

    mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1);

    Panel mapPanel = new Panel();
    mapPanel.setStyleName("dashboard");
    mapPanel.setContent(mapLayout);

    paramLayout.addComponent(mapPanel, 0, 1, 1, 1);
    paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER);
    paramPanel.setContent(paramLayout);

    Label paramDescriptionLabel = new Label("Description:");
    paramDescriptionLabel.setSizeUndefined();
    TextArea descriptionTextField = new TextArea();
    descriptionTextField.setRows(4);
    descriptionTextField.setWidth("80%");
    descriptionTextField.setId(parameter.getName());

    paramLayout.addComponent(paramDescriptionLabel, 0, 2);
    paramLayout.addComponent(descriptionTextField, 1, 2);
    paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT);

    descriptionTextFields.put(parameter.getName(), descriptionTextField);

    if (parameter.getDescription() != null) {
        descriptionTextField.setValue(parameter.getDescription());
    }

    return paramPanel;
}

From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java

License:BSD License

protected Panel createListPanel(final ConfigurationParameterListImpl parameter) {
    Panel paramPanel = new Panel();
    paramPanel.setStyleName("dashboard");
    paramPanel.setWidth("100%");

    GridLayout paramLayout = new GridLayout(2, 3);
    paramLayout.setSpacing(true);//w  w w .j av  a 2 s  . c  om
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label label = new Label(parameter.getName());
    label.setIcon(VaadinIcons.COG);
    label.addStyleName(ValoTheme.LABEL_LARGE);
    label.addStyleName(ValoTheme.LABEL_BOLD);
    label.setSizeUndefined();
    paramLayout.addComponent(label, 0, 0, 1, 0);
    paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

    final List<String> valueList = parameter.getValue();

    final GridLayout listLayout = new GridLayout(3, (valueList.size() != 0 ? valueList.size() : 1) + 1);
    listLayout.setWidth("450px");
    listLayout.setMargin(true);
    listLayout.setSpacing(true);

    listLayout.setColumnExpandRatio(0, 0.25f);
    listLayout.setColumnExpandRatio(1, 0.5f);
    listLayout.setColumnExpandRatio(2, 0.25f);

    int i = 0;

    for (final String value : valueList) {
        final Label valueLabel = new Label("Value");

        final TextField valueField = new TextField();
        valueField.setValue(value);
        valueField.setWidth("90%");

        listLayout.addComponent(valueLabel, 0, i);
        listLayout.addComponent(valueField, 1, i);

        final String mapKey = parameter.getName() + i;

        this.valueTextFields.put(mapKey, valueField);

        final Button removeButton = new Button("remove");
        removeButton.setStyleName(ValoTheme.BUTTON_LINK);
        removeButton.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                valueList.remove(value);
                listLayout.removeComponent(valueLabel);
                listLayout.removeComponent(valueField);
                listLayout.removeComponent(removeButton);

                valueTextFields.remove(mapKey);
            }
        });

        listLayout.addComponent(removeButton, 2, i);

        i++;
    }

    final Button addButton = new Button("add");
    addButton.setStyleName(ValoTheme.BUTTON_LINK);
    addButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final Label valueLabel = new Label("Value");

            final TextField valueField = new TextField();
            valueField.setWidth("90%");

            listLayout.insertRow(listLayout.getRows());

            listLayout.removeComponent(addButton);
            listLayout.addComponent(valueLabel, 0, listLayout.getRows() - 2);
            listLayout.addComponent(valueField, 1, listLayout.getRows() - 2);

            final String mapKey = parameter.getName() + valueTextFields.size();

            valueTextFields.put(mapKey, valueField);

            final Button removeButton = new Button("remove");
            removeButton.setStyleName(ValoTheme.BUTTON_LINK);
            removeButton.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    listLayout.removeComponent(valueLabel);
                    listLayout.removeComponent(valueField);

                    listLayout.removeComponent(removeButton);

                    valueTextFields.remove(mapKey);
                }
            });

            listLayout.addComponent(removeButton, 2, listLayout.getRows() - 2);

            listLayout.addComponent(addButton, 0, listLayout.getRows() - 1);
        }
    });

    listLayout.addComponent(addButton, 0, listLayout.getRows() - 1);

    Panel mapPanel = new Panel();
    mapPanel.setStyleName("dashboard");
    mapPanel.setContent(listLayout);

    paramLayout.addComponent(mapPanel, 0, 1, 1, 1);
    paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER);
    paramPanel.setContent(paramLayout);

    Label paramDescriptionLabel = new Label("Description:");
    paramDescriptionLabel.setSizeUndefined();
    TextArea descriptionTextField = new TextArea();
    descriptionTextField.setRows(4);
    descriptionTextField.setWidth("80%");
    descriptionTextField.setId(parameter.getName());

    paramLayout.addComponent(paramDescriptionLabel, 0, 2);
    paramLayout.addComponent(descriptionTextField, 1, 2);
    paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT);

    descriptionTextFields.put(parameter.getName(), descriptionTextField);

    if (parameter.getDescription() != null) {
        descriptionTextField.setValue(parameter.getDescription());
    }

    return paramPanel;
}

From source file:org.opennms.features.topology.app.internal.ui.LayoutHintComponent.java

License:Open Source License

public LayoutHintComponent(LayoutManager layoutManager, GraphContainer graphContainer) {
    this.layoutManager = layoutManager;

    final Label icon = new Label();
    icon.setIcon(FontAwesome.INFO_CIRCLE);
    final Label text = new Label("A manual layout exists for the current selection.");

    final HorizontalLayout layout = new HorizontalLayout();
    layout.addComponent(icon);/*from   w ww .j  ava  2s.c  o m*/
    layout.addComponent(text);
    layout.setDescription("Click to apply the manual layout");
    layout.addLayoutClickListener(
            (event) -> graphContainer.setLayoutAlgorithm(new ManualLayoutAlgorithm(layoutManager)));
    layout.setSpacing(true);
    setCompositionRoot(layout);
}

From source file:org.opennms.features.topology.plugins.topo.bsm.info.SimulationModeEnabledPanelItem.java

License:Open Source License

@Override
public Component getComponent(GraphContainer container) {
    Label label = new Label("Simulation Mode Enabled");
    label.setDescription("Simulation Mode is enabled");
    label.setIcon(FontAwesome.EXCLAMATION_TRIANGLE);
    label.addStyleName("warning");

    HorizontalLayout layout = new HorizontalLayout();
    layout.addComponent(label);//from  w w w .  java  2 s. c  o m
    layout.addStyleName("simulation");
    return layout;
}