From a51bf0ac029389425215135fe84874789efec44f Mon Sep 17 00:00:00 2001 From: SirWayne Date: Tue, 16 Aug 2016 14:38:21 +0200 Subject: [PATCH] Add LabelBuilder Signed-off-by: SirWayne --- .../details/ArtifactDetailsLayout.java | 5 +- .../CreateUpdateSoftwareTypeLayout.java | 6 +- .../common/AbstractMetadataPopupLayout.java | 4 +- .../ui/common/builder/LabelBuilder.java | 111 ++++++++++++++++++ .../ui/common/builder/WindowBuilder.java | 8 ++ .../AbstractConfirmationWindowLayout.java | 9 +- .../AbstractTableDetailsLayout.java | 4 +- .../filterlayout/AbstractFilterHeader.java | 3 +- .../ui/common/table/AbstractTableHeader.java | 5 +- .../ui/components/SPUIComponentProvider.java | 76 ------------ .../ui/components/SPUIHorizontalLayout.java | 49 -------- .../ui/decorators/SPUILabelDecorator.java | 65 ---------- .../CreateOrUpdateFilterHeader.java | 8 +- .../CreateOrUpdateFilterTable.java | 4 +- .../filtermanagement/TargetFilterHeader.java | 4 +- .../AbstractCreateUpdateTagLayout.java | 5 +- .../ui/layouts/CreateUpdateTypeLayout.java | 6 +- .../actionhistory/ActionHistoryHeader.java | 7 +- .../actionhistory/ActionHistoryTable.java | 12 +- .../targettag/FilterByStatusLayout.java | 6 +- .../rollout/AddUpdateRolloutWindowLayout.java | 9 +- .../ui/rollout/rollout/RolloutListHeader.java | 6 +- .../rolloutgroup/RolloutGroupsListHeader.java | 4 +- .../RolloutGroupTargetsListHeader.java | 4 +- ...AuthenticationTenantConfigurationItem.java | 5 +- ...ficateAuthenticationConfigurationItem.java | 5 +- ...yTokenAuthenticationConfigurationItem.java | 4 +- .../ui/utils/SPUILabelDefinitions.java | 12 -- .../ui/utils/SPUIComponentProviderTest.java | 20 ---- 29 files changed, 185 insertions(+), 281 deletions(-) create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/builder/LabelBuilder.java delete mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIHorizontalLayout.java delete mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUILabelDecorator.java diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java index c62637117..8408f7c74 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java @@ -24,6 +24,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.common.ConfirmationDialog; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; @@ -149,8 +150,8 @@ public class ArtifactDetailsLayout extends VerticalLayout { final SoftwareModule softwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); labelStr = HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion()); } - titleOfArtifactDetails = SPUIComponentProvider.getLabel( - HawkbitCommonUtil.getArtifactoryDetailsLabelId(labelStr), SPUILabelDefinitions.SP_WIDGET_CAPTION); + titleOfArtifactDetails = new LabelBuilder().name(HawkbitCommonUtil.getArtifactoryDetailsLabelId(labelStr)) + .buildCaptionLabel(); titleOfArtifactDetails.setContentMode(ContentMode.HTML); titleOfArtifactDetails.setSizeFull(); titleOfArtifactDetails.setImmediate(true); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java index 06fb8ed18..f57bef2d1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java @@ -18,6 +18,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper; import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -74,8 +75,9 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout { singleAssignStr = i18n.get("label.singleAssign.type"); multiAssignStr = i18n.get("label.multiAssign.type"); - singleAssign = SPUIComponentProvider.getLabel(singleAssignStr, null); - multiAssign = SPUIComponentProvider.getLabel(multiAssignStr, null); + singleAssign = new LabelBuilder().name(singleAssignStr).buildLabel(); + + multiAssign = new LabelBuilder().name(multiAssignStr).buildLabel(); tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_NAME, true, "", i18n.get("textfield.name"), true, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/AbstractMetadataPopupLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/AbstractMetadataPopupLayout.java index 972722d36..d3893e40d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/AbstractMetadataPopupLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/AbstractMetadataPopupLayout.java @@ -16,6 +16,7 @@ import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.MetaData; import org.eclipse.hawkbit.repository.model.NamedVersionedEntity; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.WindowBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer; @@ -24,7 +25,6 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; @@ -303,7 +303,7 @@ public abstract class AbstractMetadataPopupLayout extends } private Label createHeaderCaption() { - return SPUIComponentProvider.getLabel(getDefaultCaption(), SPUILabelDefinitions.SP_WIDGET_CAPTION); + return new LabelBuilder().name(getDefaultCaption()).buildCaptionLabel(); } protected VerticalLayout getTabLayout() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterHeader.java index ae497e41e..104d602dd 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterHeader.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.ui.common.filterlayout; import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; @@ -91,7 +92,7 @@ public abstract class AbstractFilterHeader extends VerticalLayout { } private Label createHeaderCaption() { - return SPUIComponentProvider.getLabel(getTitle(), SPUILabelDefinitions.SP_WIDGET_CAPTION); + return new LabelBuilder().name(getTitle()).buildCaptionLabel(); } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableHeader.java index 3631b6678..54fee678f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableHeader.java @@ -12,6 +12,7 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; @@ -203,9 +204,7 @@ public abstract class AbstractTableHeader extends VerticalLayout { } private Label createHeaderCaption() { - final Label captionLabel = SPUIComponentProvider.getLabel(getHeaderCaption(), - SPUILabelDefinitions.SP_WIDGET_CAPTION); - return captionLabel; + return new LabelBuilder().name(getHeaderCaption()).buildCaptionLabel(); } private TextField createSearchField() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java index 1d8880d91..063a5325f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java @@ -15,10 +15,8 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; -import org.eclipse.hawkbit.ui.decorators.HeaderLayoutDecorator; import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator; import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator; -import org.eclipse.hawkbit.ui.decorators.SPUILabelDecorator; import org.eclipse.hawkbit.ui.decorators.SPUITextAreaDecorator; import org.eclipse.hawkbit.ui.decorators.SPUITextFieldDecorator; import org.eclipse.hawkbit.ui.utils.I18N; @@ -33,7 +31,6 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Link; import com.vaadin.ui.Panel; @@ -59,79 +56,6 @@ public final class SPUIComponentProvider { } - /** - * @param className - * @return - */ - public static HorizontalLayout getHorizontalLayout(final Class className) { - HorizontalLayout hLayout = null; - try { - - hLayout = className.newInstance(); - } catch (final InstantiationException exception) { - LOG.error("Error occured while creating HorizontalLayout-" + className, exception); - } catch (final IllegalAccessException exception) { - LOG.error("Error occured while acessing HorizontalLayout-" + className, exception); - } - - return hLayout; - } - - /** - * Get HorizontalLayout UI component. - * - * @return HorizontalLayout as UI - */ - public static HorizontalLayout getHorizontalLayout() { - HorizontalLayout hLayout = null; - try { - hLayout = HorizontalLayout.class.newInstance(); - } catch (final InstantiationException exception) { - LOG.error("Error occured while creating HorizontalLayout-", exception); - } catch (final IllegalAccessException exception) { - LOG.error("Error occured while acessing HorizontalLayout-", exception); - } - - return hLayout; - } - - /** - * @param tableHeaderLayoutDecorator - * @return - */ - public static HorizontalLayout getHeaderLayout( - final Class tableHeaderLayoutDecorator) { - // Do we really need this??? - HorizontalLayout hLayout = getHorizontalLayout(new SPUIHorizontalLayout().getUiHorizontalLayout().getClass()); - - if (tableHeaderLayoutDecorator == null) { - return hLayout; - } - - try { - final HeaderLayoutDecorator layoutDecorator = tableHeaderLayoutDecorator.newInstance(); - hLayout = layoutDecorator.decorate(hLayout); - - } catch (final InstantiationException | IllegalAccessException exception) { - LOG.error("Error occured while creating horizontal decorator " + HeaderLayoutDecorator.class, exception); - } - - return hLayout; - } - - /** - * Get Label UI component. - * - * @param name - * label caption - * @param type - * string simple|Confirm|Message - * @return Label - */ - public static Label getLabel(final String name, final String type) { - return SPUILabelDecorator.getDeocratedLabel(name, type); - } - /** * Get Label UI component. * diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIHorizontalLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIHorizontalLayout.java deleted file mode 100644 index 33d040330..000000000 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIHorizontalLayout.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.hawkbit.ui.components; - -import com.vaadin.ui.HorizontalLayout; - -/** - * Plain Horizontal Layout. - * - * - * - */ - -public class SPUIHorizontalLayout { - private final HorizontalLayout uiHorizontalLayout; - - /** - * Default constructor. - */ - public SPUIHorizontalLayout() { - uiHorizontalLayout = new HorizontalLayout(); - decorate(); - } - - /** - * Decorate. - */ - private void decorate() { - uiHorizontalLayout.setImmediate(false); - uiHorizontalLayout.setMargin(false); - uiHorizontalLayout.setSpacing(true); - - } - - /** - * Get HorizontalLayout. - * - * @return HorizontalLayout as UI - */ - public HorizontalLayout getUiHorizontalLayout() { - return uiHorizontalLayout; - } -} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUILabelDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUILabelDecorator.java deleted file mode 100644 index a42b51566..000000000 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUILabelDecorator.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.hawkbit.ui.decorators; - -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; - -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.ui.Label; -import com.vaadin.ui.themes.ValoTheme; - -/** - * Simple Decorator for the label. - * - * - * - * - * - */ -public final class SPUILabelDecorator { - - /** - * Private Constructor. - */ - private SPUILabelDecorator() { - - } - - /** - * Simple decorator. - * - * @param name - * as String - * @param type - * as String - * @return Label - */ - public static Label getDeocratedLabel(final String name, final String type) { - final Label spUILabel = new Label(name); - // Set style. - final StringBuilder style = new StringBuilder(ValoTheme.LABEL_SMALL); - style.append(' '); - style.append(ValoTheme.LABEL_BOLD); - spUILabel.addStyleName(style.toString()); - if (SPUILabelDefinitions.SP_WIDGET_CAPTION.equalsIgnoreCase(type)) { - spUILabel.setValue(name); - spUILabel.addStyleName("header-caption"); - } else if (SPUILabelDefinitions.SP_LABEL_MESSAGE.equalsIgnoreCase(type)) { - spUILabel.setContentMode(ContentMode.HTML); - spUILabel.addStyleName(SPUILabelDefinitions.SP_LABEL_MESSAGE_STYLE); - } else { - spUILabel.setImmediate(false); - spUILabel.setWidth("-1px"); - spUILabel.setHeight("-1px"); - } - - return spUILabel; - } - -} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java index 1023d98ed..a5ff7be66 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java @@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.ui.UiProperties; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; @@ -217,10 +218,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button breadcrumbButton = createBreadcrumbButton(); - headerCaption = SPUIComponentProvider.getLabel(SPUILabelDefinitions.VAR_CREATE_FILTER, - SPUILabelDefinitions.SP_WIDGET_CAPTION); + headerCaption = new LabelBuilder().name(SPUILabelDefinitions.VAR_CREATE_FILTER).buildCaptionLabel(); - nameLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + nameLabel = new LabelBuilder().name("").buildLabel(); nameLabel.setId(SPUIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LABEL_ID); nameTextField = createNameTextField(); @@ -307,7 +307,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button breadcrumbLayout = new HorizontalLayout(); breadcrumbLayout.addComponent(breadcrumbButton); breadcrumbLayout.addComponent(new Label(">")); - breadcrumbName = SPUIComponentProvider.getLabel(null, SPUILabelDefinitions.SP_WIDGET_CAPTION); + breadcrumbName = new LabelBuilder().buildCaptionLabel(); breadcrumbLayout.addComponent(breadcrumbName); breadcrumbName.addStyleName("breadcrumbPaddingLeft"); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java index bb5707c40..e447a257a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java @@ -19,7 +19,7 @@ import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; -import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator; @@ -209,7 +209,7 @@ public class CreateOrUpdateFilterTable extends Table { final Item row1 = getItem(itemId); final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1 .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); - final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + final Label label = new LabelBuilder().name("").buildLabel(); label.setContentMode(ContentMode.HTML); if (targetStatus == TargetUpdateStatus.PENDING) { label.setDescription("Pending"); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java index b5d796ebb..32347ae24 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.filtermanagement; import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; @@ -78,8 +79,7 @@ public class TargetFilterHeader extends VerticalLayout { } private Label createHeaderCaption() { - return SPUIComponentProvider.getLabel(SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION, - SPUILabelDefinitions.SP_WIDGET_CAPTION); + return new LabelBuilder().name(SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION).buildCaptionLabel(); } private void buildLayout() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java index 91b11146a..bd62a0cb0 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java @@ -19,6 +19,7 @@ import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerLayout; import org.eclipse.hawkbit.ui.common.CommonDialogWindow; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.WindowBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -147,8 +148,8 @@ public abstract class AbstractCreateUpdateTagLayout extends CustomComponent createTagStr = i18n.get("label.create.tag"); updateTagStr = i18n.get("label.update.tag"); - comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null); - colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null); + comboLabel = new LabelBuilder().name(i18n.get("label.choose.tag")).buildLabel(); + colorLabel = new LabelBuilder().name(i18n.get("label.choose.tag.color")).buildLabel(); colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE); tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/CreateUpdateTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/CreateUpdateTypeLayout.java index f25a4b485..e15dcffc3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/CreateUpdateTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/CreateUpdateTypeLayout.java @@ -13,6 +13,7 @@ import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; @@ -56,8 +57,9 @@ public abstract class CreateUpdateTypeLayout extends AbstractCreateUpdateTagLayo createTypeStr = i18n.get("label.create.type"); updateTypeStr = i18n.get("label.update.type"); - comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null); - colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type.color"), null); + comboLabel = new LabelBuilder().name(i18n.get("label.choose.type")).buildLabel(); + colorLabel = new LabelBuilder().name(i18n.get("label.choose.type.color")).buildLabel(); + colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE); tagNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, null, false, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryHeader.java index 828b61d43..22551f28c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryHeader.java @@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.management.actionhistory; import javax.annotation.PostConstruct; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; @@ -17,7 +18,6 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus; @@ -63,8 +63,9 @@ public class ActionHistoryHeader extends VerticalLayout { private void buildComponent() { // create default title - it will be shown even when no data is // available - titleOfActionHistory = SPUIComponentProvider.getLabel(HawkbitCommonUtil.getArtifactoryDetailsLabelId(""), - SPUILabelDefinitions.SP_WIDGET_CAPTION); + titleOfActionHistory = new LabelBuilder().name(HawkbitCommonUtil.getArtifactoryDetailsLabelId("")) + .buildCaptionLabel(); + titleOfActionHistory.setImmediate(true); titleOfActionHistory.setContentMode(ContentMode.HTML); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java index ffc7d1e3a..71c489aa0 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java @@ -25,6 +25,7 @@ import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.ActionWithStatusCount; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.ui.common.ConfirmationDialog; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; @@ -36,7 +37,6 @@ import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -357,7 +357,7 @@ public class ActionHistoryTable extends TreeTable { private Component getForcedColumn(final Object itemId) { final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(itemId) .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue(); - final Label actionLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + final Label actionLabel = new LabelBuilder().name("").buildCaptionLabel(); actionLabel.setContentMode(ContentMode.HTML); actionLabel.setStyleName("action-history-table-col-forced-label"); if (actionWithActiveStatus != null && actionWithActiveStatus.getActionType() == ActionType.FORCED) { @@ -522,7 +522,7 @@ public class ActionHistoryTable extends TreeTable { * @return Label as UI */ private Label getStatusIcon(final Action.Status status) { - final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + final Label label = new LabelBuilder().name("").buildLabel(); final String statusIconPending = "statusIconPending"; label.setContentMode(ContentMode.HTML); if (Action.Status.FINISHED == status) { @@ -576,7 +576,7 @@ public class ActionHistoryTable extends TreeTable { final long currentTimeMillis = System.currentTimeMillis(); final HorizontalLayout hLayout = new HorizontalLayout(); - final Label autoForceLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + final Label autoForceLabel = new LabelBuilder().name("").buildLabel(); actionLabel.setValue(FontAwesome.BOLT.getHtml()); autoForceLabel.setContentMode(ContentMode.HTML); @@ -608,8 +608,8 @@ public class ActionHistoryTable extends TreeTable { * as String * @return Labeal as UI */ - private Label createActiveStatusLabel(final String activeValue, final boolean endedWithError) { - final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + private static Label createActiveStatusLabel(final String activeValue, final boolean endedWithError) { + final Label label = new LabelBuilder().name("").buildLabel(); label.setContentMode(ContentMode.HTML); if (SPUIDefinitions.SCHEDULED.equals(activeValue)) { label.setDescription("Scheduled"); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/FilterByStatusLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/FilterByStatusLayout.java index 27a53bfed..67f74d064 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/FilterByStatusLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/FilterByStatusLayout.java @@ -12,6 +12,7 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; @@ -20,7 +21,6 @@ import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIButtonDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventScope; @@ -84,8 +84,8 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click addStyleName("target-status-filters"); setMargin(false); - final Label targetFilterStatusLabel = SPUIComponentProvider.getLabel(i18n.get("label.filter.by.status"), - SPUILabelDefinitions.SP_LABEL_SIMPLE); + final Label targetFilterStatusLabel = new LabelBuilder().name(i18n.get("label.filter.by.status")).buildLabel(); + targetFilterStatusLabel.addStyleName("target-status-filters-title"); addComponent(targetFilterStatusLabel); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java index bd18ea113..2e0399225 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java @@ -30,6 +30,7 @@ import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.common.CommonDialogWindow; import org.eclipse.hawkbit.ui.common.DistributionSetIdName; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.WindowBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.filtermanagement.TargetFilterBeanQuery; @@ -258,7 +259,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { } private Label getLabel(final String key) { - return SPUIComponentProvider.getLabel(i18n.get(key), SPUILabelDefinitions.SP_LABEL_SIMPLE); + return new LabelBuilder().name(i18n.get(key)).buildLabel(); } private TextField getTextfield(final String key) { @@ -266,7 +267,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH); } - private Label getPercentHintLabel() { + private static Label getPercentHintLabel() { final Label percentSymbol = new Label("%"); percentSymbol.addStyleName(ValoTheme.LABEL_TINY + " " + ValoTheme.LABEL_BOLD); percentSymbol.setSizeUndefined(); @@ -295,7 +296,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { } private Label createGroupSizeLabel() { - final Label groupSize = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + final Label groupSize = new LabelBuilder().name("").buildLabel(); groupSize.addStyleName(ValoTheme.LABEL_TINY + " " + "rollout-target-count-message"); groupSize.setImmediate(true); groupSize.setVisible(false); @@ -315,7 +316,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { } private Label createTotalTargetsLabel() { - final Label targetCountLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); + final Label targetCountLabel = new LabelBuilder().name("").buildLabel(); targetCountLabel.addStyleName(ValoTheme.LABEL_TINY + " " + "rollout-target-count-message"); targetCountLabel.setImmediate(true); targetCountLabel.setVisible(false); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListHeader.java index 81608d42d..f0f14432b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListHeader.java @@ -11,13 +11,12 @@ package org.eclipse.hawkbit.ui.rollout.rollout; import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader; -import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus; @@ -134,8 +133,7 @@ public class RolloutListHeader extends AbstractGridHeader { @Override protected HorizontalLayout getHeaderCaptionLayout() { - final Label headerCaption = SPUIComponentProvider.getLabel(getHeaderCaption(), - SPUILabelDefinitions.SP_WIDGET_CAPTION); + final Label headerCaption = new LabelBuilder().name(getHeaderCaption()).buildCaptionLabel(); final HorizontalLayout headerCaptionLayout = new HorizontalLayout(); headerCaptionLayout.addComponent(headerCaption); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupsListHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupsListHeader.java index 9e4d18143..2e01a7c05 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupsListHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupsListHeader.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.rollout.rolloutgroup; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; @@ -18,7 +19,6 @@ import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventScope; @@ -149,7 +149,7 @@ public class RolloutGroupsListHeader extends AbstractGridHeader { @Override protected HorizontalLayout getHeaderCaptionLayout() { - headerCaption = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_WIDGET_CAPTION); + headerCaption = new LabelBuilder().name("").buildCaptionLabel(); headerCaption.setId(SPUIComponentIdProvider.ROLLOUT_GROUP_HEADER_CAPTION); final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null, SPUIButtonStyleSmallNoBorder.class); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListHeader.java index c22bed8dd..965e1e9b2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListHeader.java @@ -12,6 +12,7 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.model.RolloutGroup; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; @@ -19,7 +20,6 @@ import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventScope; @@ -164,7 +164,7 @@ public class RolloutGroupTargetsListHeader extends AbstractGridHeader { @Override protected HorizontalLayout getHeaderCaptionLayout() { - headerCaption = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_WIDGET_CAPTION); + headerCaption = new LabelBuilder().name("").buildCaptionLabel(); headerCaption.setStyleName(ValoTheme.LABEL_BOLD + " " + ValoTheme.LABEL_SMALL); final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null, SPUIButtonStyleSmallNoBorder.class); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AbstractAuthenticationTenantConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AbstractAuthenticationTenantConfigurationItem.java index 4f222f080..a31de899f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AbstractAuthenticationTenantConfigurationItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AbstractAuthenticationTenantConfigurationItem.java @@ -13,9 +13,8 @@ import java.util.List; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; -import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.utils.I18N; -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.springframework.beans.factory.annotation.Autowired; import com.vaadin.ui.VerticalLayout; @@ -58,7 +57,7 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay */ protected void init(final String labelText) { setImmediate(true); - addComponent(SPUIComponentProvider.getLabel(i18n.get(labelText), SPUILabelDefinitions.SP_LABEL_SIMPLE)); + addComponent(new LabelBuilder().name(i18n.get(labelText)).buildLabel()); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/CertificateAuthenticationConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/CertificateAuthenticationConfigurationItem.java index 872bdef29..d7203772a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/CertificateAuthenticationConfigurationItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/CertificateAuthenticationConfigurationItem.java @@ -12,8 +12,8 @@ import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.springframework.beans.factory.annotation.Autowired; import com.vaadin.spring.annotation.SpringComponent; @@ -61,8 +61,7 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti final HorizontalLayout caRootAuthorityLayout = new HorizontalLayout(); caRootAuthorityLayout.setSpacing(true); - final Label caRootAuthorityLabel = SPUIComponentProvider.getLabel("SSL Issuer Hash:", - SPUILabelDefinitions.SP_LABEL_SIMPLE); + 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."); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java index 31e910ddc..572cfe763 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java @@ -13,6 +13,7 @@ import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.security.SecurityTokenGenerator; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; +import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; @@ -87,8 +88,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac gatewaytokenBtn.setIcon(FontAwesome.REFRESH); gatewaytokenBtn.addClickListener(event -> generateGatewayToken()); - gatewayTokenkeyLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); - gatewayTokenkeyLabel.setId("gatewaysecuritytokenkey"); + gatewayTokenkeyLabel = new LabelBuilder().id("gatewaysecuritytokenkey").name("").buildLabel(); gatewayTokenkeyLabel.addStyleName("gateway-token-label"); gatewayTokenkeyLabel.setImmediate(true); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java index 22d680872..a5bb24831 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java @@ -20,18 +20,6 @@ import com.vaadin.ui.themes.ValoTheme; */ public final class SPUILabelDefinitions { - /** - * Label - Table. - */ - public static final String SP_WIDGET_CAPTION = "Label-table"; - /** - * Label - Simple. - */ - public static final String SP_LABEL_SIMPLE = "Label-simple"; - /** - * Label - Message. - */ - public static final String SP_LABEL_MESSAGE = "Label-message"; /** * Label - Message hint. */ diff --git a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java index f818bc15d..9fc6c5855 100644 --- a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java +++ b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java @@ -15,9 +15,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorderUH; import org.junit.Test; -import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Button; -import com.vaadin.ui.Label; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @@ -46,22 +44,4 @@ public class SPUIComponentProviderTest { assertThat(placeHolderButton.getStyleName()).isEqualTo(SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE); } - /** - * Test case for check Label factory. - * - * @throws Exception - */ - @Test - public void checkLabelFactory() throws Exception { - - Label placeHolderLabel = null; - placeHolderLabel = SPUIComponentProvider.getLabel("TestTable", SPUILabelDefinitions.SP_WIDGET_CAPTION); - assertThat(placeHolderLabel).isInstanceOf(Label.class); - assertThat(placeHolderLabel.getValue()).isEqualTo("TestTable"); - assertThat(placeHolderLabel.getContentMode()).isNotEqualTo(ContentMode.HTML); - placeHolderLabel = SPUIComponentProvider.getLabel("TestMSG", SPUILabelDefinitions.SP_LABEL_MESSAGE); - assertThat(placeHolderLabel.getValue()).isEqualTo("TestMSG"); - assertThat(placeHolderLabel.getContentMode()).isEqualTo(ContentMode.HTML); - } - }