Add LabelBuilder

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-08-16 14:38:21 +02:00
parent d3d07046ec
commit a51bf0ac02
29 changed files with 185 additions and 281 deletions

View File

@@ -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);

View File

@@ -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,

View File

@@ -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<E extends NamedVersionedEntity
}
private Label createHeaderCaption() {
return SPUIComponentProvider.getLabel(i18n.get("caption.metadata"), SPUILabelDefinitions.SP_WIDGET_CAPTION);
return new LabelBuilder().name(i18n.get("caption.metadata")).buildCaptionLabel();
}
private static IndexedContainer getMetadataContainer() {

View File

@@ -0,0 +1,111 @@
/**
* 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.common.builder;
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 class LabelBuilder {
private String name;
private String id;
private boolean visible = true;
/**
* @param name
* the name to set
* @return builder
*/
public LabelBuilder name(final String name) {
this.name = name;
return this;
}
/**
* @param id
* the id to set
* @return builder
*/
public LabelBuilder id(final String id) {
this.id = id;
return this;
}
/**
* @param visible
* the visible to set
* @return builder
*/
public LabelBuilder visible(final boolean visible) {
this.visible = visible;
return this;
}
/**
* Simple builder.
*
* @return Label
*/
public Label buildCaptionLabel() {
final Label label = createLabel();
label.setValue(name);
label.addStyleName("header-caption");
return label;
}
/**
* Simple builder.
*
* @return Label
*/
public Label buildMessageLabel() {
final Label label = createLabel();
label.setContentMode(ContentMode.HTML);
label.addStyleName(SPUILabelDefinitions.SP_LABEL_MESSAGE_STYLE);
return label;
}
/**
* Simple builder.
*
* @return Label
*/
public Label buildLabel() {
final Label label = createLabel();
label.setImmediate(false);
label.setWidth("-1px");
label.setHeight("-1px");
return label;
}
private Label createLabel() {
final Label label = new Label(name);
label.setVisible(visible);
final StringBuilder style = new StringBuilder(ValoTheme.LABEL_SMALL);
style.append(' ');
style.append(ValoTheme.LABEL_BOLD);
label.addStyleName(style.toString());
if (id != null) {
label.setId(id);
}
return label;
}
}

View File

@@ -1,3 +1,11 @@
/**
* 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.common.builder;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;

View File

@@ -13,6 +13,7 @@ import java.util.Map.Entry;
import javax.annotation.PostConstruct;
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.I18N;
@@ -51,6 +52,9 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
@Autowired
protected transient EventBus.SessionEventBus eventBus;
/**
* PostConstruct.
*/
@PostConstruct
public void initialize() {
removeAllComponents();
@@ -65,10 +69,9 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
}
private void createActionMessgaeLabel() {
actionMessage = SPUIComponentProvider.getLabel("", null);
actionMessage = new LabelBuilder().name("").id(SPUIComponentIdProvider.ACTION_LABEL).visible(false)
.buildLabel();
actionMessage.addStyleName(SPUIStyleDefinitions.CONFIRM_WINDOW_INFO_BOX);
actionMessage.setId(SPUIComponentIdProvider.ACTION_LABEL);
actionMessage.setVisible(false);
}
private void createAccordian() {

View File

@@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -25,7 +26,6 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
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.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
@@ -183,7 +183,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
}
private Label createHeaderCaption() {
return SPUIComponentProvider.getLabel(getDefaultCaption(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
return new LabelBuilder().name(getDefaultCaption()).buildCaptionLabel();
}
protected VerticalLayout getTabLayout() {

View File

@@ -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();
}
/**

View File

@@ -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() {

View File

@@ -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<? extends HorizontalLayout> 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<? extends HeaderLayoutDecorator> 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.
*

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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");

View File

@@ -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");

View File

@@ -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() {

View File

@@ -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"), "",

View File

@@ -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,

View File

@@ -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);

View File

@@ -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");

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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.");

View File

@@ -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);

View File

@@ -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.
*/

View File

@@ -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);
}
}