From 809fe4a8b67f344fed56db118ccade70701932e5 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 13 Mar 2017 09:32:59 +0100 Subject: [PATCH] Removed i18n class that was based on Vaadin4Spring utility. (#455) * Removed i18n class that was based on Vaadin4Spring utility. Signed-off-by: kaizimmerm --- .../org/eclipse/hawkbit/ui/ErrorView.java | 12 +- .../org/eclipse/hawkbit/ui/HawkbitUI.java | 7 +- .../hawkbit/ui/MgmtUiConfiguration.java | 15 ++- .../ui/artifacts/UploadArtifactView.java | 8 +- .../details/ArtifactDetailsLayout.java | 26 ++-- .../footer/SMDeleteActionsLayout.java | 8 +- .../UploadViewConfirmationWindowLayout.java | 36 +++--- .../SoftwareModuleAddUpdateWindow.java | 24 ++-- .../smtable/SoftwareModuleDetails.java | 26 ++-- .../smtable/SoftwareModuleTable.java | 8 +- .../smtable/SoftwareModuleTableHeader.java | 8 +- .../smtable/SoftwareModuleTableLayout.java | 4 +- .../CreateUpdateSoftwareTypeLayout.java | 26 ++-- .../artifacts/smtype/SMTypeFilterHeader.java | 4 +- .../artifacts/smtype/SMTypeFilterLayout.java | 4 +- .../upload/UploadConfirmationWindow.java | 32 ++--- .../ui/artifacts/upload/UploadHandler.java | 16 +-- .../ui/artifacts/upload/UploadLayout.java | 28 ++--- .../artifacts/upload/UploadResultWindow.java | 18 +-- .../upload/UploadStatusInfoWindow.java | 12 +- .../common/AbstractMetadataPopupLayout.java | 40 +++---- .../hawkbit/ui/common/CommonDialogWindow.java | 8 +- .../ui/common/builder/WindowBuilder.java | 6 +- .../AbstractConfirmationWindowLayout.java | 6 +- ...amedVersionedEntityTableDetailsLayout.java | 4 +- .../AbstractTableDetailsLayout.java | 18 +-- .../DistributionSetMetadatadetailslayout.java | 10 +- .../SoftwareModuleDetailsTable.java | 14 +-- .../SoftwareModuleMetadatadetailslayout.java | 8 +- .../TargetFilterQueryDetailsTable.java | 10 +- .../filterlayout/AbstractFilterHeader.java | 6 +- .../footer/AbstractDeleteActionsLayout.java | 12 +- .../hawkbit/ui/common/grid/AbstractGrid.java | 6 +- .../ui/common/grid/AbstractGridHeader.java | 6 +- .../table/AbstractNamedVersionTable.java | 6 +- .../ui/common/table/AbstractTable.java | 26 ++-- .../ui/common/table/AbstractTableHeader.java | 6 +- .../common/tagdetails/AbstractTagToken.java | 6 +- .../tagdetails/AbstractTargetTagToken.java | 4 +- .../tagdetails/DistributionTagToken.java | 8 +- .../ui/common/tagdetails/TargetTagToken.java | 8 +- .../components/DistributionSetInfoPanel.java | 6 +- .../ui/components/HawkbitUIErrorHandler.java | 8 +- .../components/NotificationUnreadButton.java | 12 +- .../components/SPTargetAttributesLayout.java | 6 +- .../ui/components/SPUIComponentProvider.java | 10 +- .../ui/distributions/DistributionsView.java | 8 +- .../CreateUpdateDistSetTypeLayout.java | 34 +++--- .../disttype/DSTypeFilterHeader.java | 4 +- .../disttype/DSTypeFilterLayout.java | 4 +- .../dstable/DistributionSetDetails.java | 28 ++--- .../dstable/DistributionSetTable.java | 20 ++-- .../dstable/DistributionSetTableHeader.java | 8 +- .../dstable/DistributionSetTableLayout.java | 4 +- .../dstable/DsMetadataPopupLayout.java | 4 +- .../footer/DSDeleteActionsLayout.java | 18 +-- ...DistributionsConfirmationWindowLayout.java | 80 ++++++------- .../smtable/SwMetadataPopupLayout.java | 4 +- .../smtable/SwModuleDetails.java | 26 ++-- .../distributions/smtable/SwModuleTable.java | 10 +- .../smtable/SwModuleTableHeader.java | 8 +- .../smtable/SwModuleTableLayout.java | 4 +- .../smtype/DistSMTypeFilterHeader.java | 4 +- .../smtype/DistSMTypeFilterLayout.java | 4 +- .../CreateOrUpdateFilterHeader.java | 24 ++-- .../CreateOrUpdateFilterTable.java | 24 ++-- .../CustomTargetBeanQuery.java | 8 +- .../DistributionSetSelectTable.java | 10 +- .../DistributionSetSelectWindow.java | 22 ++-- .../FilterManagementView.java | 4 +- .../filtermanagement/TargetFilterTable.java | 32 ++--- .../footer/TargetFilterCountMessageLabel.java | 12 +- .../AbstractCreateUpdateTagLayout.java | 30 ++--- .../ui/layouts/CreateUpdateTypeLayout.java | 16 +-- .../eclipse/hawkbit/ui/login/LoginView.java | 32 ++--- .../hawkbit/ui/management/DeploymentView.java | 8 +- .../actionhistory/ActionHistoryComponent.java | 4 +- .../actionhistory/ActionHistoryTable.java | 38 +++--- .../DistributionAddUpdateWindowLayout.java | 28 ++--- .../dstable/DistributionDetails.java | 28 ++--- .../management/dstable/DistributionTable.java | 22 ++-- .../dstable/DistributionTableHeader.java | 6 +- .../dstable/DistributionTableLayout.java | 4 +- ...eateUpdateDistributionTagLayoutWindow.java | 10 +- .../dstag/DistributionTagButtons.java | 4 +- .../dstag/DistributionTagHeader.java | 6 +- .../dstag/DistributionTagLayout.java | 4 +- .../event/DistributionTagDropEvent.java | 14 +-- .../footer/ActionTypeOptionGroupLayout.java | 15 +-- .../management/footer/CountMessageLabel.java | 34 +++--- .../footer/DeleteActionsLayout.java | 34 +++--- .../ManangementConfirmationWindowLayout.java | 54 ++++----- .../targettable/BulkUploadHandler.java | 14 +-- .../TargetAddUpdateWindowLayout.java | 24 ++-- .../targettable/TargetBeanQuery.java | 8 +- .../targettable/TargetBulkTokenTags.java | 6 +- .../TargetBulkUpdateWindowLayout.java | 16 +-- .../management/targettable/TargetDetails.java | 34 +++--- .../management/targettable/TargetTable.java | 26 ++-- .../targettable/TargetTableHeader.java | 16 +-- .../targettable/TargetTableLayout.java | 4 +- .../CreateUpdateTargetTagLayoutWindow.java | 8 +- .../targettag/FilterByStatusLayout.java | 22 ++-- .../targettag/MultipleTargetFilter.java | 12 +- .../targettag/TargetTagFilterButtons.java | 16 +-- .../targettag/TargetTagFilterHeader.java | 6 +- .../targettag/TargetTagFilterLayout.java | 4 +- .../hawkbit/ui/menu/DashboardMenu.java | 20 ++-- .../hawkbit/ui/rollout/RolloutView.java | 4 +- .../rollout/AddUpdateRolloutWindowLayout.java | 46 +++---- .../rollout/AutoStartOptionGroupLayout.java | 21 ++-- .../rollout/rollout/DefineGroupsLayout.java | 26 ++-- .../rollout/rollout/GroupsLegendLayout.java | 14 +-- .../ui/rollout/rollout/RolloutListGrid.java | 64 +++++----- .../ui/rollout/rollout/RolloutListHeader.java | 4 +- .../ui/rollout/rollout/RolloutListView.java | 4 +- .../rolloutgroup/RolloutGroupListGrid.java | 28 ++--- .../rolloutgroup/RolloutGroupsListHeader.java | 8 +- .../rolloutgroup/RolloutGroupsListView.java | 4 +- .../RolloutGroupTargetsCountLabelMessage.java | 12 +- .../RolloutGroupTargetsListGrid.java | 20 ++-- .../RolloutGroupTargetsListHeader.java | 8 +- .../RolloutGroupTargetsListView.java | 4 +- .../AuthenticationConfigurationView.java | 8 +- .../DefaultDistributionSetTypeLayout.java | 8 +- .../PollingConfigurationView.java | 14 +-- .../TenantConfigurationDashboardView.java | 14 +-- ...AuthenticationTenantConfigurationItem.java | 8 +- ...wnloadAuthenticationConfigurationItem.java | 4 +- ...ficateAuthenticationConfigurationItem.java | 4 +- ...yTokenAuthenticationConfigurationItem.java | 4 +- ...yTokenAuthenticationConfigurationItem.java | 4 +- .../hawkbit/ui/utils/HawkbitCommonUtil.java | 31 +++-- .../org/eclipse/hawkbit/ui/utils/I18N.java | 113 ------------------ .../hawkbit/ui/utils/SPDateTimeUtil.java | 12 +- .../hawkbit/ui/utils/VaadinMessageSource.java | 65 ++++++++++ 136 files changed, 1069 insertions(+), 1104 deletions(-) delete mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/I18N.java create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/VaadinMessageSource.java diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/ErrorView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/ErrorView.java index ced736b96..e284d4523 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/ErrorView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/ErrorView.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui; import org.eclipse.hawkbit.ui.menu.DashboardMenu; import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.springframework.beans.factory.annotation.Autowired; @@ -40,12 +40,12 @@ class ErrorView extends VerticalLayout implements View { private final Label message; - private final I18N i18n; + private final VaadinMessageSource i18n; private final DashboardMenu dashboardMenu; @Autowired - ErrorView(final I18N i18n, final DashboardMenu dashboardMenu) { + ErrorView(final VaadinMessageSource i18n, final DashboardMenu dashboardMenu) { this.i18n = i18n; this.dashboardMenu = dashboardMenu; setMargin(true); @@ -57,17 +57,17 @@ class ErrorView extends VerticalLayout implements View { public void enter(final ViewChangeListener.ViewChangeEvent event) { final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName()); if (view == null) { - message.setValue(i18n.get("message.error.view", new Object[] { event.getViewName() })); + message.setValue(i18n.getMessage("message.error.view", new Object[] { event.getViewName() })); return; } if (dashboardMenu.isAccessDenied(event.getViewName())) { final Notification nt = new Notification("Access denied", - i18n.get("message.accessdenied.view", new Object[] { event.getViewName() }), Type.ERROR_MESSAGE, + i18n.getMessage("message.accessdenied.view", new Object[] { event.getViewName() }), Type.ERROR_MESSAGE, false); nt.setStyleName(SPUILabelDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE); nt.setPosition(Position.BOTTOM_RIGHT); nt.show(UI.getCurrent().getPage()); - message.setValue(i18n.get("message.accessdenied.view", new Object[] { event.getViewName() })); + message.setValue(i18n.getMessage("message.accessdenied.view", new Object[] { event.getViewName() })); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java index c2a9350a5..9575aa5b6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java @@ -21,7 +21,7 @@ import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent; import org.eclipse.hawkbit.ui.menu.DashboardMenu; import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; import org.eclipse.hawkbit.ui.push.EventPushStrategy; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.slf4j.Logger; @@ -75,9 +75,6 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { @Autowired private transient ApplicationContext context; - @Autowired - private I18N i18n; - @Autowired private DashboardMenu dashboardMenu; @@ -200,7 +197,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { UI.getCurrent().setErrorHandler(new HawkbitUIErrorHandler()); } - LOG.info("Current locale of the application is : {}", i18n.getLocale()); + LOG.info("Current locale of the application is : {}", HawkbitCommonUtil.getLocale()); } private Component buildHeader() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/MgmtUiConfiguration.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/MgmtUiConfiguration.java index 24e377564..dd993e5f6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/MgmtUiConfiguration.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/MgmtUiConfiguration.java @@ -9,8 +9,10 @@ package org.eclipse.hawkbit.ui; import org.eclipse.hawkbit.im.authentication.PermissionService; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -26,15 +28,16 @@ import org.springframework.context.annotation.Import; @EnableConfigurationProperties(UiProperties.class) public class MgmtUiConfiguration { - /** - * @param permissionService - * to use in the checker - * @return {@link SpPermissionChecker} bean - */ @Bean @ConditionalOnMissingBean - public SpPermissionChecker spPermissionChecker(final PermissionService permissionService) { + SpPermissionChecker spPermissionChecker(final PermissionService permissionService) { return new SpPermissionChecker(permissionService); } + @Bean + @ConditionalOnMissingBean + VaadinMessageSource messageSourceVaadin(final MessageSource source) { + return new VaadinMessageSource(source); + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java index 17d14f05a..12dc79389 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java @@ -28,7 +28,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.upload.UploadLayout; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; @@ -64,7 +64,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW private final SpPermissionChecker permChecker; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UINotification uiNotification; @@ -88,7 +88,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW private DragAndDropWrapper dadw; @Autowired - UploadArtifactView(final UIEventBus eventBus, final SpPermissionChecker permChecker, final I18N i18n, + UploadArtifactView(final UIEventBus eventBus, final SpPermissionChecker permChecker, final VaadinMessageSource i18n, final UINotification uiNotification, final ArtifactUploadState artifactUploadState, final TagManagement tagManagement, final EntityFactory entityFactory, final SoftwareManagement softwareManagement, final UploadViewClientCriterion uploadViewClientCriterion, @@ -256,7 +256,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW private void checkNoDataAvaialble() { if (artifactUploadState.isNoDataAvilableSoftwareModule()) { - uiNotification.displayValidationError(i18n.get("message.no.data")); + uiNotification.displayValidationError(i18n.getMessage("message.no.data")); } } 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 2ff15d8ae..32dd87a43 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 @@ -27,7 +27,7 @@ import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; @@ -80,7 +80,7 @@ public class ArtifactDetailsLayout extends VerticalLayout { private static final String MD5HASH = "md5Hash"; - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient EventBus.UIEventBus eventBus; @@ -102,7 +102,7 @@ public class ArtifactDetailsLayout extends VerticalLayout { private final transient ArtifactManagement artifactManagement; - public ArtifactDetailsLayout(final I18N i18n, final UIEventBus eventBus, + public ArtifactDetailsLayout(final VaadinMessageSource i18n, final UIEventBus eventBus, final ArtifactUploadState artifactUploadState, final UINotification uINotification, final ArtifactManagement artifactManagement) { this.i18n = i18n; @@ -251,12 +251,12 @@ public class ArtifactDetailsLayout extends VerticalLayout { private void confirmAndDeleteArtifact(final Long id, final String fileName) { - final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.delete.artifact.confirmbox"), - i18n.get("message.delete.artifact", new Object[] { fileName }), i18n.get("button.ok"), - i18n.get("button.cancel"), ok -> { + final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.getMessage("caption.delete.artifact.confirmbox"), + i18n.getMessage("message.delete.artifact", new Object[] { fileName }), i18n.getMessage("button.ok"), + i18n.getMessage("button.cancel"), ok -> { if (ok) { artifactManagement.deleteArtifact(id); - uINotification.displaySuccess(i18n.get("message.artifact.deleted", fileName)); + uINotification.displaySuccess(i18n.getMessage("message.artifact.deleted", fileName)); if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) { populateArtifactDetails(artifactUploadState.getSelectedBaseSwModuleId().get(), HawkbitCommonUtil.getFormattedNameVersion( @@ -274,15 +274,15 @@ public class ArtifactDetailsLayout extends VerticalLayout { private void setTableColumnDetails(final Table table) { - table.setColumnHeader(PROVIDED_FILE_NAME, i18n.get("upload.file.name")); - table.setColumnHeader(SIZE, i18n.get("upload.size")); + table.setColumnHeader(PROVIDED_FILE_NAME, i18n.getMessage("upload.file.name")); + table.setColumnHeader(SIZE, i18n.getMessage("upload.size")); if (fullWindowMode) { - table.setColumnHeader(SHA1HASH, i18n.get("upload.sha1")); - table.setColumnHeader(MD5HASH, i18n.get("upload.md5")); + table.setColumnHeader(SHA1HASH, i18n.getMessage("upload.sha1")); + table.setColumnHeader(MD5HASH, i18n.getMessage("upload.md5")); } - table.setColumnHeader(CREATE_MODIFIED_DATE_UPLOAD, i18n.get("upload.last.modified.date")); + table.setColumnHeader(CREATE_MODIFIED_DATE_UPLOAD, i18n.getMessage("upload.last.modified.date")); if (!readOnly) { - table.setColumnHeader(ACTION, i18n.get("upload.action")); + table.setColumnHeader(ACTION, i18n.getMessage("upload.action")); } table.setColumnExpandRatio(PROVIDED_FILE_NAME, 3.5F); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java index b9156da39..99df46fbd 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java @@ -17,7 +17,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; import org.eclipse.hawkbit.ui.common.table.AbstractTable; import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -45,7 +45,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { private final UploadViewClientCriterion uploadViewClientCriterion; - public SMDeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus, + public SMDeleteActionsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus, final UINotification notification, final ArtifactUploadState artifactUploadState, final SoftwareManagement softwareManagement, final UploadViewClientCriterion uploadViewClientCriterion) { super(i18n, permChecker, eventBus, notification); @@ -104,7 +104,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { @Override protected String getDeleteAreaLabel() { - return i18n.get("label.software.module.drop.area"); + return i18n.getMessage("label.software.module.drop.area"); } @Override @@ -132,7 +132,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType() .map(type -> type.getName().equalsIgnoreCase(swModuleTypeName)).orElse(false)) { notification.displayValidationError( - i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName })); + i18n.getMessage("message.swmodule.type.check.delete", new Object[] { swModuleTypeName })); } else { deleteSWModuleType(swModuleTypeName); updateSWActionCount(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java index 88df6a335..fb5d4a088 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java @@ -21,7 +21,7 @@ import org.eclipse.hawkbit.ui.artifacts.state.CustomFile; import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout; import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -55,7 +55,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind private final ArtifactUploadState artifactUploadState; - UploadViewConfirmationWindowLayout(final I18N i18n, final UIEventBus eventBus, + UploadViewConfirmationWindowLayout(final VaadinMessageSource i18n, final UIEventBus eventBus, final SoftwareManagement softwareManagement, final ArtifactUploadState artifactUploadState) { super(i18n, eventBus); this.softwareManagement = softwareManagement; @@ -66,10 +66,10 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind protected Map getConfimrationTabs() { final Map tabs = Maps.newHashMapWithExpectedSize(2); if (!artifactUploadState.getDeleteSofwareModules().isEmpty()) { - tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab()); + tabs.put(i18n.getMessage("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab()); } if (!artifactUploadState.getSelectedDeleteSWModuleTypes().isEmpty()) { - tabs.put(i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab()); + tabs.put(i18n.getMessage("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab()); } return tabs; } @@ -79,10 +79,10 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind tab.getConfirmAll().setId(UIComponentIdProvider.SW_DELETE_ALL); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get("button.delete.all")); + tab.getConfirmAll().setCaption(i18n.getMessage("button.delete.all")); tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab)); - tab.getDiscardAll().setCaption(i18n.get("button.discard.all")); + tab.getDiscardAll().setCaption(i18n.getMessage("button.discard.all")); tab.getDiscardAll().addClickListener(event -> discardSMAll(tab)); // Add items container to the table. @@ -95,8 +95,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind }); tab.getTable().setVisibleColumns(SW_MODULE_NAME_MSG, SW_DISCARD_CHGS); - tab.getTable().setColumnHeaders(i18n.get("upload.swModuleTable.header"), - i18n.get("header.second.deletetarget.table")); + tab.getTable().setColumnHeaders(i18n.getMessage("upload.swModuleTable.header"), + i18n.getMessage("header.second.deletetarget.table")); tab.getTable().setColumnExpandRatio(SW_MODULE_NAME_MSG, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH); tab.getTable().setColumnExpandRatio(SW_DISCARD_CHGS, SPUIDefinitions.DISCARD_COLUMN_WIDTH); @@ -145,7 +145,7 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind final Set swmoduleIds = artifactUploadState.getDeleteSofwareModules().keySet(); softwareManagement.deleteSoftwareModules(swmoduleIds); addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.swModule.deleted", artifactUploadState.getDeleteSofwareModules().size())); + + i18n.getMessage("message.swModule.deleted", artifactUploadState.getDeleteSofwareModules().size())); /* * Check if any information / files pending to upload for the deleted * software modules. If so, then delete the files from the upload list. @@ -167,14 +167,14 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind } artifactUploadState.getDeleteSofwareModules().clear(); removeCurrentTab(tab); - setActionMessage(i18n.get("message.software.delete.success")); + setActionMessage(i18n.getMessage("message.software.delete.success")); eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE); } private void discardSMAll(final ConfirmationTab tab) { removeCurrentTab(tab); artifactUploadState.getDeleteSofwareModules().clear(); - setActionMessage(i18n.get("message.software.discard.success")); + setActionMessage(i18n.getMessage("message.software.discard.success")); eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE); } @@ -183,10 +183,10 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind tab.getConfirmAll().setId(UIComponentIdProvider.SAVE_DELETE_SW_MODULE_TYPE); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get("button.delete.all")); + tab.getConfirmAll().setCaption(i18n.getMessage("button.delete.all")); tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab)); - tab.getDiscardAll().setCaption(i18n.get("button.discard.all")); + tab.getDiscardAll().setCaption(i18n.getMessage("button.discard.all")); tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab)); // Add items container to the table. @@ -200,8 +200,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind }); tab.getTable().setVisibleColumns(SW_MODULE_TYPE_NAME, DISCARD); - tab.getTable().setColumnHeaders(i18n.get("header.first.delete.swmodule.type.table"), - i18n.get("header.second.delete.swmodule.type.table")); + tab.getTable().setColumnHeaders(i18n.getMessage("header.first.delete.swmodule.type.table"), + i18n.getMessage("header.second.delete.swmodule.type.table")); tab.getTable().setColumnExpandRatio(SW_MODULE_TYPE_NAME, 2); tab.getTable().setColumnExpandRatio(SW_DISCARD_CHGS, SPUIDefinitions.DISCARD_COLUMN_WIDTH); @@ -243,17 +243,17 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind .ifPresent(softwareManagement::deleteSoftwareModuleType); } addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount })); + + i18n.getMessage("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount })); artifactUploadState.getSelectedDeleteSWModuleTypes().clear(); removeCurrentTab(tab); - setActionMessage(i18n.get("message.software.type.delete.success")); + setActionMessage(i18n.getMessage("message.software.type.delete.success")); eventBus.publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFWARE_TYPE); } private void discardSMtypeAll(final ConfirmationTab tab) { removeCurrentTab(tab); artifactUploadState.getSelectedDeleteSWModuleTypes().clear(); - setActionMessage(i18n.get("message.software.type.discard.success")); + setActionMessage(i18n.getMessage("message.software.type.discard.success")); eventBus.publish(this, UploadArtifactUIEvent.DISCARD_ALL_DELETE_SOFTWARE_TYPE); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java index 90ba98b3d..9b35fed86 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java @@ -27,7 +27,7 @@ import org.eclipse.hawkbit.ui.common.builder.WindowBuilder; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -51,7 +51,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent { private static final long serialVersionUID = -5217675246477211483L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UINotification uiNotifcation; @@ -91,7 +91,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent { * @param entityFactory * EntityFactory */ - public SoftwareModuleAddUpdateWindow(final I18N i18n, final UINotification uiNotifcation, final UIEventBus eventBus, + public SoftwareModuleAddUpdateWindow(final VaadinMessageSource i18n, final UINotification uiNotifcation, final UIEventBus eventBus, final SoftwareManagement softwareManagement, final EntityFactory entityFactory) { this.i18n = i18n; this.uiNotifcation = uiNotifcation; @@ -136,7 +136,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent { if (newSoftwareModule != null) { eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.ADD_ENTITY, newSoftwareModule)); - uiNotifcation.displaySuccess(i18n.get("message.save.success", + uiNotifcation.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newSoftwareModule.getName() + ":" + newSoftwareModule.getVersion() })); } } @@ -151,7 +151,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent { if (moduleType.isPresent() && softwareManagement .findSoftwareModuleByNameAndVersion(name, version, moduleType.get()).isPresent()) { uiNotifcation.displayValidationError( - i18n.get("message.duplicate.softwaremodule", new Object[] { name, version })); + i18n.getMessage("message.duplicate.softwaremodule", new Object[] { name, version })); return true; } return false; @@ -164,7 +164,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent { final SoftwareModule newSWModule = softwareManagement.updateSoftwareModule(entityFactory.softwareModule() .update(baseSwModuleId).description(descTextArea.getValue()).vendor(vendorTextField.getValue())); if (newSWModule != null) { - uiNotifcation.displaySuccess(i18n.get("message.save.success", + uiNotifcation.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newSWModule.getName() + ":" + newSWModule.getVersion() })); eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.UPDATED_ENTITY, newSWModule)); @@ -208,13 +208,13 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent { vendorTextField.setRequired(false); vendorTextField.setNullRepresentation(StringUtils.EMPTY); - descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style") - .prompt(i18n.get("textfield.description")).id(UIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION) + descTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")).style("text-area-style") + .prompt(i18n.getMessage("textfield.description")).id(UIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION) .buildTextComponent(); descTextArea.setNullRepresentation(StringUtils.EMPTY); - typeComboBox = SPUIComponentProvider.getComboBox(i18n.get("upload.swmodule.type"), "", null, null, true, null, - i18n.get("upload.swmodule.type")); + typeComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("upload.swmodule.type"), "", null, null, true, null, + i18n.getMessage("upload.swmodule.type")); typeComboBox.setId(UIComponentIdProvider.SW_MODULE_TYPE); typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY); typeComboBox.setNewItemsAllowed(Boolean.FALSE); @@ -222,7 +222,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent { } private TextField createTextField(final String in18Key, final String id) { - return new TextFieldBuilder().caption(i18n.get(in18Key)).required(true).prompt(i18n.get(in18Key)) + return new TextFieldBuilder().caption(i18n.getMessage(in18Key)).required(true).prompt(i18n.getMessage(in18Key)) .immediate(true).id(id).buildTextComponent(); } @@ -260,7 +260,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent { setCompositionRoot(formLayout); final CommonDialogWindow window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW) - .caption(i18n.get("upload.caption.add.new.swmodule")).content(this).layout(formLayout).i18n(i18n) + .caption(i18n.getMessage("upload.caption.add.new.swmodule")).content(this).layout(formLayout).i18n(i18n) .saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow(); nameTextField.setEnabled(!editSwModule); versionTextField.setEnabled(!editSwModule); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java index 3ca243f25..5edbf148b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java @@ -22,7 +22,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventScope; @@ -52,7 +52,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta private final SoftwareModuleMetadatadetailslayout swmMetadataTable; - SoftwareModuleDetails(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, + SoftwareModuleDetails(final VaadinMessageSource i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, final SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow, final ArtifactUploadState artifactUploadState, final SoftwareManagement softwareManagement, final SwMetadataPopupLayout swMetadataPopupLayout, final EntityFactory entityFactory) { @@ -91,17 +91,17 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta @Override protected void addTabs(final TabSheet detailsTab) { - detailsTab.addTab(createDetailsLayout(), getI18n().get("caption.tab.details"), null); - detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null); - detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null); - detailsTab.addTab(swmMetadataTable, getI18n().get("caption.metadata"), null); + detailsTab.addTab(createDetailsLayout(), getI18n().getMessage("caption.tab.details"), null); + detailsTab.addTab(createDescriptionLayout(), getI18n().getMessage("caption.tab.description"), null); + detailsTab.addTab(createLogLayout(), getI18n().getMessage("caption.logs.tab"), null); + detailsTab.addTab(swmMetadataTable, getI18n().getMessage("caption.metadata"), null); } @Override protected void onEdit(final ClickEvent event) { final Window addSoftwareModule = softwareModuleAddUpdateWindow .createUpdateSoftwareModuleWindow(getSelectedBaseEntityId()); - addSoftwareModule.setCaption(getI18n().get("upload.caption.update.swmodule")); + addSoftwareModule.setCaption(getI18n().getMessage("upload.caption.update.swmodule")); UI.getCurrent().addWindow(addSoftwareModule); addSoftwareModule.setVisible(Boolean.TRUE); } @@ -111,9 +111,9 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta if (getSelectedBaseEntity() != null) { String maxAssign; if (getSelectedBaseEntity().getType().getMaxAssignments() == 1) { - maxAssign = getI18n().get("label.singleAssign.type"); + maxAssign = getI18n().getMessage("label.singleAssign.type"); } else { - maxAssign = getI18n().get("label.multiAssign.type"); + maxAssign = getI18n().getMessage("label.multiAssign.type"); } updateSoftwareModuleDetailsLayout(getSelectedBaseEntity().getType().getName(), getSelectedBaseEntity().getVendor(), maxAssign); @@ -128,19 +128,19 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta detailsTabLayout.removeAllComponents(); - final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"), + final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.vendor"), HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor); vendorLabel.setId(UIComponentIdProvider.DETAILS_VENDOR_LABEL_ID); detailsTabLayout.addComponent(vendorLabel); if (type != null) { - final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"), + final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.type"), type); typeLabel.setId(UIComponentIdProvider.DETAILS_TYPE_LABEL_ID); detailsTabLayout.addComponent(typeLabel); } - final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"), + final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.assigned.type"), HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign); assignLabel.setId(UIComponentIdProvider.SWM_DTLS_MAX_ASSIGN); detailsTabLayout.addComponent(assignLabel); @@ -149,7 +149,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta @Override protected String getDefaultCaption() { - return getI18n().get("upload.swModuleTable.header"); + return getI18n().getMessage("upload.swModuleTable.header"); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java index feb93a2f5..5f5def720 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -26,7 +26,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout; import org.eclipse.hawkbit.ui.push.SoftwareModuleUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -65,7 +65,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable artifactList = artifactManagement.findByFilenameAndSoftwareModule(oldFileName, currentSwId); errorLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL); - errorLabel.setDescription(i18n.get(ALREADY_EXISTS_MSG)); + errorLabel.setDescription(i18n.getMessage(ALREADY_EXISTS_MSG)); if (!artifactList.isPresent()) { errorLabel.setVisible(false); } @@ -480,12 +480,12 @@ public class UploadConfirmationWindow implements Button.ClickListener { uploadDetailsTable.setContainerDataSource(tabelContainer); uploadDetailsTable.setPageLength(10); - uploadDetailsTable.setColumnHeader(FILE_NAME_LAYOUT, i18n.get("upload.file.name")); - uploadDetailsTable.setColumnHeader(SW_MODULE_NAME, i18n.get("upload.swModuleTable.header")); - uploadDetailsTable.setColumnHeader(SHA1_CHECKSUM, i18n.get("upload.sha1")); - uploadDetailsTable.setColumnHeader(MD5_CHECKSUM, i18n.get("upload.md5")); - uploadDetailsTable.setColumnHeader(SIZE, i18n.get("upload.size")); - uploadDetailsTable.setColumnHeader(ACTION, i18n.get("upload.action")); + uploadDetailsTable.setColumnHeader(FILE_NAME_LAYOUT, i18n.getMessage("upload.file.name")); + uploadDetailsTable.setColumnHeader(SW_MODULE_NAME, i18n.getMessage("upload.swModuleTable.header")); + uploadDetailsTable.setColumnHeader(SHA1_CHECKSUM, i18n.getMessage("upload.sha1")); + uploadDetailsTable.setColumnHeader(MD5_CHECKSUM, i18n.getMessage("upload.md5")); + uploadDetailsTable.setColumnHeader(SIZE, i18n.getMessage("upload.size")); + uploadDetailsTable.setColumnHeader(ACTION, i18n.getMessage("upload.action")); uploadDetailsTable.setColumnExpandRatio(FILE_NAME_LAYOUT, 0.25F); uploadDetailsTable.setColumnExpandRatio(SW_MODULE_NAME, 0.17F); @@ -516,7 +516,7 @@ public class UploadConfirmationWindow implements Button.ClickListener { window.setDraggable(Boolean.TRUE); window.setModal(true); window.addCloseListener(event -> onPopupClose()); - window.setCaption(i18n.get("header.caption.upload.details")); + window.setCaption(i18n.getMessage("header.caption.upload.details")); window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION); } @@ -614,7 +614,7 @@ public class UploadConfirmationWindow implements Button.ClickListener { Page.getCurrent().getBrowserWindowHeight()); } else { uploadLayout.getUINotification() - .displayValidationError(uploadLayout.getI18n().get("message.error.noProvidedName")); + .displayValidationError(uploadLayout.getI18n().getMessage("message.error.noProvidedName")); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java index 8120863f9..d04212f36 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java @@ -17,7 +17,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.UploadFileStatus; import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadStatusEvent.UploadStatusEventType; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,7 +65,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene private volatile boolean aborted; private String failureReason; - private final I18N i18n; + private final VaadinMessageSource i18n; private transient EventBus.UIEventBus eventBus; private final SoftwareModule selectedSw; private SoftwareModule selectedSwForUpload; @@ -82,7 +82,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene this.upload = upload; this.mimeType = mimeType; this.selectedSw = selectedSw; - this.i18n = SpringContextHelper.getBean(I18N.class); + this.i18n = SpringContextHelper.getBean(VaadinMessageSource.class); this.eventBus = SpringContextHelper.getBean(EventBus.UIEventBus.class); this.artifactUploadState = SpringContextHelper.getBean(ArtifactUploadState.class); eventBus.subscribe(this); @@ -218,7 +218,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene new UploadFileStatus(event.getFilename(), 0, 0, selectedSwForUpload))); } } else { - failureReason = i18n.get("message.upload.failed"); + failureReason = i18n.getMessage("message.upload.failed"); upload.interruptUpload(); // actual interrupt will happen a bit late so setting the below // flag @@ -248,13 +248,13 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene if (!uploadInterrupted) { if (aborted) { LOG.info("User aborted file upload for file : {}", fileName); - failureReason = i18n.get("message.uploadedfile.aborted"); + failureReason = i18n.getMessage("message.uploadedfile.aborted"); interruptFileUpload(); return; } if (readBytes > maxSize || contentLength > maxSize) { LOG.error("User tried to upload more than was allowed ({}).", maxSize); - failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize); + failureReason = i18n.getMessage("message.uploadedfile.size.exceeded", maxSize); interruptFileUpload(); return; } @@ -273,13 +273,13 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene public void onProgress(final StreamingProgressEvent event) { if (aborted) { LOG.info("User aborted the upload for file : {}", event.getFileName()); - failureReason = i18n.get("message.uploadedfile.aborted"); + failureReason = i18n.getMessage("message.uploadedfile.aborted"); interruptFileStreaming(); return; } if (event.getBytesReceived() > maxSize || event.getContentLength() > maxSize) { LOG.error("User tried to upload more than was allowed ({}).", maxSize); - failureReason = i18n.get("message.uploadedfile.size.exceeded", maxSize); + failureReason = i18n.getMessage("message.uploadedfile.size.exceeded", maxSize); interruptFileStreaming(); return; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index 41ae1e2e3..2590749f6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -36,7 +36,7 @@ import org.eclipse.hawkbit.ui.dd.criteria.ServerItemIdClientCriterion; import org.eclipse.hawkbit.ui.dd.criteria.ServerItemIdClientCriterion.Mode; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -82,7 +82,7 @@ public class UploadLayout extends VerticalLayout { private final UploadStatusInfoWindow uploadInfoWindow; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UINotification uiNotification; @@ -115,7 +115,7 @@ public class UploadLayout extends VerticalLayout { private final transient ArtifactManagement artifactManagement; - public UploadLayout(final I18N i18n, final UINotification uiNotification, final UIEventBus eventBus, + public UploadLayout(final VaadinMessageSource i18n, final UINotification uiNotification, final UIEventBus eventBus, final ArtifactUploadState artifactUploadState, final MultipartConfigElement multipartConfigElement, final ArtifactManagement artifactManagement) { this.uploadInfoWindow = new UploadStatusInfoWindow(eventBus, artifactUploadState, i18n); @@ -174,7 +174,7 @@ public class UploadLayout extends VerticalLayout { final Upload upload = new Upload(); final UploadHandler uploadHandler = new UploadHandler(null, 0, this, multipartConfigElement.getMaxFileSize(), upload, null, null); - upload.setButtonCaption(i18n.get("upload.file")); + upload.setButtonCaption(i18n.getMessage("upload.file")); upload.setImmediate(true); upload.setReceiver(uploadHandler); upload.addSucceededListener(uploadHandler); @@ -299,7 +299,7 @@ public class UploadLayout extends VerticalLayout { if (compositeMessage.length() > 0) { compositeMessage.append("
"); } - compositeMessage.append(i18n.get("message.no.directory.upload")); + compositeMessage.append(i18n.getMessage("message.no.directory.upload")); } if (!compositeMessage.toString().isEmpty()) { uiNotification.displayValidationError(compositeMessage.toString()); @@ -393,10 +393,10 @@ public class UploadLayout extends VerticalLayout { return out; } catch (final FileNotFoundException e) { LOG.error("Upload failed {}", e); - throw new ArtifactUploadFailedException(i18n.get("message.file.not.found")); + throw new ArtifactUploadFailedException(i18n.getMessage("message.file.not.found")); } catch (final IOException e) { LOG.error("Upload failed {}", e); - throw new ArtifactUploadFailedException(i18n.get("message.upload.failed")); + throw new ArtifactUploadFailedException(i18n.getMessage("message.upload.failed")); } } @@ -405,7 +405,7 @@ public class UploadLayout extends VerticalLayout { // check if drop is valid.If valid ,check if software module is // selected. if (!isFilesDropped(event)) { - uiNotification.displayValidationError(i18n.get("message.action.not.allowed")); + uiNotification.displayValidationError(i18n.getMessage("message.action.not.allowed")); return false; } return checkIfSoftwareModuleIsSelected(); @@ -421,7 +421,7 @@ public class UploadLayout extends VerticalLayout { Boolean checkIfSoftwareModuleIsSelected() { if (!isSoftwareModuleSelected()) { - uiNotification.displayValidationError(i18n.get("message.error.noSwModuleSelected")); + uiNotification.displayValidationError(i18n.getMessage("message.error.noSwModuleSelected")); return false; } return true; @@ -494,10 +494,10 @@ public class UploadLayout extends VerticalLayout { if (!duplicateFileNamesList.isEmpty()) { final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList); if (duplicateFileNamesList.size() == 1) { - message.append(i18n.get("message.no.duplicateFile") + fileNames); + message.append(i18n.getMessage("message.no.duplicateFile") + fileNames); } else if (duplicateFileNamesList.size() > 1) { - message.append(i18n.get("message.no.duplicateFiles")); + message.append(i18n.getMessage("message.no.duplicateFiles")); } } return message.toString(); @@ -550,7 +550,7 @@ public class UploadLayout extends VerticalLayout { private void discardUploadData(final Button.ClickEvent event) { if (event.getButton().equals(discardBtn)) { if (artifactUploadState.getFileSelected().isEmpty()) { - uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); + uiNotification.displayValidationError(i18n.getMessage("message.error.noFileSelected")); } else { clearUploadedFileDetails(); } @@ -621,7 +621,7 @@ public class UploadLayout extends VerticalLayout { private void displayConfirmWindow(final Button.ClickEvent event) { if (event.getComponent().getId().equals(UIComponentIdProvider.UPLOAD_PROCESS_BUTTON)) { if (artifactUploadState.getFileSelected().isEmpty()) { - uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); + uiNotification.displayValidationError(i18n.getMessage("message.error.noFileSelected")); } else { currentUploadConfirmationwindow = new UploadConfirmationWindow(this, artifactUploadState, eventBus, artifactManagement); @@ -635,7 +635,7 @@ public class UploadLayout extends VerticalLayout { /** * @return */ - I18N getI18n() { + VaadinMessageSource getI18n() { return i18n; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java index 74a2275e7..24fc5d826 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java @@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -51,7 +51,7 @@ public class UploadResultWindow implements Button.ClickListener { private IndexedContainer tabelContainer; - private final I18N i18n; + private final VaadinMessageSource i18n; private static final String FILE_NAME = "fileName"; @@ -71,7 +71,7 @@ public class UploadResultWindow implements Button.ClickListener { * @param i18n * I18N */ - UploadResultWindow(final List uploadResultList, final I18N i18n, final EventBus.UIEventBus eventBus) { + UploadResultWindow(final List uploadResultList, final VaadinMessageSource i18n, final EventBus.UIEventBus eventBus) { this.uploadResultList = uploadResultList; this.i18n = i18n; this.eventBus = eventBus; @@ -110,11 +110,11 @@ public class UploadResultWindow implements Button.ClickListener { .setValue(HawkbitCommonUtil.getFormatedLabel(uploadResult.getBaseSwModuleName())); if (uploadResult.getUploadResult().equals(SPUILabelDefinitions.SUCCESS)) { - statusLabel = new Label(HawkbitCommonUtil.getFormatedLabel(i18n.get("upload.success"))); + statusLabel = new Label(HawkbitCommonUtil.getFormatedLabel(i18n.getMessage("upload.success"))); statusLabel.addStyleName("validation-success"); newItem.getItemProperty(UPLOAD_RESULT).setValue(statusLabel); } else { - statusLabel = new Label(HawkbitCommonUtil.getFormatedLabel(i18n.get("upload.failed"))); + statusLabel = new Label(HawkbitCommonUtil.getFormatedLabel(i18n.getMessage("upload.failed"))); statusLabel.addStyleName("validation-failed"); newItem.getItemProperty(UPLOAD_RESULT).setValue(statusLabel); } @@ -138,10 +138,10 @@ public class UploadResultWindow implements Button.ClickListener { uploadResultTable.setContainerDataSource(tabelContainer); uploadResultTable.setPageLength(10); - uploadResultTable.setColumnHeader(FILE_NAME, i18n.get("upload.file.name")); - uploadResultTable.setColumnHeader(BASE_SW_MODULE, i18n.get("upload.swModuleTable.header")); - uploadResultTable.setColumnHeader(UPLOAD_RESULT, i18n.get("upload.result.status")); - uploadResultTable.setColumnHeader(REASON, i18n.get("upload.reason")); + uploadResultTable.setColumnHeader(FILE_NAME, i18n.getMessage("upload.file.name")); + uploadResultTable.setColumnHeader(BASE_SW_MODULE, i18n.getMessage("upload.swModuleTable.header")); + uploadResultTable.setColumnHeader(UPLOAD_RESULT, i18n.getMessage("upload.result.status")); + uploadResultTable.setColumnHeader(REASON, i18n.getMessage("upload.reason")); uploadResultTable.setColumnExpandRatio(FILE_NAME, 0.2f); uploadResultTable.setColumnExpandRatio(BASE_SW_MODULE, 0.2f); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatusInfoWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatusInfoWindow.java index d4c141049..36b060a22 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatusInfoWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatusInfoWindow.java @@ -21,7 +21,7 @@ import org.eclipse.hawkbit.ui.common.ConfirmationDialog; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -59,7 +59,7 @@ public class UploadStatusInfoWindow extends Window { private final ArtifactUploadState artifactUploadState; - private final I18N i18n; + private final VaadinMessageSource i18n; private static final String PROGRESS = "Progress"; @@ -93,7 +93,7 @@ public class UploadStatusInfoWindow extends Window { private ConfirmationDialog confirmDialog; - UploadStatusInfoWindow(final UIEventBus eventBus, final ArtifactUploadState artifactUploadState, final I18N i18n) { + UploadStatusInfoWindow(final UIEventBus eventBus, final ArtifactUploadState artifactUploadState, final VaadinMessageSource i18n) { this.eventBus = eventBus; this.artifactUploadState = artifactUploadState; this.i18n = i18n; @@ -193,7 +193,7 @@ public class UploadStatusInfoWindow extends Window { grid.getColumn(PROGRESS).setRenderer(new ProgressBarRenderer()); grid.setColumnOrder(STATUS, PROGRESS, FILE_NAME, SPUILabelDefinitions.NAME_VERSION, REASON); setColumnWidth(); - grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setHeaderCaption(i18n.get("upload.swModuleTable.header")); + grid.getColumn(SPUILabelDefinitions.NAME_VERSION).setHeaderCaption(i18n.getMessage("upload.swModuleTable.header")); grid.setFrozenColumnCount(5); } @@ -466,8 +466,8 @@ public class UploadStatusInfoWindow extends Window { } private void createConfirmDialog() { - confirmDialog = new ConfirmationDialog(i18n.get("caption.confirm.abort.action"), - i18n.get("message.abort.upload"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> { + confirmDialog = new ConfirmationDialog(i18n.getMessage("caption.confirm.abort.action"), + i18n.getMessage("message.abort.upload"), i18n.getMessage("button.ok"), i18n.getMessage("button.cancel"), ok -> { if (ok) { eventBus.publish(this, UploadStatusEventType.ABORT_UPLOAD); uploadAborted = 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 ca5462993..60660bda8 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 @@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -72,7 +72,7 @@ public abstract class AbstractMetadataPopupLayout { + i18n.getMessage("caption.metadata.delete.action.confirmbox"), i18n.getMessage("message.confirm.delete.metadata", key), + i18n.getMessage("button.ok"), i18n.getMessage("button.cancel"), ok -> { if (ok) { handleOkDeleteMetadata(event, key, value); } @@ -290,7 +290,7 @@ public abstract class AbstractMetadataPopupLayout onAdd()); return addIcon; } private Label createHeaderCaption() { - return new LabelBuilder().name(i18n.get("caption.metadata")).buildCaptionLabel(); + return new LabelBuilder().name(i18n.getMessage("caption.metadata")).buildCaptionLabel(); } private static IndexedContainer getMetadataContainer() { @@ -387,7 +387,7 @@ public abstract class AbstractMetadataPopupLayout> allComponents; - private final I18N i18n; + private final VaadinMessageSource i18n; private transient SaveDialogCloseListener closeListener; @@ -121,7 +121,7 @@ public class CommonDialogWindow extends Window { */ public CommonDialogWindow(final String caption, final Component content, final String helpLink, final SaveDialogCloseListener closeListener, final ClickListener cancelButtonClickListener, - final AbstractLayout layout, final I18N i18n) { + final AbstractLayout layout, final VaadinMessageSource i18n) { checkNotNull(closeListener); this.caption = caption; this.content = content; @@ -428,7 +428,7 @@ public class CommonDialogWindow extends Window { return; } - final Label mandatoryLabel = new Label(i18n.get("label.mandatory.field")); + final Label mandatoryLabel = new Label(i18n.getMessage("label.mandatory.field")); mandatoryLabel.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR + " " + ValoTheme.LABEL_TINY); if (content instanceof TargetAddUpdateWindowLayout) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/builder/WindowBuilder.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/builder/WindowBuilder.java index faef01ded..b5d9bc913 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/builder/WindowBuilder.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/builder/WindowBuilder.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.common.builder; import org.eclipse.hawkbit.ui.common.CommonDialogWindow; import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -29,7 +29,7 @@ public class WindowBuilder { private ClickListener cancelButtonClickListener; private String helpLink; private AbstractLayout layout; - private I18N i18n; + private VaadinMessageSource i18n; private final String type; private String id; @@ -124,7 +124,7 @@ public class WindowBuilder { * the i18n * @return the window builder */ - public WindowBuilder i18n(final I18N i18n) { + public WindowBuilder i18n(final VaadinMessageSource i18n) { this.i18n = i18n; return this; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/AbstractConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/AbstractConfirmationWindowLayout.java index fd2d23e2f..c45b2cfdf 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/AbstractConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/AbstractConfirmationWindowLayout.java @@ -14,7 +14,7 @@ import java.util.Map.Entry; 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; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -44,11 +44,11 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout { private String consolidatedMessage; - protected I18N i18n; + protected VaadinMessageSource i18n; protected transient EventBus.UIEventBus eventBus; - protected AbstractConfirmationWindowLayout(final I18N i18n, final UIEventBus eventBus) { + protected AbstractConfirmationWindowLayout(final VaadinMessageSource i18n, final UIEventBus eventBus) { this.i18n = i18n; this.eventBus = eventBus; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractNamedVersionedEntityTableDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractNamedVersionedEntityTableDetailsLayout.java index 710c4ff40..571cddbc9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractNamedVersionedEntityTableDetailsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractNamedVersionedEntityTableDetailsLayout.java @@ -12,7 +12,7 @@ import org.eclipse.hawkbit.repository.model.NamedVersionedEntity; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.vaadin.spring.events.EventBus.UIEventBus; /** @@ -24,7 +24,7 @@ public abstract class AbstractNamedVersionedEntityTableDetailsLayout extends private static final long serialVersionUID = 4862529368471627190L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final SpPermissionChecker permissionChecker; @@ -69,7 +69,7 @@ public abstract class AbstractTableDetailsLayout extends protected final ManagementUIState managementUIState; - protected AbstractTableDetailsLayout(final I18N i18n, final UIEventBus eventBus, + protected AbstractTableDetailsLayout(final VaadinMessageSource i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState) { this.i18n = i18n; this.permissionChecker = permissionChecker; @@ -87,7 +87,7 @@ public abstract class AbstractTableDetailsLayout extends return permissionChecker; } - protected I18N getI18n() { + protected VaadinMessageSource getI18n() { return i18n; } @@ -131,7 +131,7 @@ public abstract class AbstractTableDetailsLayout extends manageMetadataBtn = SPUIComponentProvider.getButton("", "", "", null, false, FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class); manageMetadataBtn.setId(getEditButtonId()); - manageMetadataBtn.setDescription(i18n.get("tooltip.metadata.icon")); + manageMetadataBtn.setDescription(i18n.getMessage("tooltip.metadata.icon")); manageMetadataBtn.addClickListener(this::showMetadata); manageMetadataBtn.setEnabled(false); @@ -214,7 +214,7 @@ public abstract class AbstractTableDetailsLayout extends protected void populateLog() { logLayout.removeAllComponents(); - logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"), + logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.getMessage("label.created.at"), SPDateTimeUtil.formatCreatedAt(selectedBaseEntity))); logLayout.addComponent(SPUIComponentProvider.createCreatedByLabel(i18n, selectedBaseEntity)); @@ -223,7 +223,7 @@ public abstract class AbstractTableDetailsLayout extends return; } - logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.date"), + logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.getMessage("label.modified.date"), SPDateTimeUtil.formatLastModifiedAt(selectedBaseEntity))); logLayout.addComponent(SPUIComponentProvider.createLastModifiedByLabel(i18n, selectedBaseEntity)); @@ -316,9 +316,9 @@ public abstract class AbstractTableDetailsLayout extends private void populateDescription() { if (selectedBaseEntity != null) { - updateDescriptionLayout(i18n.get("label.description"), selectedBaseEntity.getDescription()); + updateDescriptionLayout(i18n.getMessage("label.description"), selectedBaseEntity.getDescription()); } else { - updateDescriptionLayout(i18n.get("label.description"), null); + updateDescriptionLayout(i18n.getMessage("label.description"), null); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/DistributionSetMetadatadetailslayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/DistributionSetMetadatadetailslayout.java index 7dcbb076d..ab5e2b51d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/DistributionSetMetadatadetailslayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/DistributionSetMetadatadetailslayout.java @@ -19,7 +19,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -53,13 +53,13 @@ public class DistributionSetMetadatadetailslayout extends Table { private final transient EntityFactory entityFactory; - private final I18N i18n; + private final VaadinMessageSource i18n; private Long selectedDistSetId; private final UINotification notification; - public DistributionSetMetadatadetailslayout(final I18N i18n, final SpPermissionChecker permissionChecker, + public DistributionSetMetadatadetailslayout(final VaadinMessageSource i18n, final SpPermissionChecker permissionChecker, final DistributionSetManagement distributionSetManagement, final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory, final UINotification notification) { @@ -123,7 +123,7 @@ public class DistributionSetMetadatadetailslayout extends Table { } private void addDSMetadataTableHeader() { - setColumnHeader(METADATA_KEY, i18n.get("header.key")); + setColumnHeader(METADATA_KEY, i18n.getMessage("header.key")); } private void setDSMetadataProperties(final DistributionSetMetadata dsMetadata) { @@ -153,7 +153,7 @@ public class DistributionSetMetadatadetailslayout extends Table { private void showMetadataDetails(final Long selectedDistSetId, final String metadataKey) { final Optional distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId); if (!distSet.isPresent()) { - notification.displayWarning(i18n.get("distributionset.not.exists")); + notification.displayWarning(i18n.getMessage("distributionset.not.exists")); return; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java index 588e66e26..d096d6ebb 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java @@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.slf4j.Logger; @@ -65,7 +65,7 @@ public class SoftwareModuleDetailsTable extends Table { private final transient DistributionSetManagement distributionSetManagement; - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient EventBus.UIEventBus eventBus; @@ -92,7 +92,7 @@ public class SoftwareModuleDetailsTable extends Table { * @param uiNotification * UINotification for displaying error and success notifications */ - public SoftwareModuleDetailsTable(final I18N i18n, final boolean isUnassignSoftModAllowed, + public SoftwareModuleDetailsTable(final VaadinMessageSource i18n, final boolean isUnassignSoftModAllowed, final SpPermissionChecker permissionChecker, final DistributionSetManagement distributionSetManagement, final EventBus.UIEventBus eventBus, final ManageDistUIState manageDistUIState, final UINotification uiNotification) { @@ -133,8 +133,8 @@ public class SoftwareModuleDetailsTable extends Table { private void addSWModuleTableHeader() { setColumnHeader(SOFT_TYPE_MANDATORY, ""); - setColumnHeader(SOFT_TYPE_NAME, i18n.get("header.caption.typename")); - setColumnHeader(SOFT_MODULE, i18n.get("header.caption.softwaremodule")); + setColumnHeader(SOFT_TYPE_NAME, i18n.getMessage("header.caption.typename")); + setColumnHeader(SOFT_MODULE, i18n.getMessage("header.caption.softwaremodule")); } /** @@ -186,7 +186,7 @@ public class SoftwareModuleDetailsTable extends Table { final Set alreadyAssignedSwModules) { final SoftwareModule unAssignedSw = getSoftwareModule(event.getButton().getId(), alreadyAssignedSwModules); if (distributionSetManagement.isDistributionSetInUse(distributionSet.getId())) { - uiNotification.displayValidationError(i18n.get("message.error.notification.ds.target.assigned", + uiNotification.displayValidationError(i18n.getMessage("message.error.notification.ds.target.assigned", distributionSet.getName(), distributionSet.getVersion())); } else { final DistributionSet newDistributionSet = distributionSetManagement @@ -194,7 +194,7 @@ public class SoftwareModuleDetailsTable extends Table { manageDistUIState.setLastSelectedEntity(newDistributionSet.getId()); eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, newDistributionSet)); eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION); - uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName())); + uiNotification.displaySuccess(i18n.getMessage("message.sw.unassigned", unAssignedSw.getName())); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleMetadatadetailslayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleMetadatadetailslayout.java index 7bfb1920e..5c8ec6bd5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleMetadatadetailslayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleMetadatadetailslayout.java @@ -18,7 +18,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -49,7 +49,7 @@ public class SoftwareModuleMetadatadetailslayout extends Table { private SwMetadataPopupLayout swMetadataPopupLayout; - private I18N i18n; + private VaadinMessageSource i18n; private Long selectedSWModuleId; @@ -69,7 +69,7 @@ public class SoftwareModuleMetadatadetailslayout extends Table { * @param entityFactory * the entity factory service */ - public void init(final I18N i18n, final SpPermissionChecker permissionChecker, + public void init(final VaadinMessageSource i18n, final SpPermissionChecker permissionChecker, final SoftwareManagement softwareManagement, final SwMetadataPopupLayout swMetadataPopupLayout, final EntityFactory entityFactory) { this.i18n = i18n; @@ -143,7 +143,7 @@ public class SoftwareModuleMetadatadetailslayout extends Table { } private void addSMMetadataTableHeader() { - setColumnHeader(METADATA_KEY, i18n.get("header.key")); + setColumnHeader(METADATA_KEY, i18n.getMessage("header.key")); } private void setSWMetadataProperties(final SoftwareModuleMetadata swMetadata) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/TargetFilterQueryDetailsTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/TargetFilterQueryDetailsTable.java index ef4bc84d2..f28033e5c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/TargetFilterQueryDetailsTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/TargetFilterQueryDetailsTable.java @@ -12,7 +12,7 @@ import java.util.List; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import com.vaadin.data.Container; @@ -32,9 +32,9 @@ public class TargetFilterQueryDetailsTable extends Table { private static final String TFQ_NAME = "name"; private static final String TFQ_QUERY = "query"; - private final I18N i18n; + private final VaadinMessageSource i18n; - public TargetFilterQueryDetailsTable(final I18N i18n) { + public TargetFilterQueryDetailsTable(final VaadinMessageSource i18n) { this.i18n = i18n; createTable(); } @@ -90,8 +90,8 @@ public class TargetFilterQueryDetailsTable extends Table { } private void addTableHeader() { - setColumnHeader(TFQ_NAME, i18n.get("header.target.filter.name")); - setColumnHeader(TFQ_QUERY, i18n.get("header.target.filter.query")); + setColumnHeader(TFQ_NAME, i18n.getMessage("header.target.filter.name")); + setColumnHeader(TFQ_QUERY, i18n.getMessage("header.target.filter.query")); } } 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 8ddf90111..c086798d6 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 @@ -12,7 +12,7 @@ import org.eclipse.hawkbit.ui.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.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -41,9 +41,9 @@ public abstract class AbstractFilterHeader extends VerticalLayout { private Button hideIcon; - protected final I18N i18n; + protected final VaadinMessageSource i18n; - protected AbstractFilterHeader(final SpPermissionChecker permChecker, final UIEventBus eventBus, final I18N i18n) { + protected AbstractFilterHeader(final SpPermissionChecker permChecker, final UIEventBus eventBus, final VaadinMessageSource i18n) { this.permChecker = permChecker; this.eventBus = eventBus; this.i18n = i18n; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/footer/AbstractDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/footer/AbstractDeleteActionsLayout.java index 04aec943c..9519d601b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/footer/AbstractDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/footer/AbstractDeleteActionsLayout.java @@ -12,7 +12,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.builder.WindowBuilder; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -43,7 +43,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme private static final long serialVersionUID = -6047975388519155509L; - protected I18N i18n; + protected VaadinMessageSource i18n; protected SpPermissionChecker permChecker; @@ -59,7 +59,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme private Button bulkUploadStatusButton; - protected AbstractDeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, + protected AbstractDeleteActionsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus, final UINotification notification) { this.i18n = i18n; this.permChecker = permChecker; @@ -338,7 +338,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme * @return the no actions label. */ protected String getNoActionsButtonLabel() { - return i18n.get("button.no.actions"); + return i18n.getMessage("button.no.actions"); } /** @@ -347,7 +347,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme * @return the actions label. */ protected String getActionsButtonLabel() { - return i18n.get("button.actions"); + return i18n.getMessage("button.actions"); } /** @@ -356,7 +356,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme * @return caption of the window. */ protected String getUnsavedActionsWindowCaption() { - return i18n.get("caption.save.window"); + return i18n.getMessage("caption.save.window"); } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGrid.java index d41b93afd..180f9130d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGrid.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.common.grid; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.components.RefreshableContainer; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.spring.events.EventBus; @@ -28,13 +28,13 @@ public abstract class AbstractGrid extends Grid implements RefreshableContainer private static final long serialVersionUID = 4856562746502217630L; - protected final I18N i18n; + protected final VaadinMessageSource i18n; protected final transient EventBus.UIEventBus eventBus; protected final SpPermissionChecker permissionChecker; - protected AbstractGrid(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker) { + protected AbstractGrid(final VaadinMessageSource i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker) { this.i18n = i18n; this.eventBus = eventBus; this.permissionChecker = permissionChecker; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGridHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGridHeader.java index 4db6143d7..28aa1ada9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGridHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGridHeader.java @@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.components.SPUIButton; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -49,10 +49,10 @@ public abstract class AbstractGridHeader extends VerticalLayout { protected final RolloutUIState rolloutUIState; - protected final I18N i18n; + protected final VaadinMessageSource i18n; protected AbstractGridHeader(final SpPermissionChecker permissionChecker, final RolloutUIState rolloutUIState, - final I18N i18n) { + final VaadinMessageSource i18n) { this.permissionChecker = permissionChecker; this.rolloutUIState = rolloutUIState; this.i18n = i18n; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractNamedVersionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractNamedVersionTable.java index d870a8863..f5e55fa64 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractNamedVersionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractNamedVersionTable.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.common.table; import java.util.List; import org.eclipse.hawkbit.repository.model.NamedVersionedEntity; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -33,7 +33,7 @@ public abstract class AbstractNamedVersionTable columnList = super.getTableVisibleColumns(); final float versionColumnSize = isMaximized() ? 0.1F : 0.2F; columnList - .add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), versionColumnSize)); + .add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.getMessage("header.version"), versionColumnSize)); return columnList; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java index c69651ffd..b01b92021 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java @@ -22,7 +22,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.common.ManagmentEntityState; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.RefreshableContainer; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; @@ -64,11 +64,11 @@ public abstract class AbstractTable extends Table impl protected transient EventBus.UIEventBus eventBus; - protected I18N i18n; + protected VaadinMessageSource i18n; protected UINotification notification; - protected AbstractTable(final UIEventBus eventBus, final I18N i18n, final UINotification notification) { + protected AbstractTable(final UIEventBus eventBus, final VaadinMessageSource i18n, final UINotification notification) { this.eventBus = eventBus; this.i18n = i18n; this.notification = notification; @@ -320,17 +320,17 @@ public abstract class AbstractTable extends Table impl protected List getTableVisibleColumns() { final List columnList = new ArrayList<>(); if (!isMaximized()) { - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.getMessage("header.name"), getColumnNameMinimizedSize())); return columnList; } - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.getMessage("header.name"), 0.2F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.getMessage("header.createdBy"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.getMessage("header.createdDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.getMessage("header.modifiedBy"), 0.1F)); columnList.add( - new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F)); + new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.getMessage("header.modifiedDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.getMessage("header.description"), 0.2F)); setItemDescriptionGenerator((source, itemId, propertyId) -> { if (SPUILabelDefinitions.VAR_CREATED_BY.equals(propertyId)) { @@ -395,7 +395,7 @@ public abstract class AbstractTable extends Table impl private boolean validateDropList(final Set droplist) { if (droplist.isEmpty()) { - final String actionDidNotWork = i18n.get("message.action.did.not.work", new Object[] {}); + final String actionDidNotWork = i18n.getMessage("message.action.did.not.work", new Object[] {}); notification.displayValidationError(actionDidNotWork); return false; } @@ -407,7 +407,7 @@ public abstract class AbstractTable extends Table impl final Component compsource = transferable.getSourceComponent(); if (!hasDropPermission()) { - notification.displayValidationError(i18n.get("message.permission.insufficient")); + notification.displayValidationError(i18n.getMessage("message.permission.insufficient")); return false; } @@ -420,7 +420,7 @@ public abstract class AbstractTable extends Table impl return validateDragAndDropWrapper((DragAndDropWrapper) compsource) && validateDropList(getDraggedTargetList(dragEvent)); } - notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG)); + notification.displayValidationError(i18n.getMessage(ACTION_NOT_ALLOWED_MSG)); return false; } 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 8d41ff654..03bf215a1 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 @@ -18,7 +18,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.vaadin.spring.events.EventBus; @@ -41,7 +41,7 @@ public abstract class AbstractTableHeader extends VerticalLayout { private static final long serialVersionUID = 4881626370291837175L; - protected I18N i18n; + protected VaadinMessageSource i18n; protected SpPermissionChecker permChecker; @@ -67,7 +67,7 @@ public abstract class AbstractTableHeader extends VerticalLayout { protected final ManageDistUIState manageDistUIstate; protected final ArtifactUploadState artifactUploadState; - protected AbstractTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus, + protected AbstractTableHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus, final ManagementUIState managementUIState, final ManageDistUIState manageDistUIstate, final ArtifactUploadState artifactUploadState) { this.i18n = i18n; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java index d82553340..15eb736cf 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java @@ -18,7 +18,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -64,7 +64,7 @@ public abstract class AbstractTagToken implements Serializ protected SpPermissionChecker checker; - protected I18N i18n; + protected VaadinMessageSource i18n; protected UINotification uinotification; @@ -77,7 +77,7 @@ public abstract class AbstractTagToken implements Serializ @SuppressWarnings("squid:S1948") protected T selectedEntity; - protected AbstractTagToken(final SpPermissionChecker checker, final I18N i18n, final UINotification uinotification, + protected AbstractTagToken(final SpPermissionChecker checker, final VaadinMessageSource i18n, final UINotification uinotification, final UIEventBus eventBus, final ManagementUIState managementUIState) { this.checker = checker; this.i18n = i18n; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java index abfb1a498..b475c4345 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java @@ -17,7 +17,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer; import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventScope; @@ -37,7 +37,7 @@ public abstract class AbstractTargetTagToken extends Abstr protected final transient TagManagement tagManagement; - protected AbstractTargetTagToken(final SpPermissionChecker checker, final I18N i18n, + protected AbstractTargetTagToken(final SpPermissionChecker checker, final VaadinMessageSource i18n, final UINotification uinotification, final UIEventBus eventBus, final ManagementUIState managementUIState, final TagManagement tagManagement) { super(checker, i18n, uinotification, eventBus, managementUIState); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java index 8a24c5024..e9aaceb04 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java @@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventScope; @@ -48,7 +48,7 @@ public class DistributionTagToken extends AbstractTagToken { // To Be Done : have to set this value based on view??? private static final Boolean NOTAGS_SELECTED = Boolean.FALSE; - public DistributionTagToken(final SpPermissionChecker checker, final I18N i18n, final UINotification uinotification, + public DistributionTagToken(final SpPermissionChecker checker, final VaadinMessageSource i18n, final UINotification uinotification, final UIEventBus eventBus, final ManagementUIState managementUIState, final TagManagement tagManagement, final DistributionSetManagement distributionSetManagement) { super(checker, i18n, uinotification, eventBus, managementUIState); @@ -63,7 +63,7 @@ public class DistributionTagToken extends AbstractTagToken { @Override protected String getTokenInputPrompt() { - return i18n.get("combo.type.tag.name"); + return i18n.getMessage("combo.type.tag.name"); } @Override @@ -74,7 +74,7 @@ public class DistributionTagToken extends AbstractTagToken { eventBus.publish(this, ManagementUIEvent.ASSIGN_DISTRIBUTION_TAG); } } else { - uinotification.displayValidationError(i18n.get("message.error.missing.tagname")); + uinotification.displayValidationError(i18n.getMessage("message.error.missing.tagname")); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java index c840857fd..a945abf8f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java @@ -21,7 +21,7 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.data.domain.PageRequest; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -44,7 +44,7 @@ public class TargetTagToken extends AbstractTargetTagToken { private final transient TargetManagement targetManagement; - public TargetTagToken(final SpPermissionChecker checker, final I18N i18n, final UINotification uinotification, + public TargetTagToken(final SpPermissionChecker checker, final VaadinMessageSource i18n, final UINotification uinotification, final UIEventBus eventBus, final ManagementUIState managementUIState, final TagManagement tagManagement, final TargetManagement targetManagement) { super(checker, i18n, uinotification, eventBus, managementUIState, tagManagement); @@ -58,7 +58,7 @@ public class TargetTagToken extends AbstractTargetTagToken { @Override protected String getTokenInputPrompt() { - return i18n.get("combo.type.tag.name"); + return i18n.getMessage("combo.type.tag.name"); } @Override @@ -69,7 +69,7 @@ public class TargetTagToken extends AbstractTargetTagToken { eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG); } } else { - uinotification.displayValidationError(i18n.get("message.error.missing.tagname")); + uinotification.displayValidationError(i18n.getMessage("message.error.missing.tagname")); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/DistributionSetInfoPanel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/DistributionSetInfoPanel.java index ea02b6128..9d13c599a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/DistributionSetInfoPanel.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/DistributionSetInfoPanel.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.components; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import com.vaadin.ui.Label; @@ -55,10 +55,10 @@ public class DistributionSetInfoPanel extends Panel { */ private void decorate(final DistributionSet distributionSet, final String caption, final String style1, final String style2) { - final I18N i18n = SpringContextHelper.getBean(I18N.class); + final VaadinMessageSource i18n = SpringContextHelper.getBean(VaadinMessageSource.class); final VerticalLayout layout = new VerticalLayout(); // Display distribution set name - layout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.name"), + layout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.getMessage("label.dist.details.name"), distributionSet.getName(), distributionSet.getVersion())); /* Module info */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/HawkbitUIErrorHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/HawkbitUIErrorHandler.java index f5f5185d6..2912b187f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/HawkbitUIErrorHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/HawkbitUIErrorHandler.java @@ -19,7 +19,7 @@ import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -103,9 +103,9 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler { final String errorMessage = extractMessageFrom(ex); - final I18N i18n = SpringContextHelper.getBean(I18N.class); - return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"), - i18n.get("message.error.temp", errorMessage), false); + final VaadinMessageSource i18n = SpringContextHelper.getBean(VaadinMessageSource.class); + return new HawkbitErrorNotificationMessage(STYLE, i18n.getMessage("caption.error"), + i18n.getMessage("message.error.temp", errorMessage), false); } private String extractMessageFrom(final Throwable ex) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/NotificationUnreadButton.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/NotificationUnreadButton.java index 619a00c76..4b386ff93 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/NotificationUnreadButton.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/NotificationUnreadButton.java @@ -12,7 +12,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.hawkbit.ui.push.EventContainer; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.springframework.beans.factory.annotation.Autowired; @@ -48,7 +48,7 @@ public class NotificationUnreadButton extends Button { private AbstractNotificationView currentView; private Window notificationsWindow; private transient Map, NotificationUnreadValue> unreadNotifications; - private transient I18N i18n; + private transient VaadinMessageSource i18n; /** * Constructor. @@ -57,7 +57,7 @@ public class NotificationUnreadButton extends Button { * i18n */ @Autowired - NotificationUnreadButton(final I18N i18n) { + NotificationUnreadButton(final VaadinMessageSource i18n) { this.i18n = i18n; this.unreadNotifications = new ConcurrentHashMap<>(); setIcon(FontAwesome.BELL); @@ -76,7 +76,7 @@ public class NotificationUnreadButton extends Button { notificationsLayout.setMargin(true); notificationsLayout.setSpacing(true); - final Label title = new Label(i18n.get(TITLE)); + final Label title = new Label(i18n.getMessage(TITLE)); title.addStyleName(ValoTheme.LABEL_H3); title.addStyleName(ValoTheme.LABEL_NO_MARGIN); notificationsLayout.addComponent(title); @@ -118,7 +118,7 @@ public class NotificationUnreadButton extends Button { private void createNotification(final VerticalLayout notificationsLayout, final NotificationUnreadValue notificationUnreadValue) { final Label contentLabel = new Label(notificationUnreadValue.getUnreadNotifications() + " " - + i18n.get(notificationUnreadValue.getUnreadNotificationMessageKey())); + + i18n.getMessage(notificationUnreadValue.getUnreadNotificationMessageKey())); notificationsLayout.addComponent(contentLabel); } @@ -172,7 +172,7 @@ public class NotificationUnreadButton extends Button { setEnabled(true); setCaption("
" + unreadNotificationCounter + "
"); } - setDescription(i18n.get(DESCRIPTION, new Object[] { unreadNotificationCounter })); + setDescription(i18n.getMessage(DESCRIPTION, new Object[] { unreadNotificationCounter })); } private static class NotificationUnreadValue { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPTargetAttributesLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPTargetAttributesLayout.java index cb45ca2d9..a057cdb3d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPTargetAttributesLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPTargetAttributesLayout.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.components; import java.util.Map; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; @@ -45,8 +45,8 @@ public class SPTargetAttributesLayout { * @param controllerAttibs */ private void decorate(final Map controllerAttibs) { - final I18N i18n = SpringContextHelper.getBean(I18N.class); - final Label title = new Label(i18n.get("label.target.controller.attrs"), ContentMode.HTML); + final VaadinMessageSource i18n = SpringContextHelper.getBean(VaadinMessageSource.class); + final Label title = new Label(i18n.getMessage("label.target.controller.attrs"), ContentMode.HTML); title.addStyleName(SPUIDefinitions.TEXT_STYLE); targetAttributesLayout.addComponent(title); if (HawkbitCommonUtil.isNotNullOrEmpty(controllerAttibs)) { 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 ca133f16a..3726858dd 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 @@ -17,7 +17,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator; import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -231,8 +231,8 @@ public final class SPUIComponentProvider { * the entity * @return the label */ - public static Label createCreatedByLabel(final I18N i18n, final BaseEntity baseEntity) { - return createUsernameLabel(i18n.get("label.created.by"), + public static Label createCreatedByLabel(final VaadinMessageSource i18n, final BaseEntity baseEntity) { + return createUsernameLabel(i18n.getMessage("label.created.by"), baseEntity == null ? StringUtils.EMPTY : baseEntity.getCreatedBy()); } @@ -246,8 +246,8 @@ public final class SPUIComponentProvider { * the entity * @return the label */ - public static Label createLastModifiedByLabel(final I18N i18n, final BaseEntity baseEntity) { - return createUsernameLabel(i18n.get("label.modified.by"), + public static Label createLastModifiedByLabel(final VaadinMessageSource i18n, final BaseEntity baseEntity) { + return createUsernameLabel(i18n.getMessage("label.modified.by"), baseEntity == null ? StringUtils.EMPTY : baseEntity.getLastModifiedBy()); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java index 611a18a4f..4abd627b1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java @@ -40,7 +40,7 @@ import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer; import org.eclipse.hawkbit.ui.push.SoftwareModuleCreatedEventContainer; import org.eclipse.hawkbit.ui.push.SoftwareModuleDeletedEventContainer; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; @@ -69,7 +69,7 @@ public class DistributionsView extends AbstractNotificationView implements Brows private final SpPermissionChecker permChecker; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UINotification uiNotification; @@ -90,7 +90,7 @@ public class DistributionsView extends AbstractNotificationView implements Brows private GridLayout mainLayout; @Autowired - DistributionsView(final SpPermissionChecker permChecker, final UIEventBus eventBus, final I18N i18n, + DistributionsView(final SpPermissionChecker permChecker, final UIEventBus eventBus, final VaadinMessageSource i18n, final UINotification uiNotification, final ManageDistUIState manageDistUIState, final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement, final TargetManagement targetManagement, final EntityFactory entityFactory, @@ -228,7 +228,7 @@ public class DistributionsView extends AbstractNotificationView implements Brows private void checkNoDataAvaialble() { if (manageDistUIState.isNoDataAvilableSwModule() && manageDistUIState.isNoDataAvailableDist()) { - uiNotification.displayValidationError(i18n.get("message.no.data")); + uiNotification.displayValidationError(i18n.getMessage("message.no.data")); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java index 61160d8d3..f1fbd407b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java @@ -33,7 +33,7 @@ import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent; import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent.DistributionSetTypeEnum; import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -103,7 +103,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout assignedSWModule; - DistributionSetDetails(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, + DistributionSetDetails(final VaadinMessageSource i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, final ManageDistUIState manageDistUIState, final ManagementUIState managementUIState, final DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout, final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement, @@ -295,7 +295,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet detailsTabLayout.removeAllComponents(); if (type != null) { - final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"), + final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.type"), type); typeLabel.setId(UIComponentIdProvider.DETAILS_TYPE_LABEL_ID); detailsTabLayout.addComponent(typeLabel); @@ -303,15 +303,15 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet if (isMigrationRequired != null) { detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel( - getI18n().get("checkbox.dist.migration.required"), - isMigrationRequired.equals(Boolean.TRUE) ? getI18n().get("label.yes") : getI18n().get("label.no"))); + getI18n().getMessage("checkbox.dist.migration.required"), + isMigrationRequired.equals(Boolean.TRUE) ? getI18n().getMessage("label.yes") : getI18n().getMessage("label.no"))); } } @Override protected void onEdit(final ClickEvent event) { final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow(getSelectedBaseEntityId()); - newDistWindow.setCaption(getI18n().get(UIComponentIdProvider.DIST_UPDATE_CAPTION)); + newDistWindow.setCaption(getI18n().getMessage(UIComponentIdProvider.DIST_UPDATE_CAPTION)); UI.getCurrent().addWindow(newDistWindow); newDistWindow.setVisible(Boolean.TRUE); } @@ -334,18 +334,18 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet @Override protected String getDefaultCaption() { - return getI18n().get("distribution.details.header"); + return getI18n().getMessage("distribution.details.header"); } @Override protected void addTabs(final TabSheet detailsTab) { - detailsTab.addTab(createDetailsLayout(), getI18n().get("caption.tab.details"), null); - detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null); - detailsTab.addTab(createSoftwareModuleTab(), getI18n().get("caption.softwares.distdetail.tab"), null); - detailsTab.addTab(createTagsLayout(), getI18n().get("caption.tags.tab"), null); - detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null); - detailsTab.addTab(dsMetadataTable, getI18n().get("caption.metadata"), null); - detailsTab.addTab(tfqDetailsTable, getI18n().get("caption.auto.assignment.ds"), null); + detailsTab.addTab(createDetailsLayout(), getI18n().getMessage("caption.tab.details"), null); + detailsTab.addTab(createDescriptionLayout(), getI18n().getMessage("caption.tab.description"), null); + detailsTab.addTab(createSoftwareModuleTab(), getI18n().getMessage("caption.softwares.distdetail.tab"), null); + detailsTab.addTab(createTagsLayout(), getI18n().getMessage("caption.tags.tab"), null); + detailsTab.addTab(createLogLayout(), getI18n().getMessage("caption.logs.tab"), null); + detailsTab.addTab(dsMetadataTable, getI18n().getMessage("caption.metadata"), null); + detailsTab.addTab(tfqDetailsTable, getI18n().getMessage("caption.auto.assignment.ds"), null); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java index 30ecc9bb9..17c4f1c51 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java @@ -40,7 +40,7 @@ import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent; import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -90,7 +90,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable 0) { /* Distribution is already assigned */ - notification.displayValidationError(i18n.get("message.dist.inuse", + notification.displayValidationError(i18n.getMessage("message.dist.inuse", HawkbitCommonUtil.concatStrings(":", ds.getName(), ds.getVersion()))); return false; } if (ds.getModules().contains(sm)) { /* Already has software module */ - notification.displayValidationError(i18n.get("message.software.dist.already.assigned", + notification.displayValidationError(i18n.getMessage("message.software.dist.already.assigned", HawkbitCommonUtil.concatStrings(":", ds.getName(), ds.getVersion()), HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion()))); return false; @@ -360,7 +360,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable swModuleIdNames = entry.getValue(); for (final SoftwareModuleIdName swModuleIdName : swModuleIdNames) { if ((sm.getName().concat(":" + sm.getVersion())).equals(swModuleIdName.getName())) { - notification.displayValidationError(i18n.get("message.software.already.dragged", + notification.displayValidationError(i18n.getMessage("message.software.already.dragged", HawkbitCommonUtil.concatStrings(":", sm.getName(), sm.getVersion()))); return false; } @@ -488,7 +488,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable tabs = Maps.newHashMapWithExpectedSize(5); /* Create tab for SW Modules delete */ if (!manageDistUIState.getDeleteSofwareModulesList().isEmpty()) { - tabs.put(i18n.get("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab()); + tabs.put(i18n.getMessage("caption.delete.swmodule.accordion.tab"), createSMDeleteConfirmationTab()); } /* Create tab for SW Module Type delete */ if (!manageDistUIState.getSelectedDeleteSWModuleTypes().isEmpty()) { - tabs.put(i18n.get("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab()); + tabs.put(i18n.getMessage("caption.delete.sw.module.type.accordion.tab"), createSMtypeDeleteConfirmationTab()); } /* Create tab for Distributions delete */ if (!manageDistUIState.getDeletedDistributionList().isEmpty()) { - tabs.put(i18n.get("caption.delete.dist.accordion.tab"), createDistDeleteConfirmationTab()); + tabs.put(i18n.getMessage("caption.delete.dist.accordion.tab"), createDistDeleteConfirmationTab()); } /* Create tab for Distribution Set Types delete */ if (!manageDistUIState.getSelectedDeleteDistSetTypes().isEmpty()) { - tabs.put(i18n.get("caption.delete.dist.set.type.accordion.tab"), createDistSetTypeDeleteConfirmationTab()); + tabs.put(i18n.getMessage("caption.delete.dist.set.type.accordion.tab"), createDistSetTypeDeleteConfirmationTab()); } /* Create tab for Assign Software Module */ if (!manageDistUIState.getAssignedList().isEmpty()) { - tabs.put(i18n.get("caption.assign.dist.accordion.tab"), createAssignSWModuleConfirmationTab()); + tabs.put(i18n.getMessage("caption.assign.dist.accordion.tab"), createAssignSWModuleConfirmationTab()); } return tabs; @@ -129,10 +129,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW tab.getConfirmAll().setId(UIComponentIdProvider.SW_DELETE_ALL); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL)); + tab.getConfirmAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DELETE_ALL)); tab.getConfirmAll().addClickListener(event -> deleteSMAll(tab)); - tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); + tab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); tab.getDiscardAll().addClickListener(event -> discardSMAll(tab)); /* Add items container to the table. */ @@ -145,8 +145,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW }); tab.getTable().setVisibleColumns(SW_MODULE_NAME_MSG, SW_DISCARD_CHGS); - tab.getTable().setColumnHeaders(i18n.get("upload.swModuleTable.header"), - i18n.get("header.second.deletetarget.table")); + tab.getTable().setColumnHeaders(i18n.getMessage("upload.swModuleTable.header"), + i18n.getMessage("header.second.deletetarget.table")); tab.getTable().setColumnExpandRatio(SW_MODULE_NAME_MSG, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH); tab.getTable().setColumnExpandRatio(SW_DISCARD_CHGS, SPUIDefinitions.DISCARD_COLUMN_WIDTH); @@ -165,10 +165,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.REMOVE_ENTITY, swmoduleIds)); addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.swModule.deleted", swmoduleIds.size())); + + i18n.getMessage("message.swModule.deleted", swmoduleIds.size())); manageDistUIState.getDeleteSofwareModulesList().clear(); removeCurrentTab(tab); - setActionMessage(i18n.get("message.software.delete.success")); + setActionMessage(i18n.getMessage("message.software.delete.success")); eventBus.publish(this, SaveActionWindowEvent.DELETE_ALL_SOFWARE); } @@ -194,7 +194,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW private void discardSMAll(final ConfirmationTab tab) { removeCurrentTab(tab); manageDistUIState.getDeleteSofwareModulesList().clear(); - setActionMessage(i18n.get("message.software.discard.success")); + setActionMessage(i18n.getMessage("message.software.discard.success")); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_SOFTWARE); } @@ -239,10 +239,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW tab.getConfirmAll().setId(UIComponentIdProvider.SAVE_DELETE_SW_MODULE_TYPE); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL)); + tab.getConfirmAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DELETE_ALL)); tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab)); - tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); + tab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); tab.getDiscardAll().setId(UIComponentIdProvider.DISCARD_SW_MODULE_TYPE); tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab)); @@ -264,8 +264,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW }); tab.getTable().setVisibleColumns(SW_MODULE_TYPE_NAME, DISCARD); - tab.getTable().setColumnHeaders(i18n.get("header.first.delete.swmodule.type.table"), - i18n.get("header.second.delete.swmodule.type.table")); + tab.getTable().setColumnHeaders(i18n.getMessage("header.first.delete.swmodule.type.table"), + i18n.getMessage("header.second.delete.swmodule.type.table")); tab.getTable().setColumnExpandRatio(SW_MODULE_TYPE_NAME, 2); tab.getTable().setColumnExpandRatio(SW_DISCARD_CHGS, SPUIDefinitions.DISCARD_COLUMN_WIDTH); @@ -281,17 +281,17 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW .ifPresent(softwareManagement::deleteSoftwareModuleType); } addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount })); + + i18n.getMessage("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount })); manageDistUIState.getSelectedDeleteSWModuleTypes().clear(); removeCurrentTab(tab); - setActionMessage(i18n.get("message.software.type.delete.success")); + setActionMessage(i18n.getMessage("message.software.type.delete.success")); eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES); } private void discardSMtypeAll(final ConfirmationTab tab) { removeCurrentTab(tab); manageDistUIState.getSelectedDeleteSWModuleTypes().clear(); - setActionMessage(i18n.get("message.software.type.discard.success")); + setActionMessage(i18n.getMessage("message.software.type.discard.success")); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_SW_MODULE_TYPES); } @@ -331,10 +331,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW tab.getConfirmAll().setId(UIComponentIdProvider.DIST_DELETE_ALL); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL)); + tab.getConfirmAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DELETE_ALL)); tab.getConfirmAll().addClickListener(event -> deleteDistAll(tab)); - tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); + tab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); tab.getDiscardAll().addClickListener(event -> discardDistAll(tab)); /* Add items container to the table. */ @@ -348,8 +348,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW }); tab.getTable().setVisibleColumns(DIST_NAME, DISCARD); - tab.getTable().setColumnHeaders(i18n.get("header.one.deletedist.table"), - i18n.get("header.second.deletedist.table")); + tab.getTable().setColumnHeaders(i18n.getMessage("header.one.deletedist.table"), + i18n.getMessage("header.second.deletedist.table")); tab.getTable().setColumnExpandRatio(DIST_NAME, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH); tab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH); @@ -375,7 +375,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW dsManagement.deleteDistributionSet(Lists.newArrayList(deletedIds)); addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.dist.deleted", deletedIds.length)); + + i18n.getMessage("message.dist.deleted", deletedIds.length)); manageDistUIState.getDeletedDistributionList() .forEach(deletedIdname -> manageDistUIState.getAssignedList().remove(deletedIdname)); @@ -387,7 +387,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW private void discardDistAll(final ConfirmationTab tab) { removeCurrentTab(tab); manageDistUIState.getDeletedDistributionList().clear(); - setActionMessage(i18n.get("message.dist.discard.success")); + setActionMessage(i18n.getMessage("message.dist.discard.success")); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS); } @@ -429,10 +429,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW tab.getConfirmAll().setId(UIComponentIdProvider.SAVE_DELETE_DIST_SET_TYPE); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL)); + tab.getConfirmAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DELETE_ALL)); tab.getConfirmAll().addClickListener(event -> deleteDistSetTypeAll(tab)); - tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); + tab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); tab.getDiscardAll().setId(UIComponentIdProvider.DISCARD_DIST_SET_TYPE); tab.getDiscardAll().addClickListener(event -> discardDistSetTypeAll(tab)); @@ -448,8 +448,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW }); tab.getTable().setVisibleColumns(DIST_SET_NAME, DISCARD); - tab.getTable().setColumnHeaders(i18n.get("header.first.delete.dist.type.table"), - i18n.get("header.second.delete.dist.type.table")); + tab.getTable().setColumnHeaders(i18n.getMessage("header.first.delete.dist.type.table"), + i18n.getMessage("header.second.delete.dist.type.table")); tab.getTable().setColumnExpandRatio(DIST_SET_NAME, 2); tab.getTable().setColumnExpandRatio(DISCARD, SPUIDefinitions.DISCARD_COLUMN_WIDTH); @@ -465,17 +465,17 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW .forEach(dsManagement::deleteDistributionSetType); addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.dist.type.delete", new Object[] { deleteDistTypeCount })); + + i18n.getMessage("message.dist.type.delete", new Object[] { deleteDistTypeCount })); manageDistUIState.getSelectedDeleteDistSetTypes().clear(); removeCurrentTab(tab); - setActionMessage(i18n.get("message.dist.set.type.deleted.success")); + setActionMessage(i18n.getMessage("message.dist.set.type.deleted.success")); eventBus.publish(this, SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES); } private void discardDistSetTypeAll(final ConfirmationTab tab) { removeCurrentTab(tab); manageDistUIState.getSelectedDeleteDistSetTypes().clear(); - setActionMessage(i18n.get("message.dist.type.discard.success")); + setActionMessage(i18n.getMessage("message.dist.type.discard.success")); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DELETE_DIST_SET_TYPES); } @@ -517,10 +517,10 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW assignmnetTab.getConfirmAll().setId(UIComponentIdProvider.SAVE_ASSIGNMENT); assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE); - assignmnetTab.getConfirmAll().setCaption(i18n.get("button.assign.all")); + assignmnetTab.getConfirmAll().setCaption(i18n.getMessage("button.assign.all")); assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab)); - assignmnetTab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); + assignmnetTab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); assignmnetTab.getDiscardAll().setId(UIComponentIdProvider.DISCARD_ASSIGNMENT); assignmnetTab.getDiscardAll().addClickListener(event -> discardAllSWAssignments(assignmnetTab)); @@ -542,8 +542,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW }); assignmnetTab.getTable().setVisibleColumns(DIST_NAME, SOFTWARE_MODULE_NAME, DISCARD); - assignmnetTab.getTable().setColumnHeaders(i18n.get("header.dist.first.assignment.table"), - i18n.get("header.dist.second.assignment.table"), i18n.get("header.third.assignment.table")); + assignmnetTab.getTable().setColumnHeaders(i18n.getMessage("header.dist.first.assignment.table"), + i18n.getMessage("header.dist.second.assignment.table"), i18n.getMessage("header.third.assignment.table")); assignmnetTab.getTable().setColumnExpandRatio(DIST_NAME, 2); assignmnetTab.getTable().setColumnExpandRatio(SOFTWARE_MODULE_NAME, 2); @@ -593,7 +593,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW count += entry.getValue().size(); } addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.software.assignment", new Object[] { count })); + + i18n.getMessage("message.software.assignment", new Object[] { count })); manageDistUIState.getAssignedList().clear(); manageDistUIState.getConsolidatedDistSoftwarewList().clear(); removeCurrentTab(tab); @@ -604,7 +604,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW removeCurrentTab(tab); manageDistUIState.getAssignedList().clear(); manageDistUIState.getConsolidatedDistSoftwarewList().clear(); - setActionMessage(i18n.get("message.assign.discard.success")); + setActionMessage(i18n.getMessage("message.assign.discard.success")); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwMetadataPopupLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwMetadataPopupLayout.java index 0e1ba5342..08a2e313c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwMetadataPopupLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwMetadataPopupLayout.java @@ -20,7 +20,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout; import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -35,7 +35,7 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout getTableVisibleColumns() { final List columnList = super.getTableVisibleColumns(); if (isMaximized()) { - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.getMessage("header.vendor"), 0.1F)); } else { columnList.add(new TableColumn(SPUILabelDefinitions.ARTIFACT_ICON, "", 0.1F)); } @@ -346,7 +346,7 @@ public class SwModuleTable extends AbstractNamedVersionTable { private static final long serialVersionUID = 6464291374980641235L; - public SwModuleTableLayout(final I18N i18n, final UINotification uiNotification, final UIEventBus eventBus, + public SwModuleTableLayout(final VaadinMessageSource i18n, final UINotification uiNotification, final UIEventBus eventBus, final SoftwareManagement softwareManagement, final EntityFactory entityFactory, final ManageDistUIState manageDistUIState, final SpPermissionChecker permChecker, final DistributionsViewClientCriterion distributionsViewClientCriterion, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java index 78df12233..d3d806d88 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java @@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.artifacts.smtype.CreateUpdateSoftwareTypeLayout; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -36,7 +36,7 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader { private final ManageDistUIState manageDistUIState; private final CreateUpdateSoftwareTypeLayout createUpdateSWTypeLayout; - DistSMTypeFilterHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus, + DistSMTypeFilterHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus, final ManageDistUIState manageDistUIState, final TagManagement tagManagement, final EntityFactory entityFactory, final UINotification uiNotification, final SoftwareManagement swTypeManagementService) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterLayout.java index 5ce4fffec..45339f927 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterLayout.java @@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout; import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventScope; @@ -31,7 +31,7 @@ public class DistSMTypeFilterLayout extends AbstractFilterLayout { private final ManageDistUIState manageDistUIState; - public DistSMTypeFilterLayout(final UIEventBus eventBus, final I18N i18n, final SpPermissionChecker permChecker, + public DistSMTypeFilterLayout(final UIEventBus eventBus, final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final ManageDistUIState manageDistUIState, final TagManagement tagManagement, final EntityFactory entityFactory, final UINotification uiNotification, final SoftwareManagement softwareManagement, 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 e6baacc74..d6763df52 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 @@ -22,7 +22,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -57,7 +57,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button private static final String BREADCRUMB_CUSTOM_FILTERS = "breadcrumb.target.filter.custom.filters"; - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient EventBus.UIEventBus eventBus; @@ -105,7 +105,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button private LayoutClickListener nameLayoutClickListner; - CreateOrUpdateFilterHeader(final I18N i18n, final UIEventBus eventBus, + CreateOrUpdateFilterHeader(final VaadinMessageSource i18n, final UIEventBus eventBus, final FilterManagementUIState filterManagementUIState, final TargetFilterQueryManagement targetFilterQueryManagement, final SpPermissionChecker permissionChecker, final UINotification notification, final UiProperties uiProperties, final EntityFactory entityFactory, @@ -193,16 +193,16 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button final Button createFilterViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null, SPUIButtonStyleSmallNoBorder.class); createFilterViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links"); - createFilterViewLink.setDescription(i18n.get(BREADCRUMB_CUSTOM_FILTERS)); - createFilterViewLink.setCaption(i18n.get(BREADCRUMB_CUSTOM_FILTERS)); + createFilterViewLink.setDescription(i18n.getMessage(BREADCRUMB_CUSTOM_FILTERS)); + createFilterViewLink.setCaption(i18n.getMessage(BREADCRUMB_CUSTOM_FILTERS)); createFilterViewLink.addClickListener(value -> showCustomFiltersView()); return createFilterViewLink; } private TextField createNameTextField() { - final TextField nameField = new TextFieldBuilder().caption(i18n.get("textfield.customfiltername")) - .prompt(i18n.get("textfield.customfiltername")).immediate(true) + final TextField nameField = new TextFieldBuilder().caption(i18n.getMessage("textfield.customfiltername")) + .prompt(i18n.getMessage("textfield.customfiltername")).immediate(true) .id(UIComponentIdProvider.CUSTOM_FILTER_ADD_NAME).buildTextComponent(); nameField.setPropertyDataSource(nameLabel); nameField.addTextChangeListener(this::onFilterNameChange); @@ -241,7 +241,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button private void buildLayout() { captionLayout = new HorizontalLayout(); - captionLayout.setDescription(i18n.get("tooltip.click.to.edit")); + captionLayout.setDescription(i18n.getMessage("tooltip.click.to.edit")); captionLayout.setId(UIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LAYOUT_ID); titleFilterIconsLayout = new HorizontalLayout(); @@ -371,7 +371,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(entityFactory .targetFilterQuery().create().name(nameTextField.getValue()).query(queryTextField.getValue())); notification.displaySuccess( - i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() })); + i18n.getMessage("message.create.filter.success", new Object[] { targetFilterQuery.getName() })); eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY); } @@ -387,7 +387,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button filterManagementUIState.setTfQuery(updatedTargetFilter); oldFilterName = nameTextField.getValue(); oldFilterQuery = queryTextField.getValue(); - notification.displaySuccess(i18n.get("message.update.filter.success")); + notification.displaySuccess(i18n.getMessage("message.update.filter.success")); eventBus.publish(this, CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY); } @@ -401,7 +401,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button private boolean doesAlreadyExists() { if (targetFilterQueryManagement.findTargetFilterQueryByName(nameTextField.getValue()).isPresent()) { - notification.displayValidationError(i18n.get("message.target.filter.duplicate", nameTextField.getValue())); + notification.displayValidationError(i18n.getMessage("message.target.filter.duplicate", nameTextField.getValue())); return true; } return false; @@ -410,7 +410,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button private boolean manadatoryFieldsPresent() { if (Strings.isNullOrEmpty(nameTextField.getValue()) || Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) { - notification.displayValidationError(i18n.get("message.target.filter.validation")); + notification.displayValidationError(i18n.getMessage("message.target.filter.validation")); return false; } return true; 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 402896307..a614946fb 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 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; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -53,7 +53,7 @@ public class CreateOrUpdateFilterTable extends Table { private static final long serialVersionUID = 6887304217281629713L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final FilterManagementUIState filterManagementUIState; @@ -67,7 +67,7 @@ public class CreateOrUpdateFilterTable extends Table { private static final String INSTALL_DIST_SET = "installedDistributionSet"; - CreateOrUpdateFilterTable(final I18N i18n, final UIEventBus eventBus, + CreateOrUpdateFilterTable(final VaadinMessageSource i18n, final UIEventBus eventBus, final FilterManagementUIState filterManagementUIState) { this.i18n = i18n; this.filterManagementUIState = filterManagementUIState; @@ -180,14 +180,14 @@ public class CreateOrUpdateFilterTable extends Table { private List getVisbleColumns() { final List columnList = Lists.newArrayListWithExpectedSize(7); - columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.getMessage("header.name"), 0.15F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.getMessage("header.createdBy"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.getMessage("header.createdDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.getMessage("header.modifiedBy"), 0.1F)); columnList.add( - new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F)); + new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.getMessage("header.modifiedDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.getMessage("header.description"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.getMessage("header.status"), 0.1F)); return columnList; } @@ -207,7 +207,7 @@ public class CreateOrUpdateFilterTable extends Table { label.setStyleName(SPUIStyleDefinitions.STATUS_ICON_LIGHT_BLUE); label.setValue(FontAwesome.DOT_CIRCLE_O.getHtml()); } else if (targetStatus == TargetUpdateStatus.ERROR) { - label.setDescription(i18n.get("label.error")); + label.setDescription(i18n.getMessage("label.error")); label.setStyleName(SPUIStyleDefinitions.STATUS_ICON_RED); label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml()); } else if (targetStatus == TargetUpdateStatus.IN_SYNC) { @@ -216,7 +216,7 @@ public class CreateOrUpdateFilterTable extends Table { label.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); } else if (targetStatus == TargetUpdateStatus.UNKNOWN) { label.setStyleName(SPUIStyleDefinitions.STATUS_ICON_BLUE); - label.setDescription(i18n.get("label.unknown")); + label.setDescription(i18n.getMessage("label.unknown")); label.setValue(FontAwesome.QUESTION_CIRCLE.getHtml()); } return label; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java index 54e8b1320..919a4010c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java @@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyTarget; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; @@ -48,7 +48,7 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery { private Sort sort = new Sort(Direction.ASC, "id"); private transient TargetManagement targetManagement; private FilterManagementUIState filterManagementUIState; - private transient I18N i18N; + private transient VaadinMessageSource i18N; private String filterQuery; /** @@ -159,9 +159,9 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery { return filterManagementUIState; } - private I18N getI18N() { + private VaadinMessageSource getI18N() { if (i18N == null) { - i18N = SpringContextHelper.getBean(I18N.class); + i18N = SpringContextHelper.getBean(VaadinMessageSource.class); } return i18N; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/DistributionSetSelectTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/DistributionSetSelectTable.java index 23500d9a2..81ceeb96b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/DistributionSetSelectTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/DistributionSetSelectTable.java @@ -17,7 +17,7 @@ import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; import org.eclipse.hawkbit.ui.distributions.dstable.ManageDistBeanQuery; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.TableColumn; @@ -40,13 +40,13 @@ public class DistributionSetSelectTable extends Table { private static final long serialVersionUID = -4307487829435471759L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final ManageDistUIState manageDistUIState; private Container container; - DistributionSetSelectTable(final I18N i18n, final UIEventBus eventBus, final ManageDistUIState manageDistUIState) { + DistributionSetSelectTable(final VaadinMessageSource i18n, final UIEventBus eventBus, final ManageDistUIState manageDistUIState) { this.i18n = i18n; this.manageDistUIState = manageDistUIState; setStyleName("sp-table"); @@ -98,8 +98,8 @@ public class DistributionSetSelectTable extends Table { private List getVisbleColumns() { final List columnList = new ArrayList<>(2); - columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.6F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.4F)); + columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.getMessage("header.name"), 0.6F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.getMessage("header.version"), 0.4F)); return columnList; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/DistributionSetSelectWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/DistributionSetSelectWindow.java index 54bb0c72b..91039d564 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/DistributionSetSelectWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/DistributionSetSelectWindow.java @@ -21,7 +21,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorderWithIcon; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.vaadin.spring.events.EventBus; @@ -48,7 +48,7 @@ public class DistributionSetSelectWindow private static final long serialVersionUID = 4752345414134989396L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final DistributionSetSelectTable dsTable; @@ -62,7 +62,7 @@ public class DistributionSetSelectWindow private CheckBox checkBox; private Long tfqId; - DistributionSetSelectWindow(final I18N i18n, final UIEventBus eventBus, final TargetManagement targetManagement, + DistributionSetSelectWindow(final VaadinMessageSource i18n, final UIEventBus eventBus, final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement, final ManageDistUIState manageDistUIState) { this.i18n = i18n; this.dsTable = new DistributionSetSelectTable(i18n, eventBus, manageDistUIState); @@ -72,9 +72,9 @@ public class DistributionSetSelectWindow } private void initLocal() { - final Label label = new Label(i18n.get("label.auto.assign.description")); + final Label label = new Label(i18n.getMessage("label.auto.assign.description")); - checkBox = new CheckBox(i18n.get("label.auto.assign.enable")); + checkBox = new CheckBox(i18n.getMessage("label.auto.assign.enable")); checkBox.setId(UIComponentIdProvider.DIST_SET_SELECT_ENABLE_ID); checkBox.setImmediate(true); checkBox.addValueChangeListener(this); @@ -85,7 +85,7 @@ public class DistributionSetSelectWindow verticalLayout.addComponent(dsTable); window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW) - .caption(i18n.get("caption.select.auto.assign.dist")).content(verticalLayout).layout(verticalLayout) + .caption(i18n.getMessage("caption.select.auto.assign.dist")).content(verticalLayout).layout(verticalLayout) .i18n(i18n).saveDialogCloseListener(this).buildCommonDialogWindow(); window.setId(UIComponentIdProvider.DIST_SET_SELECT_WINDOW_ID); } @@ -212,7 +212,7 @@ public class DistributionSetSelectWindow public ConfirmConsequencesDialog(final TargetFilterQuery targetFilterQuery, final Long dsId, final ConfirmCallback callback) { - super(i18n.get("caption.confirm.assign.consequences")); + super(i18n.getMessage("caption.confirm.assign.consequences")); this.callback = callback; this.targetFilterQuery = targetFilterQuery; @@ -236,10 +236,10 @@ public class DistributionSetSelectWindow targetFilterQuery.getQuery()); Label mainTextLabel; if (targetsCount == 0) { - mainTextLabel = new Label(i18n.get("message.confirm.assign.consequences.none")); + mainTextLabel = new Label(i18n.getMessage("message.confirm.assign.consequences.none")); } else { mainTextLabel = new Label( - i18n.get("message.confirm.assign.consequences.text", new Object[] { targetsCount })); + i18n.getMessage("message.confirm.assign.consequences.text", new Object[] { targetsCount })); } layout.addComponent(mainTextLabel); @@ -250,7 +250,7 @@ public class DistributionSetSelectWindow buttonsLayout.addStyleName("actionButtonsMargin"); layout.addComponent(buttonsLayout); - okButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SAVE_BUTTON, i18n.get("button.ok"), "", "", + okButton = SPUIComponentProvider.getButton(UIComponentIdProvider.SAVE_BUTTON, i18n.getMessage("button.ok"), "", "", true, FontAwesome.SAVE, SPUIButtonStyleNoBorderWithIcon.class); okButton.setSizeUndefined(); okButton.addStyleName("default-color"); @@ -260,7 +260,7 @@ public class DistributionSetSelectWindow buttonsLayout.setExpandRatio(okButton, 1.0F); final Button cancelButton = SPUIComponentProvider.getButton(UIComponentIdProvider.CANCEL_BUTTON, - i18n.get("button.cancel"), "", "", true, FontAwesome.TIMES, SPUIButtonStyleNoBorderWithIcon.class); + i18n.getMessage("button.cancel"), "", "", true, FontAwesome.TIMES, SPUIButtonStyleNoBorderWithIcon.class); cancelButton.setSizeUndefined(); cancelButton.addStyleName("default-color"); cancelButton.addClickListener(this); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementView.java index c85ab5ece..a815c0123 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementView.java @@ -21,7 +21,7 @@ import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.footer.TargetFilterCountMessageLabel; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; @@ -65,7 +65,7 @@ public class FilterManagementView extends VerticalLayout implements View { private final transient EventBus.UIEventBus eventBus; @Autowired - FilterManagementView(final I18N i18n, final UIEventBus eventBus, + FilterManagementView(final VaadinMessageSource i18n, final UIEventBus eventBus, final FilterManagementUIState filterManagementUIState, final TargetFilterQueryManagement targetFilterQueryManagement, final SpPermissionChecker permissionChecker, final UINotification notification, final UiProperties uiProperties, final EntityFactory entityFactory, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java index 2ba398b01..aefef7d7b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java @@ -22,7 +22,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.TableColumn; @@ -55,7 +55,7 @@ public class TargetFilterTable extends Table { private static final long serialVersionUID = -4307487829435474759L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UINotification notification; @@ -71,7 +71,7 @@ public class TargetFilterTable extends Table { private static final int PROPERTY_DEPT = 3; - public TargetFilterTable(final I18N i18n, final UINotification notification, final UIEventBus eventBus, + public TargetFilterTable(final VaadinMessageSource i18n, final UINotification notification, final UIEventBus eventBus, final FilterManagementUIState filterManagementUIState, final TargetFilterQueryManagement targetFilterQueryManagement, final ManageDistUIState manageDistUIState, final TargetManagement targetManagement) { @@ -140,14 +140,14 @@ public class TargetFilterTable extends Table { private List getVisbleColumns() { final List columnList = new ArrayList<>(7); - columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.2F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_USER, i18n.get("header.createdBy"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.2F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.2F)); + columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.getMessage("header.name"), 0.2F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_USER, i18n.getMessage("header.createdBy"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.getMessage("header.createdDate"), 0.2F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_MODIFIED_BY, i18n.getMessage("header.modifiedBy"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE, i18n.getMessage("header.modifiedDate"), 0.2F)); columnList.add(new TableColumn(SPUILabelDefinitions.AUTO_ASSIGN_DISTRIBUTION_SET, - i18n.get("header.auto.assignment.ds"), 0.1F)); - columnList.add(new TableColumn(SPUIDefinitions.CUSTOM_FILTER_DELETE, i18n.get("header.delete"), 0.1F)); + i18n.getMessage("header.auto.assignment.ds"), 0.1F)); + columnList.add(new TableColumn(SPUIDefinitions.CUSTOM_FILTER_DELETE, i18n.getMessage("header.delete"), 0.1F)); return columnList; } @@ -175,8 +175,8 @@ public class TargetFilterTable extends Table { private void onDelete(final ClickEvent event) { /* Display the confirmation */ - final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.filter.delete.confirmbox"), - i18n.get("message.delete.filter.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> { + final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.getMessage("caption.filter.delete.confirmbox"), + i18n.getMessage("message.delete.filter.confirm"), i18n.getMessage("button.ok"), i18n.getMessage("button.cancel"), ok -> { if (ok) { final Long rowId = (Long) ((Button) event.getComponent()).getData(); final String deletedFilterName = targetFilterQueryManagement.findTargetFilterQueryById(rowId) @@ -189,7 +189,7 @@ public class TargetFilterTable extends Table { */ notification.displaySuccess( - i18n.get("message.delete.filter.success", new Object[] { deletedFilterName })); + i18n.getMessage("message.delete.filter.success", new Object[] { deletedFilterName })); refreshContainer(); } }); @@ -228,11 +228,11 @@ public class TargetFilterTable extends Table { final String buttonId = "distSetButton"; Button updateIcon; if (distSet == null) { - updateIcon = SPUIComponentProvider.getButton(buttonId, i18n.get("button.no.auto.assignment"), - i18n.get("button.auto.assignment.desc"), null, false, null, SPUIButtonStyleSmallNoBorder.class); + updateIcon = SPUIComponentProvider.getButton(buttonId, i18n.getMessage("button.no.auto.assignment"), + i18n.getMessage("button.auto.assignment.desc"), null, false, null, SPUIButtonStyleSmallNoBorder.class); } else { updateIcon = SPUIComponentProvider.getButton(buttonId, distSet.getNameVersion(), - i18n.get("button.auto.assignment.desc"), null, false, null, SPUIButtonStyleSmallNoBorder.class); + i18n.getMessage("button.auto.assignment.desc"), null, false, null, SPUIButtonStyleSmallNoBorder.class); } updateIcon.addClickListener(this::onClickOfDistributionSetButton); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java index b55eb3ebe..374c136f2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.filtermanagement.footer; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -36,9 +36,9 @@ public class TargetFilterCountMessageLabel extends Label { private final FilterManagementUIState filterManagementUIState; - private final I18N i18n; + private final VaadinMessageSource i18n; - public TargetFilterCountMessageLabel(final FilterManagementUIState filterManagementUIState, final I18N i18n, + public TargetFilterCountMessageLabel(final FilterManagementUIState filterManagementUIState, final VaadinMessageSource i18n, final UIEventBus eventBus) { this.filterManagementUIState = filterManagementUIState; this.i18n = i18n; @@ -70,11 +70,11 @@ public class TargetFilterCountMessageLabel extends Label { if (null != filterManagementUIState.getFilterQueryValue()) { totalTargets = filterManagementUIState.getTargetsCountAll().get(); } - final StringBuilder targetMessage = new StringBuilder(i18n.get("label.target.filtered.total")); + final StringBuilder targetMessage = new StringBuilder(i18n.getMessage("label.target.filtered.total")); if (filterManagementUIState.getTargetsTruncated() != null) { // set the icon setIcon(FontAwesome.INFO_CIRCLE); - setDescription(i18n.get("label.target.filter.truncated", filterManagementUIState.getTargetsTruncated(), + setDescription(i18n.getMessage("label.target.filter.truncated", filterManagementUIState.getTargetsTruncated(), SPUIDefinitions.MAX_TABLE_ENTRIES)); } else { @@ -85,7 +85,7 @@ public class TargetFilterCountMessageLabel extends Label { if (totalTargets > SPUIDefinitions.MAX_TABLE_ENTRIES) { targetMessage.append(HawkbitCommonUtil.SP_STRING_PIPE); - targetMessage.append(i18n.get("label.filter.shown")); + targetMessage.append(i18n.getMessage("label.filter.shown")); targetMessage.append(SPUIDefinitions.MAX_TABLE_ENTRIES); } 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 383d215c9..60a14e25f 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 @@ -34,7 +34,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.management.event.DistributionSetTagTableEvent; import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -77,7 +77,7 @@ public abstract class AbstractCreateUpdateTagLayout exten protected static final String TAG_DYNAMIC_STYLE = "tag-color-preview"; protected static final String MESSAGE_ERROR_MISSING_TAGNAME = "message.error.missing.tagname"; - protected I18N i18n; + protected VaadinMessageSource i18n; protected transient TagManagement tagManagement; @@ -130,7 +130,7 @@ public abstract class AbstractCreateUpdateTagLayout exten * @param uiNotification * UINotification */ - public AbstractCreateUpdateTagLayout(final I18N i18n, final TagManagement tagManagement, + public AbstractCreateUpdateTagLayout(final VaadinMessageSource i18n, final TagManagement tagManagement, final EntityFactory entityFactory, final UIEventBus eventBus, final SpPermissionChecker permChecker, final UINotification uiNotification) { this.i18n = i18n; @@ -196,26 +196,26 @@ public abstract class AbstractCreateUpdateTagLayout exten protected void createRequiredComponents() { - createTagStr = i18n.get("label.create.tag"); - updateTagStr = i18n.get("label.update.tag"); - comboLabel = new LabelBuilder().name(i18n.get("label.choose.tag")).buildLabel(); - colorLabel = new LabelBuilder().name(i18n.get("label.choose.tag.color")).buildLabel(); + createTagStr = i18n.getMessage("label.create.tag"); + updateTagStr = i18n.getMessage("label.update.tag"); + comboLabel = new LabelBuilder().name(i18n.getMessage("label.choose.tag")).buildLabel(); + colorLabel = new LabelBuilder().name(i18n.getMessage("label.choose.tag.color")).buildLabel(); colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE); - tagName = new TextFieldBuilder().caption(i18n.get("textfield.name")) + tagName = new TextFieldBuilder().caption(i18n.getMessage("textfield.name")) .styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME).required(true) - .prompt(i18n.get("textfield.name")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_NAME) + .prompt(i18n.getMessage("textfield.name")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_NAME) .buildTextComponent(); - tagDesc = new TextAreaBuilder().caption(i18n.get("textfield.description")) + tagDesc = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")) .styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC) - .prompt(i18n.get("textfield.description")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_DESC) + .prompt(i18n.getMessage("textfield.description")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_DESC) .buildTextComponent(); tagDesc.setNullRepresentation(StringUtils.EMPTY); tagNameComboBox = SPUIComponentProvider.getComboBox(null, "", null, null, false, "", - i18n.get("label.combobox.tag")); + i18n.getMessage("label.combobox.tag")); tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE); tagNameComboBox.setImmediate(true); tagNameComboBox.setId(UIComponentIdProvider.DIST_TAG_COMBO); @@ -587,12 +587,12 @@ public abstract class AbstractCreateUpdateTagLayout exten eventBus.publish(this, new DistributionSetTagTableEvent(BaseEntityEventType.UPDATED_ENTITY, (DistributionSetTag) targetObj)); } - uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { targetObj.getName() })); + uiNotification.displaySuccess(i18n.getMessage("message.update.success", new Object[] { targetObj.getName() })); } protected void displaySuccess(final String tagName) { - uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { tagName })); + uiNotification.displaySuccess(i18n.getMessage("message.save.success", new Object[] { tagName })); } protected void displayValidationError(final String errorMessage) { @@ -610,7 +610,7 @@ public abstract class AbstractCreateUpdateTagLayout exten private boolean isDuplicateByName() { final Optional existingType = findEntityByName(); existingType.ifPresent(type -> uiNotification - .displayValidationError(i18n.get("message.tag.duplicate.check", new Object[] { type.getName() }))); + .displayValidationError(i18n.getMessage("message.tag.duplicate.check", new Object[] { type.getName() }))); return existingType.isPresent(); } 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 8590b7ea1..0edb122b9 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 @@ -19,7 +19,7 @@ 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.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -47,7 +47,7 @@ public abstract class CreateUpdateTypeLayout extends Abst private static final String TYPE_NAME_DYNAMIC_STYLE = "new-tag-name"; private static final String TYPE_DESC_DYNAMIC_STYLE = "new-tag-desc"; - public CreateUpdateTypeLayout(final I18N i18n, final TagManagement tagManagement, final EntityFactory entityFactory, + public CreateUpdateTypeLayout(final VaadinMessageSource i18n, final TagManagement tagManagement, final EntityFactory entityFactory, final UIEventBus eventBus, final SpPermissionChecker permChecker, final UINotification uiNotification) { super(i18n, tagManagement, entityFactory, eventBus, permChecker, uiNotification); } @@ -61,14 +61,14 @@ public abstract class CreateUpdateTypeLayout extends Abst @Override protected void createRequiredComponents() { - createTagStr = i18n.get("label.create.type"); - updateTagStr = i18n.get("label.update.type"); - comboLabel = new LabelBuilder().name(i18n.get("label.choose.type")).buildLabel(); - colorLabel = new LabelBuilder().name(i18n.get("label.choose.type.color")).buildLabel(); + createTagStr = i18n.getMessage("label.create.type"); + updateTagStr = i18n.getMessage("label.update.type"); + comboLabel = new LabelBuilder().name(i18n.getMessage("label.choose.type")).buildLabel(); + colorLabel = new LabelBuilder().name(i18n.getMessage("label.choose.type.color")).buildLabel(); colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE); - tagNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", null, null, false, "", - i18n.get("label.combobox.type")); + tagNameComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("label.combobox.type"), "", null, null, false, "", + i18n.getMessage("label.combobox.type")); tagNameComboBox.setId(SPUIDefinitions.NEW_DISTRIBUTION_SET_TYPE_NAME_COMBO); tagNameComboBox.addStyleName(SPUIDefinitions.FILTER_TYPE_COMBO_STYLE); tagNameComboBox.setImmediate(true); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java index 07c0c923c..03330ef7e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java @@ -18,7 +18,7 @@ import org.eclipse.hawkbit.im.authentication.MultitenancyIndicator; import org.eclipse.hawkbit.im.authentication.TenantUserPasswordAuthenticationToken; import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,7 +71,7 @@ public class LoginView extends VerticalLayout implements View { private final transient VaadinSecurity vaadinSecurity; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UiProperties uiProperties; @@ -86,7 +86,7 @@ public class LoginView extends VerticalLayout implements View { private Button signin; @Autowired - LoginView(final VaadinSecurity vaadinSecurity, final I18N i18n, final UiProperties uiProperties, + LoginView(final VaadinSecurity vaadinSecurity, final VaadinMessageSource i18n, final UiProperties uiProperties, final MultitenancyIndicator multiTenancyIndicator) { this.vaadinSecurity = vaadinSecurity; this.i18n = i18n; @@ -95,8 +95,8 @@ public class LoginView extends VerticalLayout implements View { } void loginAuthenticationFailedNotification() { - final Notification notification = new Notification(i18n.get("notification.login.failed.title")); - notification.setDescription(i18n.get("notification.login.failed.description")); + final Notification notification = new Notification(i18n.getMessage("notification.login.failed.title")); + notification.setDescription(i18n.getMessage("notification.login.failed.description")); notification.setHtmlContentAllowed(true); notification.setStyleName("error closable"); notification.setPosition(Position.BOTTOM_CENTER); @@ -106,8 +106,8 @@ public class LoginView extends VerticalLayout implements View { void loginCredentialsExpiredNotification() { final Notification notification = new Notification( - i18n.get("notification.login.failed.credentialsexpired.title")); - notification.setDescription(i18n.get("notification.login.failed.credentialsexpired.description")); + i18n.getMessage("notification.login.failed.credentialsexpired.title")); + notification.setDescription(i18n.getMessage("notification.login.failed.credentialsexpired.description")); notification.setDelayMsec(10000); notification.setHtmlContentAllowed(true); notification.setStyleName("error closeable"); @@ -225,7 +225,7 @@ public class LoginView extends VerticalLayout implements View { } private void buildSignInButton() { - signin = new Button(i18n.get("button.login.signin")); + signin = new Button(i18n.getMessage("button.login.signin")); signin.addStyleName(ValoTheme.BUTTON_PRIMARY + " " + ValoTheme.BUTTON_SMALL + " " + "login-button"); signin.setClickShortcut(KeyCode.ENTER); signin.focus(); @@ -233,7 +233,7 @@ public class LoginView extends VerticalLayout implements View { } private void buildPasswordField() { - password = new PasswordField(i18n.get("label.login.password")); + password = new PasswordField(i18n.getMessage("label.login.password")); password.setIcon(FontAwesome.LOCK); password.addStyleName( ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD); @@ -241,7 +241,7 @@ public class LoginView extends VerticalLayout implements View { } private void buildUserField() { - username = new TextField(i18n.get("label.login.username")); + username = new TextField(i18n.getMessage("label.login.username")); username.setIcon(FontAwesome.USER); username.addStyleName( ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD); @@ -250,7 +250,7 @@ public class LoginView extends VerticalLayout implements View { private void buildTenantField() { if (multiTenancyIndicator.isMultiTenancySupported()) { - tenant = new TextField(i18n.get("label.login.tenant")); + tenant = new TextField(i18n.getMessage("label.login.tenant")); tenant.setIcon(FontAwesome.DATABASE); tenant.addStyleName( ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD); @@ -268,7 +268,7 @@ public class LoginView extends VerticalLayout implements View { if (!uiProperties.getLinks().getDocumentation().getRoot().isEmpty()) { final Link docuLink = SPUIComponentProvider.getLink(UIComponentIdProvider.LINK_DOCUMENTATION, - i18n.get("link.documentation.name"), uiProperties.getLinks().getDocumentation().getRoot(), + i18n.getMessage("link.documentation.name"), uiProperties.getLinks().getDocumentation().getRoot(), FontAwesome.QUESTION_CIRCLE, "_blank", linkStyle); links.addComponent(docuLink); docuLink.addStyleName(ValoTheme.LINK_SMALL); @@ -276,14 +276,14 @@ public class LoginView extends VerticalLayout implements View { if (!uiProperties.getDemo().getUser().isEmpty()) { final Link demoLink = SPUIComponentProvider.getLink(UIComponentIdProvider.LINK_DEMO, - i18n.get("link.demo.name"), "?demo", FontAwesome.DESKTOP, "_top", linkStyle); + i18n.getMessage("link.demo.name"), "?demo", FontAwesome.DESKTOP, "_top", linkStyle); links.addComponent(demoLink); demoLink.addStyleName(ValoTheme.LINK_SMALL); } if (!uiProperties.getLinks().getRequestAccount().isEmpty()) { final Link requestAccountLink = SPUIComponentProvider.getLink(UIComponentIdProvider.LINK_REQUESTACCOUNT, - i18n.get("link.requestaccount.name"), uiProperties.getLinks().getRequestAccount(), + i18n.getMessage("link.requestaccount.name"), uiProperties.getLinks().getRequestAccount(), FontAwesome.SHOPPING_CART, "", linkStyle); links.addComponent(requestAccountLink); requestAccountLink.addStyleName(ValoTheme.LINK_SMALL); @@ -291,7 +291,7 @@ public class LoginView extends VerticalLayout implements View { if (!uiProperties.getLinks().getUserManagement().isEmpty()) { final Link userManagementLink = SPUIComponentProvider.getLink(UIComponentIdProvider.LINK_USERMANAGEMENT, - i18n.get("link.usermanagement.name"), uiProperties.getLinks().getUserManagement(), + i18n.getMessage("link.usermanagement.name"), uiProperties.getLinks().getUserManagement(), FontAwesome.USERS, "_blank", linkStyle); links.addComponent(userManagementLink); userManagementLink.addStyleName(ValoTheme.LINK_SMALL); @@ -301,7 +301,7 @@ public class LoginView extends VerticalLayout implements View { } private Component buildUnsupportedMessage() { - final Label label = new Label(i18n.get("label.unsupported.browser.ie")); + final Label label = new Label(i18n.getMessage("label.unsupported.browser.ie")); label.addStyleName(ValoTheme.LABEL_FAILURE); return label; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java index d2d865419..fa8964eed 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java @@ -52,7 +52,7 @@ import org.eclipse.hawkbit.ui.push.TargetDeletedEventContainer; import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer; import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer; import org.eclipse.hawkbit.ui.push.TargetTagUpdatedEventContainer; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; @@ -83,7 +83,7 @@ public class DeploymentView extends AbstractNotificationView implements BrowserW private final SpPermissionChecker permChecker; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UINotification uiNotification; @@ -106,7 +106,7 @@ public class DeploymentView extends AbstractNotificationView implements BrowserW private final DeploymentViewMenuItem deploymentViewMenuItem; @Autowired - DeploymentView(final UIEventBus eventbus, final SpPermissionChecker permChecker, final I18N i18n, + DeploymentView(final UIEventBus eventbus, final SpPermissionChecker permChecker, final VaadinMessageSource i18n, final UINotification uiNotification, final ManagementUIState managementUIState, final DeploymentManagement deploymentManagement, final UIEventBus eventBus, final DistributionTableFilters distFilterParameters, @@ -347,7 +347,7 @@ public class DeploymentView extends AbstractNotificationView implements BrowserW private void checkNoDataAvaialble() { if (managementUIState.isNoDataAvilableTarget() && managementUIState.isNoDataAvailableDistribution()) { - uiNotification.displayValidationError(i18n.get("message.no.data")); + uiNotification.displayValidationError(i18n.getMessage("message.no.data")); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryComponent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryComponent.java index 2f2bb9762..2205f3eca 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryComponent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryComponent.java @@ -13,7 +13,7 @@ import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -34,7 +34,7 @@ public class ActionHistoryComponent extends VerticalLayout { private final ActionHistoryHeader actionHistoryHeader; private final ActionHistoryTable actionHistoryTable; - public ActionHistoryComponent(final I18N i18n, final DeploymentManagement deploymentManagement, + public ActionHistoryComponent(final VaadinMessageSource i18n, final DeploymentManagement deploymentManagement, final UIEventBus eventBus, final UINotification notification, final ManagementUIState managementUIState) { this.actionHistoryHeader = new ActionHistoryHeader(eventBus, managementUIState); this.actionHistoryTable = new ActionHistoryTable(i18n, deploymentManagement, eventBus, notification, 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 2b993dd69..2f0d99878 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 @@ -31,7 +31,7 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -75,7 +75,7 @@ public class ActionHistoryTable extends TreeTable { private static final String BUTTON_CANCEL = "button.cancel"; private static final String BUTTON_OK = "button.ok"; - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient DeploymentManagement deploymentManagement; private final transient EventBus.UIEventBus eventBus; private final UINotification notification; @@ -86,7 +86,7 @@ public class ActionHistoryTable extends TreeTable { private Target target; - ActionHistoryTable(final I18N i18n, final DeploymentManagement deploymentManagement, final UIEventBus eventBus, + ActionHistoryTable(final VaadinMessageSource i18n, final DeploymentManagement deploymentManagement, final UIEventBus eventBus, final UINotification notification, final ManagementUIState managementUIState) { this.i18n = i18n; this.deploymentManagement = deploymentManagement; @@ -388,20 +388,20 @@ public class ActionHistoryTable extends TreeTable { final boolean isActionActive = target != null && SPUIDefinitions.ACTIVE.equals(activeValue); final Button actionCancel = SPUIComponentProvider.getButton( - UIComponentIdProvider.ACTION_HISTORY_TABLE_CANCEL_ID, "", i18n.get("message.cancel.action"), + UIComponentIdProvider.ACTION_HISTORY_TABLE_CANCEL_ID, "", i18n.getMessage("message.cancel.action"), ValoTheme.BUTTON_TINY, true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); actionCancel.setEnabled(isActionActive && !actionWithActiveStatus.isCancelingOrCanceled()); actionCancel.addClickListener(event -> confirmAndCancelAction(actionId)); final Button actionForce = SPUIComponentProvider.getButton(UIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_ID, - "", i18n.get("message.force.action"), ValoTheme.BUTTON_TINY, true, FontAwesome.BOLT, + "", i18n.getMessage("message.force.action"), ValoTheme.BUTTON_TINY, true, FontAwesome.BOLT, SPUIButtonStyleSmallNoBorder.class); actionForce.setEnabled( isActionActive && !actionWithActiveStatus.isForce() && !actionWithActiveStatus.isCancelingOrCanceled()); actionForce.addClickListener(event -> confirmAndForceAction(actionId)); final Button actionForceQuit = SPUIComponentProvider.getButton( - UIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_QUIT_ID, "", i18n.get("message.forcequit.action"), + UIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_QUIT_ID, "", i18n.getMessage("message.forcequit.action"), ValoTheme.BUTTON_TINY + " redicon", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); actionForceQuit.setEnabled(isActionActive && actionWithActiveStatus.isCancelingOrCanceled()); actionForceQuit.addClickListener(event -> confirmAndForceQuitAction(actionId)); @@ -520,7 +520,7 @@ public class ActionHistoryTable extends TreeTable { return label; } - label.setDescription(i18n.get(mapping.getDescriptionI18N())); + label.setDescription(i18n.getMessage(mapping.getDescriptionI18N())); label.setStyleName(mapping.getStyleName()); label.setValue(mapping.getIcon().getHtml()); return label; @@ -653,7 +653,7 @@ public class ActionHistoryTable extends TreeTable { } } else { /* Messages are not available */ - updateStatusMessages.append(i18n.get("message.no.available")); + updateStatusMessages.append(i18n.getMessage("message.no.available")); } textArea.setValue(updateStatusMessages.toString()); textArea.setReadOnly(Boolean.TRUE); @@ -696,14 +696,14 @@ public class ActionHistoryTable extends TreeTable { */ private void confirmAndForceAction(final Long actionId) { /* Display the confirmation */ - final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.force.action.confirmbox"), - i18n.get("message.force.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> { + final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.getMessage("caption.force.action.confirmbox"), + i18n.getMessage("message.force.action.confirm"), i18n.getMessage(BUTTON_OK), i18n.getMessage(BUTTON_CANCEL), ok -> { if (!ok) { return; } deploymentManagement.forceTargetAction(actionId); populateAndupdateTargetDetails(target); - notification.displaySuccess(i18n.get("message.force.action.success")); + notification.displaySuccess(i18n.getMessage("message.force.action.success")); }); UI.getCurrent().addWindow(confirmDialog.getWindow()); @@ -712,17 +712,17 @@ public class ActionHistoryTable extends TreeTable { private void confirmAndForceQuitAction(final Long actionId) { /* Display the confirmation */ - final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.forcequit.action.confirmbox"), - i18n.get("message.forcequit.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> { + final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.getMessage("caption.forcequit.action.confirmbox"), + i18n.getMessage("message.forcequit.action.confirm"), i18n.getMessage(BUTTON_OK), i18n.getMessage(BUTTON_CANCEL), ok -> { if (!ok) { return; } final boolean cancelResult = forceQuitActiveAction(actionId); if (cancelResult) { populateAndupdateTargetDetails(target); - notification.displaySuccess(i18n.get("message.forcequit.action.success")); + notification.displaySuccess(i18n.getMessage("message.forcequit.action.success")); } else { - notification.displayValidationError(i18n.get("message.forcequit.action.failed")); + notification.displayValidationError(i18n.getMessage("message.forcequit.action.failed")); } }, FontAwesome.WARNING); UI.getCurrent().addWindow(confirmDialog.getWindow()); @@ -741,17 +741,17 @@ public class ActionHistoryTable extends TreeTable { return; } - final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.cancel.action.confirmbox"), - i18n.get("message.cancel.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> { + final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.getMessage("caption.cancel.action.confirmbox"), + i18n.getMessage("message.cancel.action.confirm"), i18n.getMessage(BUTTON_OK), i18n.getMessage(BUTTON_CANCEL), ok -> { if (!ok) { return; } final boolean cancelResult = cancelActiveAction(actionId); if (cancelResult) { populateAndupdateTargetDetails(target); - notification.displaySuccess(i18n.get("message.cancel.action.success")); + notification.displaySuccess(i18n.getMessage("message.cancel.action.success")); } else { - notification.displayValidationError(i18n.get("message.cancel.action.failed")); + notification.displayValidationError(i18n.getMessage("message.cancel.action.failed")); } }); UI.getCurrent().addWindow(confirmDialog.getWindow()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index 0d2b9a644..25b5b2e9c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -30,7 +30,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTable; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -58,7 +58,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent { private static final long serialVersionUID = -5602182034230568435L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UINotification notificationMessage; private final transient EventBus.UIEventBus eventBus; private final transient DistributionSetManagement distributionSetManagement; @@ -95,7 +95,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent { * @param distributionSetTable * DistributionSetTable */ - public DistributionAddUpdateWindowLayout(final I18N i18n, final UINotification notificationMessage, + public DistributionAddUpdateWindowLayout(final VaadinMessageSource i18n, final UINotification notificationMessage, final UIEventBus eventBus, final DistributionSetManagement distributionSetManagement, final SystemManagement systemManagement, final EntityFactory entityFactory, final DistributionSetTable distributionSetTable) { @@ -142,7 +142,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent { entityFactory.distributionSet().update(editDistId).name(distNameTextField.getValue()) .description(descTextArea.getValue()).version(distVersionTextField.getValue()) .requiredMigrationStep(isMigStepReq).type(type)); - notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success", + notificationMessage.displaySuccess(i18n.getMessage("message.new.dist.save.success", new Object[] { currentDS.getName(), currentDS.getVersion() })); // update table row+details layout eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.UPDATED_ENTITY, currentDS)); @@ -170,7 +170,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent { eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.ADD_ENTITY, newDist)); - notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success", + notificationMessage.displaySuccess(i18n.getMessage("message.new.dist.save.success", new Object[] { newDist.getName(), newDist.getVersion() })); distributionSetTable.setValue(Sets.newHashSet(newDist.getId())); @@ -192,7 +192,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent { if (existingDs.isPresent() && !existingDs.get().getId().equals(editDistId)) { distNameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT); distVersionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT); - notificationMessage.displayValidationError(i18n.get("message.duplicate.dist", + notificationMessage.displayValidationError(i18n.getMessage("message.duplicate.dist", new Object[] { existingDs.get().getName(), existingDs.get().getVersion() })); return true; @@ -226,26 +226,26 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent { distNameTextField = createTextField("textfield.name", UIComponentIdProvider.DIST_ADD_NAME); distVersionTextField = createTextField("textfield.version", UIComponentIdProvider.DIST_ADD_VERSION); - distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", null, "", - false, "", i18n.get("label.combobox.type")); + distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("label.combobox.type"), "", null, "", + false, "", i18n.getMessage("label.combobox.type")); distsetTypeNameComboBox.setImmediate(true); distsetTypeNameComboBox.setNullSelectionAllowed(false); distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE); - descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style") - .prompt(i18n.get("textfield.description")).immediate(true).id(UIComponentIdProvider.DIST_ADD_DESC) + descTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")).style("text-area-style") + .prompt(i18n.getMessage("textfield.description")).immediate(true).id(UIComponentIdProvider.DIST_ADD_DESC) .buildTextComponent(); descTextArea.setNullRepresentation(StringUtils.EMPTY); - reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.get("checkbox.dist.required.migration.step"), + reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.getMessage("checkbox.dist.required.migration.step"), "dist-checkbox-style", null, false, ""); reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL); reqMigStepCheckbox.setId(UIComponentIdProvider.DIST_ADD_MIGRATION_CHECK); } private TextField createTextField(final String in18Key, final String id) { - final TextField buildTextField = new TextFieldBuilder().caption(i18n.get(in18Key)).required(true) - .prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent(); + final TextField buildTextField = new TextFieldBuilder().caption(i18n.getMessage(in18Key)).required(true) + .prompt(i18n.getMessage(in18Key)).immediate(true).id(id).buildTextComponent(); buildTextField.setNullRepresentation(StringUtils.EMPTY); return buildTextField; } @@ -323,7 +323,7 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent { populateDistSetTypeNameCombo(); populateValuesOfDistribution(editDistId); return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW) - .caption(i18n.get(UIComponentIdProvider.DIST_ADD_CAPTION)).content(this).layout(formLayout).i18n(i18n) + .caption(i18n.getMessage(UIComponentIdProvider.DIST_ADD_CAPTION)).content(this).layout(formLayout).i18n(i18n) .saveDialogCloseListener(new SaveOnCloseDialogListener()).buildCommonDialogWindow(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java index 240522d57..d5a9c935c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java @@ -23,7 +23,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -55,7 +55,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail private final UINotification notificationMessage; - DistributionDetails(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, + DistributionDetails(final VaadinMessageSource i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState, final DistributionSetManagement distributionSetManagement, final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory, final UINotification notificationMessage, final TagManagement tagManagement, @@ -86,23 +86,23 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail @Override protected String getDefaultCaption() { - return getI18n().get("distribution.details.header"); + return getI18n().getMessage("distribution.details.header"); } @Override protected void addTabs(final TabSheet detailsTab) { - detailsTab.addTab(createDetailsLayout(), getI18n().get("caption.tab.details"), null); - detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null); - detailsTab.addTab(createSoftwareModuleTab(), getI18n().get("caption.softwares.distdetail.tab"), null); - detailsTab.addTab(createTagsLayout(), getI18n().get("caption.tags.tab"), null); - detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null); - detailsTab.addTab(dsMetadataTable, getI18n().get("caption.metadata"), null); + detailsTab.addTab(createDetailsLayout(), getI18n().getMessage("caption.tab.details"), null); + detailsTab.addTab(createDescriptionLayout(), getI18n().getMessage("caption.tab.description"), null); + detailsTab.addTab(createSoftwareModuleTab(), getI18n().getMessage("caption.softwares.distdetail.tab"), null); + detailsTab.addTab(createTagsLayout(), getI18n().getMessage("caption.tags.tab"), null); + detailsTab.addTab(createLogLayout(), getI18n().getMessage("caption.logs.tab"), null); + detailsTab.addTab(dsMetadataTable, getI18n().getMessage("caption.metadata"), null); } @Override protected void onEdit(final ClickEvent event) { final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow(getSelectedBaseEntityId()); - newDistWindow.setCaption(getI18n().get(UIComponentIdProvider.DIST_UPDATE_CAPTION)); + newDistWindow.setCaption(getI18n().getMessage(UIComponentIdProvider.DIST_UPDATE_CAPTION)); UI.getCurrent().addWindow(newDistWindow); newDistWindow.setVisible(Boolean.TRUE); } @@ -159,7 +159,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail detailsTabLayout.removeAllComponents(); if (type != null) { - final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"), + final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.type"), type); typeLabel.setId(UIComponentIdProvider.DETAILS_TYPE_LABEL_ID); detailsTabLayout.addComponent(typeLabel); @@ -167,8 +167,8 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail if (isMigrationRequired != null) { detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel( - getI18n().get("checkbox.dist.migration.required"), - isMigrationRequired.equals(Boolean.TRUE) ? getI18n().get("label.yes") : getI18n().get("label.no"))); + getI18n().getMessage("checkbox.dist.migration.required"), + isMigrationRequired.equals(Boolean.TRUE) ? getI18n().getMessage("label.yes") : getI18n().getMessage("label.no"))); } } @@ -200,7 +200,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail final Optional ds = distributionSetManagement .findDistributionSetById(getSelectedBaseEntityId()); if (!ds.isPresent()) { - notificationMessage.displayWarning(getI18n().get("distributionset.not.exists")); + notificationMessage.displayWarning(getI18n().getMessage("distributionset.not.exists")); return; } UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds.get(), null)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java index 625f8b931..43dbd0426 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -42,7 +42,7 @@ import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.targettable.TargetTable; import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -87,7 +87,7 @@ public class DistributionTable extends AbstractNamedVersionTable findDistributionSetById = distributionSetManagement .findDistributionSetById(distId); if (!findDistributionSetById.isPresent()) { - notification.displayWarning(i18n.get("distributionset.not.exists")); + notification.displayWarning(i18n.getMessage("distributionset.not.exists")); return; } @@ -461,7 +461,7 @@ public class DistributionTable extends AbstractNamedVersionTable ds = distributionSetManagement.findDistributionSetById((Long) itemId); if (!ds.isPresent()) { - notification.displayWarning(i18n.get("distributionset.not.exists")); + notification.displayWarning(i18n.getMessage("distributionset.not.exists")); return; } UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds.get(), null)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java index 3e8053fc5..0c232130b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java @@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventScope; @@ -31,7 +31,7 @@ import com.vaadin.ui.Button.ClickEvent; public class DistributionTableHeader extends AbstractTableHeader { private static final long serialVersionUID = 7597766804650170127L; - DistributionTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus, + DistributionTableHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus, final ManagementUIState managementUIState) { super(i18n, permChecker, eventbus, managementUIState, null, null); } @@ -47,7 +47,7 @@ public class DistributionTableHeader extends AbstractTableHeader { @Override protected String getHeaderCaption() { - return i18n.get("header.dist.table"); + return i18n.getMessage("header.dist.table"); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java index cf9c357b3..45ca95ee3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java @@ -18,7 +18,7 @@ import org.eclipse.hawkbit.ui.common.table.AbstractTableLayout; import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -29,7 +29,7 @@ public class DistributionTableLayout extends AbstractTableLayout SPUIDefinitions.MAX_TABLE_ENTRIES) { message.append(HawkbitCommonUtil.SP_STRING_PIPE); - message.append(i18n.get("label.filter.shown")); + message.append(i18n.getMessage("label.filter.shown")); message.append(SPUIDefinitions.MAX_TABLE_ENTRIES); } @@ -172,14 +172,14 @@ public class CountMessageLabel extends Label { if (managementUIState.getTargetsTruncated() != null) { // set the icon setIcon(FontAwesome.INFO_CIRCLE); - setDescription(i18n.get("label.target.filter.truncated", managementUIState.getTargetsTruncated(), + setDescription(i18n.getMessage("label.target.filter.truncated", managementUIState.getTargetsTruncated(), SPUIDefinitions.MAX_TABLE_ENTRIES)); } else { setIcon(null); setDescription(null); } - final StringBuilder message = new StringBuilder(i18n.get("label.target.filter.count")); + final StringBuilder message = new StringBuilder(i18n.getMessage("label.target.filter.count")); message.append(managementUIState.getTargetsCountAll()); return message; @@ -194,11 +194,11 @@ public class CountMessageLabel extends Label { private void displayCountLabel(final Long distId) { final Long targetsWithAssigedDsCount = targetManagement.countTargetByAssignedDistributionSet(distId); final Long targetsWithInstalledDsCount = targetManagement.countTargetByInstalledDistributionSet(distId); - final StringBuilder message = new StringBuilder(i18n.get("label.target.count")); + final StringBuilder message = new StringBuilder(i18n.getMessage("label.target.count")); message.append(""); - message.append(i18n.get("label.assigned.count", new Object[] { targetsWithAssigedDsCount })); + message.append(i18n.getMessage("label.assigned.count", new Object[] { targetsWithAssigedDsCount })); message.append(", "); - message.append(i18n.get("label.installed.count", new Object[] { targetsWithInstalledDsCount })); + message.append(i18n.getMessage("label.installed.count", new Object[] { targetsWithInstalledDsCount })); message.append(""); setValue(message.toString()); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java index 8a220bc68..a1243ae9f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java @@ -38,7 +38,7 @@ import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.targettable.TargetTable; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -77,7 +77,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { private final transient DistributionSetManagement distributionSetManagement; - public DeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus, + public DeleteActionsLayout(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus, final UINotification notification, final TagManagement tagManagementService, final ManagementViewClientCriterion managementViewClientCriterion, final ManagementUIState managementUIState, final TargetManagement targetManagement, @@ -156,7 +156,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { @Override protected String getDeleteAreaLabel() { - return i18n.get("label.components.drop.area"); + return i18n.getMessage("label.components.drop.area"); } @Override @@ -173,7 +173,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { protected void processDroppedComponent(final DragAndDropEvent event) { final Component source = event.getTransferable().getSourceComponent(); if (!DeleteActionsLayoutHelper.isComponentDeletable(source)) { - notification.displayValidationError(i18n.get("message.cannot.delete")); + notification.displayValidationError(i18n.getMessage("message.cannot.delete")); } else { processDeletion(event, source); } @@ -197,7 +197,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { private boolean tagNotInUSeInBulkUpload(final Component source) { final String tagName = HawkbitCommonUtil.removePrefix(source.getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); if (managementUIState.getTargetTableFilters().getBulkUpload().getAssignedTagNames().contains(tagName)) { - notification.displayValidationError(i18n.get("message.tag.use.bulk.upload", tagName)); + notification.displayValidationError(i18n.getMessage("message.tag.use.bulk.upload", tagName)); return false; } return true; @@ -243,7 +243,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { final String tagName = HawkbitCommonUtil.removePrefix(source.getId(), SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS); if (managementUIState.getDistributionTableFilters().getDistSetTags().contains(tagName)) { - notification.displayValidationError(i18n.get("message.tag.delete", new Object[] { tagName })); + notification.displayValidationError(i18n.getMessage("message.tag.delete", new Object[] { tagName })); } else { tagManagementService.deleteDistributionSetTag(tagName); @@ -253,14 +253,14 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { new DistributionSetTagTableEvent(BaseEntityEventType.REMOVE_ENTITY, Arrays.asList(id))); } - notification.displaySuccess(i18n.get("message.delete.success", new Object[] { tagName })); + notification.displaySuccess(i18n.getMessage("message.delete.success", new Object[] { tagName })); } } private void deleteTargetTag(final Component source) { final String tagName = HawkbitCommonUtil.removePrefix(source.getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); if (managementUIState.getTargetTableFilters().getClickedTargetTags().contains(tagName)) { - notification.displayValidationError(i18n.get("message.tag.delete", new Object[] { tagName })); + notification.displayValidationError(i18n.getMessage("message.tag.delete", new Object[] { tagName })); } else { tagManagementService.deleteTargetTag(tagName); @@ -269,7 +269,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { eventBus.publish(this, new TargetTagTableEvent(BaseEntityEventType.REMOVE_ENTITY, Arrays.asList(id))); } - notification.displaySuccess(i18n.get("message.delete.success", new Object[] { tagName })); + notification.displaySuccess(i18n.getMessage("message.delete.success", new Object[] { tagName })); } } @@ -291,7 +291,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { .findDistributionSetAllById(ids); if (findDistributionSetAllById.isEmpty()) { - notification.displayWarning(i18n.get("distributionsets.not.exists")); + notification.displayWarning(i18n.getMessage("distributionsets.not.exists")); return; } @@ -317,7 +317,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { if (newDeletedSize - existingDeletedSize == currentValues.size()) { return; } - notification.displayValidationError(i18n.get(messageKey)); + notification.displayValidationError(i18n.getMessage(messageKey)); } private void showAlreadyDeletedDistributionSetNotfication(final int existingDeletedSize, final int newDeletedSize, @@ -326,7 +326,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { if (newDeletedSize != existingDeletedSize) { return; } - notification.displayValidationError(i18n.get(messageKey)); + notification.displayValidationError(i18n.getMessage(messageKey)); } private boolean isDsInUseInBulkUpload(final Set distributionIdNameSet, final Long dsInBulkUpload) { @@ -334,10 +334,10 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { final Optional distributionSet = distributionSetManagement .findDistributionSetById(dsInBulkUpload); if (!distributionSet.isPresent()) { - notification.displayWarning(i18n.get("distributionset.not.exists")); + notification.displayWarning(i18n.getMessage("distributionset.not.exists")); return true; } - notification.displayValidationError(i18n.get("message.tag.use.bulk.upload", HawkbitCommonUtil + notification.displayValidationError(i18n.getMessage("message.tag.use.bulk.upload", HawkbitCommonUtil .getFormattedNameVersion(distributionSet.get().getName(), distributionSet.get().getVersion()))); return true; } @@ -350,7 +350,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { final Set targetIdSet = targetTable.getDeletedEntityByTransferable(transferable); final Collection findTargetAllById = targetManagement.findTargetAllById(targetIdSet); if (findTargetAllById.isEmpty()) { - notification.displayWarning(i18n.get("targets.not.exists")); + notification.displayWarning(i18n.getMessage("targets.not.exists")); return; } @@ -379,7 +379,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { private Boolean canTargetBeDeleted() { if (!permChecker.hasDeleteTargetPermission()) { - notification.displayValidationError(i18n.get("message.permission.insufficient")); + notification.displayValidationError(i18n.getMessage("message.permission.insufficient")); return false; } return true; @@ -387,7 +387,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { private Boolean canDSBeDeleted() { if (!permChecker.hasDeleteDistributionPermission()) { - notification.displayValidationError(i18n.get("message.permission.insufficient")); + notification.displayValidationError(i18n.getMessage("message.permission.insufficient")); return false; } return true; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java index d51adc2f1..969b567ac 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java @@ -36,7 +36,7 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.ActionTypeOption; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -80,7 +80,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin private ConfirmationTab assignmnetTab; - public ManangementConfirmationWindowLayout(final I18N i18n, final UIEventBus eventBus, + public ManangementConfirmationWindowLayout(final VaadinMessageSource i18n, final UIEventBus eventBus, final ManagementUIState managementUIState, final TargetManagement targetManagement, final DeploymentManagement deploymentManagement, final DistributionSetManagement distributionSetManagement) { @@ -96,13 +96,13 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin protected Map getConfimrationTabs() { final Map tabs = Maps.newHashMapWithExpectedSize(3); if (!managementUIState.getDeletedDistributionList().isEmpty()) { - tabs.put(i18n.get("caption.delete.dist.accordion.tab"), createDeletedDistributionTab()); + tabs.put(i18n.getMessage("caption.delete.dist.accordion.tab"), createDeletedDistributionTab()); } if (!managementUIState.getDeletedTargetList().isEmpty()) { - tabs.put(i18n.get("caption.delete.target.accordion.tab"), createDeletedTargetTab()); + tabs.put(i18n.getMessage("caption.delete.target.accordion.tab"), createDeletedTargetTab()); } if (!managementUIState.getAssignedList().isEmpty()) { - tabs.put(i18n.get("caption.assign.dist.accordion.tab"), createAssignmentTab()); + tabs.put(i18n.getMessage("caption.assign.dist.accordion.tab"), createAssignmentTab()); } return tabs; @@ -113,10 +113,10 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin assignmnetTab = new ConfirmationTab(); assignmnetTab.getConfirmAll().setId(UIComponentIdProvider.SAVE_ASSIGNMENT); assignmnetTab.getConfirmAll().setIcon(FontAwesome.SAVE); - assignmnetTab.getConfirmAll().setCaption(i18n.get("button.assign.all")); + assignmnetTab.getConfirmAll().setCaption(i18n.getMessage("button.assign.all")); assignmnetTab.getConfirmAll().addClickListener(event -> saveAllAssignments(assignmnetTab)); - assignmnetTab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); + assignmnetTab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); assignmnetTab.getDiscardAll().setId(UIComponentIdProvider.DISCARD_ASSIGNMENT); assignmnetTab.getDiscardAll().addClickListener(event -> discardAllAssignments(assignmnetTab)); @@ -133,8 +133,8 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin assignmnetTab.getTable().setColumnExpandRatio(DISTRIBUTION_NAME, 2); assignmnetTab.getTable().setColumnExpandRatio(DISCARD_CHANGES, 1); assignmnetTab.getTable().setVisibleColumns(TARGET_NAME, DISTRIBUTION_NAME, DISCARD_CHANGES); - assignmnetTab.getTable().setColumnHeaders(i18n.get("header.first.assignment.table"), - i18n.get("header.second.assignment.table"), i18n.get("header.third.assignment.table")); + assignmnetTab.getTable().setColumnHeaders(i18n.getMessage("header.first.assignment.table"), + i18n.getMessage("header.second.assignment.table"), i18n.getMessage("header.third.assignment.table")); assignmnetTab.getTable().setColumnAlignment(DISCARD_CHANGES, Align.CENTER); actionTypeOptionGroupLayout.selectDefaultOption(); @@ -189,7 +189,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin resfreshPinnedDetails(saveAssignedList); managementUIState.getAssignedList().clear(); - setActionMessage(i18n.get("message.target.ds.assign.success")); + setActionMessage(i18n.getMessage("message.target.ds.assign.success")); removeCurrentTab(tab); eventBus.publish(this, SaveActionWindowEvent.SAVED_ASSIGNMENTS); } @@ -220,18 +220,18 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin private String getAssigmentSuccessMessage(final int assignedCount) { return FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.target.assignment", new Object[] { assignedCount }); + + i18n.getMessage("message.target.assignment", new Object[] { assignedCount }); } private String getDuplicateAssignmentMessage(final int alreadyAssignedCount) { return FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.target.alreadyAssigned", new Object[] { alreadyAssignedCount }); + + i18n.getMessage("message.target.alreadyAssigned", new Object[] { alreadyAssignedCount }); } private void discardAllAssignments(final ConfirmationTab tab) { removeCurrentTab(tab); managementUIState.getAssignedList().clear(); - setActionMessage(i18n.get("message.assign.discard.success")); + setActionMessage(i18n.getMessage("message.assign.discard.success")); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS); } @@ -275,10 +275,10 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin // TobeDone ? y to set caption every time?? tab.getConfirmAll().setId(UIComponentIdProvider.TARGET_DELETE_ALL); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL)); + tab.getConfirmAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DELETE_ALL)); tab.getConfirmAll().addClickListener(event -> deleteAllTargets(tab)); - tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); + tab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); tab.getDiscardAll().addClickListener(event -> discardAllTargets(tab)); /* Add items container to the table. */ @@ -292,8 +292,8 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin }); tab.getTable().setVisibleColumns(TARGET_NAME, DISCARD_CHANGES); - tab.getTable().setColumnHeaders(i18n.get("header.first.deletetarget.table"), - i18n.get("header.second.deletetarget.table")); + tab.getTable().setColumnHeaders(i18n.getMessage("header.first.deletetarget.table"), + i18n.getMessage("header.second.deletetarget.table")); tab.getTable().setColumnExpandRatio(TARGET_NAME, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH); tab.getTable().setColumnExpandRatio(DISCARD_CHANGES, SPUIDefinitions.DISCARD_COLUMN_WIDTH); @@ -307,10 +307,10 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin // TobeDone ? y to set caption every time?? tab.getConfirmAll().setId(UIComponentIdProvider.DIST_DELETE_ALL); tab.getConfirmAll().setIcon(FontAwesome.TRASH_O); - tab.getConfirmAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DELETE_ALL)); + tab.getConfirmAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DELETE_ALL)); tab.getConfirmAll().addClickListener(event -> deleteAllDistributions(tab)); - tab.getDiscardAll().setCaption(i18n.get(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); + tab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL)); tab.getDiscardAll().addClickListener(event -> discardAllDistributions(tab)); /* Add items container to the table. */ @@ -326,8 +326,8 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin tab.getTable().setColumnExpandRatio(DISTRIBUTION_NAME, SPUIDefinitions.TARGET_DISTRIBUTION_COLUMN_WIDTH); tab.getTable().setColumnExpandRatio(DISCARD_CHANGES, SPUIDefinitions.DISCARD_COLUMN_WIDTH); tab.getTable().setVisibleColumns(DISTRIBUTION_NAME, DISCARD_CHANGES); - tab.getTable().setColumnHeaders(i18n.get("header.one.deletedist.table"), - i18n.get("header.second.deletedist.table")); + tab.getTable().setColumnHeaders(i18n.getMessage("header.one.deletedist.table"), + i18n.getMessage("header.second.deletedist.table")); tab.getTable().setColumnAlignment(DISCARD_CHANGES, Align.CENTER); return tab; } @@ -363,7 +363,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin private void discardAllDistributions(final ConfirmationTab tab) { removeCurrentTab(tab); managementUIState.getDeletedDistributionList().clear(); - setActionMessage(i18n.get("message.dist.discard.success")); + setActionMessage(i18n.getMessage("message.dist.discard.success")); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_DISTRIBUTIONS); } @@ -376,11 +376,11 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.REMOVE_ENTITY, deletedIds)); addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.dist.deleted", managementUIState.getDeletedDistributionList().size())); + + i18n.getMessage("message.dist.deleted", managementUIState.getDeletedDistributionList().size())); removeDeletedDistributionsFromAssignmentTab(); removeCurrentTab(tab); - setActionMessage(i18n.get("message.dist.delete.success")); + setActionMessage(i18n.getMessage("message.dist.delete.success")); managementUIState.getTargetTableFilters().getPinnedDistId() .ifPresent(distId -> unPinDeletedDS(deletedIds, distId)); @@ -455,7 +455,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin private void discardAllTargets(final ConfirmationTab tab) { removeCurrentTab(tab); - setActionMessage(i18n.get("message.target.discard.success")); + setActionMessage(i18n.getMessage("message.target.discard.success")); managementUIState.getDeletedTargetList().clear(); eventBus.publish(this, SaveActionWindowEvent.DISCARD_ALL_TARGETS); } @@ -470,9 +470,9 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.REMOVE_ENTITY, targetIds)); addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE - + i18n.get("message.target.deleted", targetIds.size())); + + i18n.getMessage("message.target.deleted", targetIds.size())); removeCurrentTab(tab); - setActionMessage(i18n.get("message.target.delete.success")); + setActionMessage(i18n.getMessage("message.target.delete.success")); removeDeletedTargetsFromAssignmentTab(); managementUIState.getDistributionTableFilters().getPinnedTarget().ifPresent(this::unPinDeletedTarget); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java index bc4563113..e9360ea86 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java @@ -41,7 +41,7 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentE import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.state.TargetBulkUpload; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,7 +85,7 @@ public class BulkUploadHandler extends CustomComponent private final ComboBox comboBox; private final TextArea descTextArea; - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient DeploymentManagement deploymentManagement; private final transient DistributionSetManagement distributionSetManagement; @@ -108,7 +108,7 @@ public class BulkUploadHandler extends CustomComponent BulkUploadHandler(final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout, final TargetManagement targetManagement, final TagManagement tagManagement, final EntityFactory entityFactory, final DistributionSetManagement distributionSetManagement, - final ManagementUIState managementUIState, final DeploymentManagement deploymentManagement, final I18N i18n, + final ManagementUIState managementUIState, final DeploymentManagement deploymentManagement, final VaadinMessageSource i18n, final UI uiInstance, final Executor uiExecutor) { this.uiInstance = uiInstance; this.comboBox = targetBulkUpdateWindowLayout.getDsNamecomboBox(); @@ -305,7 +305,7 @@ public class BulkUploadHandler extends CustomComponent final List targetsList = targetBulkUpload.getTargetsCreated(); final Long dsSelected = (Long) comboBox.getValue(); if (!distributionSetManagement.findDistributionSetById(dsSelected).isPresent()) { - return i18n.get("message.bulk.upload.assignment.failed"); + return i18n.getMessage("message.bulk.upload.assignment.failed"); } deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion(), actionType, forcedTimeStamp, targetsList); @@ -328,9 +328,9 @@ public class BulkUploadHandler extends CustomComponent return null; } if (deletedTags.size() == 1) { - return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0)); + return i18n.getMessage("message.bulk.upload.tag.assignment.failed", deletedTags.get(0)); } - return i18n.get("message.bulk.upload.tag.assignments.failed"); + return i18n.getMessage("message.bulk.upload.tag.assignments.failed"); } private boolean ifTagsSelected() { @@ -392,7 +392,7 @@ public class BulkUploadHandler extends CustomComponent if (!event.getFilename().endsWith(".csv")) { new HawkbitErrorNotificationMessage(SPUILabelDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE, null, - i18n.get("bulk.targets.upload"), true).show(Page.getCurrent()); + i18n.getMessage("bulk.targets.upload"), true).show(Page.getCurrent()); LOG.error("Wrong file format for file {}", event.getFilename()); upload.interruptUpload(); } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java index 72ef34df7..ea341b18e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java @@ -22,7 +22,7 @@ import org.eclipse.hawkbit.ui.common.builder.WindowBuilder; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -44,7 +44,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { private static final long serialVersionUID = -6659290471705262389L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient TargetManagement targetManagement; @@ -62,7 +62,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { private FormLayout formLayout; private CommonDialogWindow window; - TargetAddUpdateWindowLayout(final I18N i18n, final TargetManagement targetManagement, final UIEventBus eventBus, + TargetAddUpdateWindowLayout(final VaadinMessageSource i18n, final TargetManagement targetManagement, final UIEventBus eventBus, final UINotification uINotification, final EntityFactory entityFactory) { this.i18n = i18n; this.targetManagement = targetManagement; @@ -96,18 +96,18 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { private void createRequiredComponents() { controllerIDTextField = createTextField("prompt.target.id", UIComponentIdProvider.TARGET_ADD_CONTROLLER_ID); - controllerIDTextField.addValidator(new RegexpValidator("[.\\S]*", i18n.get("message.target.whitespace.check"))); + controllerIDTextField.addValidator(new RegexpValidator("[.\\S]*", i18n.getMessage("message.target.whitespace.check"))); nameTextField = createTextField("textfield.name", UIComponentIdProvider.TARGET_ADD_NAME); nameTextField.setRequired(false); - descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style") - .prompt(i18n.get("textfield.description")).immediate(true).id(UIComponentIdProvider.TARGET_ADD_DESC) + descTextArea = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")).style("text-area-style") + .prompt(i18n.getMessage("textfield.description")).immediate(true).id(UIComponentIdProvider.TARGET_ADD_DESC) .buildTextComponent(); descTextArea.setNullRepresentation(StringUtils.EMPTY); } private TextField createTextField(final String in18Key, final String id) { - return new TextFieldBuilder().caption(i18n.get(in18Key)).required(true).prompt(i18n.get(in18Key)) + return new TextFieldBuilder().caption(i18n.getMessage(in18Key)).required(true).prompt(i18n.getMessage(in18Key)) .immediate(true).id(id).buildTextComponent(); } @@ -129,7 +129,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { final Target target = targetManagement.updateTarget(entityFactory.target().update(controllerId) .name(nameTextField.getValue()).description(descTextArea.getValue())); /* display success msg */ - uINotification.displaySuccess(i18n.get("message.update.success", new Object[] { target.getName() })); + uINotification.displaySuccess(i18n.getMessage("message.update.success", new Object[] { target.getName() })); // publishing through event bus eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.UPDATED_ENTITY, target)); } @@ -144,12 +144,12 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.ADD_ENTITY, newTarget)); - uINotification.displaySuccess(i18n.get("message.save.success", new Object[] { newTarget.getName() })); + uINotification.displaySuccess(i18n.getMessage("message.save.success", new Object[] { newTarget.getName() })); } public Window createNewWindow() { window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW) - .caption(i18n.get(UIComponentIdProvider.TARGET_ADD_CAPTION)).content(this).layout(formLayout).i18n(i18n) + .caption(i18n.getMessage(UIComponentIdProvider.TARGET_ADD_CAPTION)).content(this).layout(formLayout).i18n(i18n) .saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow(); return window; @@ -166,7 +166,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { public Window getWindow(final String controllerId) { final Optional target = targetManagement.findTargetByControllerID(controllerId); if (!target.isPresent()) { - uINotification.displayWarning(i18n.get("target.not.exists", new Object[] { controllerId })); + uINotification.displayWarning(i18n.getMessage("target.not.exists", new Object[] { controllerId })); return null; } populateValuesOfTarget(target.get()); @@ -193,7 +193,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { final Optional existingTarget = targetManagement.findTargetByControllerID(newControlllerId.trim()); if (existingTarget.isPresent()) { uINotification.displayValidationError( - i18n.get("message.target.duplicate.check", new Object[] { newControlllerId })); + i18n.getMessage("message.target.duplicate.check", new Object[] { newControlllerId })); return true; } else { return false; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index 63bb563c1..7d95d9348 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -29,7 +29,7 @@ import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyTarget; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; @@ -58,7 +58,7 @@ public class TargetBeanQuery extends AbstractBeanQuery { private String searchText; private Boolean noTagClicked; private transient TargetManagement targetManagement; - private transient I18N i18N; + private transient VaadinMessageSource i18N; private Long pinnedDistId; private Long targetFilterQueryId; private ManagementUIState managementUIState; @@ -226,9 +226,9 @@ public class TargetBeanQuery extends AbstractBeanQuery { return managementUIState; } - private I18N getI18N() { + private VaadinMessageSource getI18N() { if (i18N == null) { - i18N = SpringContextHelper.getBean(I18N.class); + i18N = SpringContextHelper.getBean(VaadinMessageSource.class); } return i18N; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkTokenTags.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkTokenTags.java index e9b1cf75c..91388451d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkTokenTags.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkTokenTags.java @@ -15,7 +15,7 @@ import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.tagdetails.AbstractTargetTagToken; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.data.domain.PageRequest; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -29,7 +29,7 @@ public class TargetBulkTokenTags extends AbstractTargetTagToken { private static final int MAX_TAGS = 500; - TargetBulkTokenTags(final SpPermissionChecker checker, final I18N i18n, final UINotification uinotification, + TargetBulkTokenTags(final SpPermissionChecker checker, final VaadinMessageSource i18n, final UINotification uinotification, final UIEventBus eventBus, final ManagementUIState managementUIState, final TagManagement tagManagement) { super(checker, i18n, uinotification, eventBus, managementUIState, tagManagement); } @@ -52,7 +52,7 @@ public class TargetBulkTokenTags extends AbstractTargetTagToken { @Override protected String getTokenInputPrompt() { - return i18n.get("combo.type.tag.name"); + return i18n.getMessage("combo.type.tag.name"); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java index c554abfcd..a0c2510ab 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java @@ -27,7 +27,7 @@ import org.eclipse.hawkbit.ui.management.dstable.DistributionBeanQuery; import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.state.TargetBulkUpload; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -62,7 +62,7 @@ import com.vaadin.ui.themes.ValoTheme; * Bulk target upload layout. */ public class TargetBulkUpdateWindowLayout extends CustomComponent { - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient TargetManagement targetManagement; private final transient DistributionSetManagement distributionSetManagement; @@ -96,7 +96,7 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent { private Button minimizeButton; private Button closeButton; - TargetBulkUpdateWindowLayout(final I18N i18n, final TargetManagement targetManagement, final UIEventBus eventBus, + TargetBulkUpdateWindowLayout(final VaadinMessageSource i18n, final TargetManagement targetManagement, final UIEventBus eventBus, final ManagementUIState managementUIState, final DeploymentManagement deploymentManagement, final UiProperties uiproperties, final SpPermissionChecker checker, final UINotification uinotification, final TagManagement tagManagement, final DistributionSetManagement distributionSetManagement, @@ -145,7 +145,7 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent { bulkUploader = getBulkUploadHandler(); linkToSystemConfigHelp = SPUIComponentProvider .getHelpLink(uiproperties.getLinks().getDocumentation().getDeploymentView()); - windowCaption = new Label(i18n.get("caption.bulk.upload.targets")); + windowCaption = new Label(i18n.getMessage("caption.bulk.upload.targets")); minimizeButton = getMinimizeButton(); closeButton = getCloseButton(); } @@ -194,8 +194,8 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent { } private TextArea getDescriptionTextArea() { - final TextArea description = new TextAreaBuilder().caption(i18n.get("textfield.description")) - .style("text-area-style").prompt(i18n.get("textfield.description")).immediate(true) + final TextArea description = new TextAreaBuilder().caption(i18n.getMessage("textfield.description")) + .style("text-area-style").prompt(i18n.getMessage("textfield.description")).immediate(true) .id(UIComponentIdProvider.BULK_UPLOAD_DESC).buildTextComponent(); description.setNullRepresentation(StringUtils.EMPTY); description.setWidth("100%"); @@ -204,8 +204,8 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent { private ComboBox getDsComboField() { final Container container = createContainer(); - final ComboBox dsComboBox = SPUIComponentProvider.getComboBox(i18n.get("bulkupload.ds.name"), "", null, null, - false, "", i18n.get("bulkupload.ds.name")); + final ComboBox dsComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("bulkupload.ds.name"), "", null, null, + false, "", i18n.getMessage("bulkupload.ds.name")); dsComboBox.setSizeUndefined(); dsComboBox.addStyleName(SPUIDefinitions.BULK_UPLOD_DS_COMBO_STYLE); dsComboBox.setImmediate(true); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java index 43177e77e..866f4a436 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java @@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -59,7 +59,7 @@ public class TargetDetails extends AbstractTableDetailsLayout { private VerticalLayout assignedDistLayout; private VerticalLayout installedDistLayout; - TargetDetails(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, + TargetDetails(final VaadinMessageSource i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState, final UINotification uiNotification, final TagManagement tagManagement, final TargetManagement targetManagement, final EntityFactory entityFactory) { @@ -74,18 +74,18 @@ public class TargetDetails extends AbstractTableDetailsLayout { @Override protected String getDefaultCaption() { - return getI18n().get("target.details.header"); + return getI18n().getMessage("target.details.header"); } @Override protected void addTabs(final TabSheet detailsTab) { - detailsTab.addTab(createDetailsLayout(), getI18n().get("caption.tab.details"), null); - detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null); - detailsTab.addTab(createAttributesLayout(), getI18n().get("caption.attributes.tab"), null); - detailsTab.addTab(createAssignedDistLayout(), getI18n().get("header.target.assigned"), null); - detailsTab.addTab(createInstalledDistLayout(), getI18n().get("header.target.installed"), null); - detailsTab.addTab(createTagsLayout(), getI18n().get("caption.tags.tab"), null); - detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null); + detailsTab.addTab(createDetailsLayout(), getI18n().getMessage("caption.tab.details"), null); + detailsTab.addTab(createDescriptionLayout(), getI18n().getMessage("caption.tab.description"), null); + detailsTab.addTab(createAttributesLayout(), getI18n().getMessage("caption.attributes.tab"), null); + detailsTab.addTab(createAssignedDistLayout(), getI18n().getMessage("header.target.assigned"), null); + detailsTab.addTab(createInstalledDistLayout(), getI18n().getMessage("header.target.installed"), null); + detailsTab.addTab(createTagsLayout(), getI18n().getMessage("caption.tags.tab"), null); + detailsTab.addTab(createLogLayout(), getI18n().getMessage("caption.logs.tab"), null); } @@ -118,7 +118,7 @@ public class TargetDetails extends AbstractTableDetailsLayout { if (targetWindow == null) { return; } - targetWindow.setCaption(getI18n().get(UIComponentIdProvider.TARGET_UPDATE_CAPTION)); + targetWindow.setCaption(getI18n().getMessage(UIComponentIdProvider.TARGET_UPDATE_CAPTION)); UI.getCurrent().addWindow(targetWindow); targetWindow.setVisible(Boolean.TRUE); } @@ -165,18 +165,18 @@ public class TargetDetails extends AbstractTableDetailsLayout { final VerticalLayout detailsTabLayout = getDetailsLayout(); detailsTabLayout.removeAllComponents(); - final Label controllerLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.target.id"), + final Label controllerLabel = SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.target.id"), HawkbitCommonUtil.trimAndNullIfEmpty(controllerId) == null ? "" : controllerId); controllerLabel.setId(UIComponentIdProvider.TARGET_CONTROLLER_ID); detailsTabLayout.addComponent(controllerLabel); final Label lastPollDtLabel = SPUIComponentProvider.createNameValueLabel( - getI18n().get("label.target.lastpolldate"), + getI18n().getMessage("label.target.lastpolldate"), HawkbitCommonUtil.trimAndNullIfEmpty(lastQueryDate) == null ? "" : lastQueryDate); lastPollDtLabel.setId(UIComponentIdProvider.TARGET_LAST_QUERY_DT); detailsTabLayout.addComponent(lastPollDtLabel); - final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.ip"), + final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.ip"), address == null ? StringUtils.EMPTY : address.toString()); typeLabel.setId(UIComponentIdProvider.TARGET_IP_ADDRESS); detailsTabLayout.addComponent(typeLabel); @@ -192,7 +192,7 @@ public class TargetDetails extends AbstractTableDetailsLayout { final HorizontalLayout securityTokenLayout = new HorizontalLayout(); final Label securityTableLbl = new Label( - SPUIComponentProvider.getBoldHTMLText(getI18n().get("label.target.security.token")), ContentMode.HTML); + SPUIComponentProvider.getBoldHTMLText(getI18n().getMessage("label.target.security.token")), ContentMode.HTML); securityTableLbl.addStyleName(SPUIDefinitions.TEXT_STYLE); securityTableLbl.addStyleName("label-style"); @@ -215,10 +215,10 @@ public class TargetDetails extends AbstractTableDetailsLayout { if (distributionSet == null) { return; } - layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.name"), + layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.name"), distributionSet.getName())); - layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.version"), + layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.version"), distributionSet.getVersion())); distributionSet.getModules() diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 579ae1f9a..3906cce8a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -61,7 +61,7 @@ import org.eclipse.hawkbit.ui.push.CancelTargetAssignmentEventContainer; import org.eclipse.hawkbit.ui.push.TargetUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; @@ -119,7 +119,7 @@ public class TargetTable extends AbstractTable { private Button targetPinnedBtn; private boolean isTargetPinned; - public TargetTable(final UIEventBus eventBus, final I18N i18n, final UINotification notification, + public TargetTable(final UIEventBus eventBus, final VaadinMessageSource i18n, final UINotification notification, final TargetManagement targetManagement, final ManagementUIState managementUIState, final SpPermissionChecker permChecker, final ManagementViewClientCriterion managementViewClientCriterion, final DistributionSetManagement distributionSetManagement, final TagManagement tagManagement) { @@ -499,7 +499,7 @@ public class TargetTable extends AbstractTable { .toString(); if (tagName.equals(SPUIDefinitions.TARGET_TAG_BUTTON)) { notification.displayValidationError( - i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") })); + i18n.getMessage("message.tag.cannot.be.assigned", new Object[] { i18n.getMessage("label.no.tag.assigned") })); return false; } return true; @@ -511,7 +511,7 @@ public class TargetTable extends AbstractTable { final String targTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); if (targetList.isEmpty()) { - final String actionDidNotWork = i18n.get("message.action.did.not.work"); + final String actionDidNotWork = i18n.getMessage("message.action.did.not.work"); notification.displayValidationError(actionDidNotWork); return; } @@ -540,14 +540,14 @@ public class TargetTable extends AbstractTable { final List controllerIds = targetManagement.findTargetAllById(targetIds).stream() .map(Target::getControllerId).collect(Collectors.toList()); if (controllerIds.isEmpty()) { - notification.displayWarning(i18n.get("targets.not.exists")); + notification.displayWarning(i18n.getMessage("targets.not.exists")); return new TargetTagAssignmentResult(0, 0, 0, Lists.newArrayListWithCapacity(0), Lists.newArrayListWithCapacity(0), null); } final Optional tag = tagManagement.findTargetTag(targTagName); if (!tag.isPresent()) { - notification.displayWarning(i18n.get("targettag.not.exists", new Object[] { targTagName })); + notification.displayWarning(i18n.getMessage("targettag.not.exists", new Object[] { targTagName })); return new TargetTagAssignmentResult(0, 0, 0, Lists.newArrayListWithCapacity(0), Lists.newArrayListWithCapacity(0), null); } @@ -565,11 +565,11 @@ public class TargetTable extends AbstractTable { SPUIDefinitions.TARGET_TAG_ID_PREFIXS); if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) { if ("NO TAG".equals(tagName)) { - notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG)); + notification.displayValidationError(i18n.getMessage(ACTION_NOT_ALLOWED_MSG)); return false; } } else { - notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG)); + notification.displayValidationError(i18n.getMessage(ACTION_NOT_ALLOWED_MSG)); return false; } @@ -595,13 +595,13 @@ public class TargetTable extends AbstractTable { final Object targetItemId = dropData.getItemIdOver(); LOG.debug("Adding a log to check if targetItemId is null : {} ", targetItemId); if (targetItemId == null) { - getNotification().displayWarning(i18n.get("target.not.exists", new Object[] { "" })); + getNotification().displayWarning(i18n.getMessage("target.not.exists", new Object[] { "" })); return; } final Long targetId = (Long) targetItemId; final Optional target = targetManagement.findTargetById(targetId); if (!target.isPresent()) { - getNotification().displayWarning(i18n.get("target.not.exists", new Object[] { "" })); + getNotification().displayWarning(i18n.getMessage("target.not.exists", new Object[] { "" })); return; } final TargetIdName createTargetIdName = new TargetIdName(target.get()); @@ -610,7 +610,7 @@ public class TargetTable extends AbstractTable { .findDistributionSetAllById(ids); if (findDistributionSetAllById.isEmpty()) { - notification.displayWarning(i18n.get("distributionsets.not.exists")); + notification.displayWarning(i18n.getMessage("distributionsets.not.exists")); return; } @@ -667,9 +667,9 @@ public class TargetTable extends AbstractTable { */ private String getPendingActionMessage(final String message, final String distName, final String controllerId) { if (message == null) { - return i18n.get("message.dist.pending.action", new Object[] { controllerId, distName }); + return i18n.getMessage("message.dist.pending.action", new Object[] { controllerId, distName }); } - return i18n.get("message.target.assigned.pending"); + return i18n.getMessage("message.target.assigned.pending"); } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java index c45183034..c28a034e7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java @@ -35,7 +35,7 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUITargetDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -77,7 +77,7 @@ public class TargetTableHeader extends AbstractTableHeader { private final transient DistributionSetManagement distributionSetManagement; - TargetTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus, + TargetTableHeader(final VaadinMessageSource i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus, final UINotification notification, final ManagementUIState managementUIState, final ManagementViewClientCriterion managementViewClientCriterion, final TargetManagement targetManagement, final DeploymentManagement deploymentManagement, final UiProperties uiproperties, final UIEventBus eventBus, @@ -166,7 +166,7 @@ public class TargetTableHeader extends AbstractTableHeader { @Override protected String getHeaderCaption() { - return i18n.get("header.target.table"); + return i18n.getMessage("header.target.table"); } @Override @@ -280,7 +280,7 @@ public class TargetTableHeader extends AbstractTableHeader { protected void addNewItem(final ClickEvent event) { targetAddUpdateWindow.resetComponents(); final Window addTargetWindow = targetAddUpdateWindow.createNewWindow(); - addTargetWindow.setCaption(i18n.get(UIComponentIdProvider.TARGET_ADD_CAPTION)); + addTargetWindow.setCaption(i18n.getMessage(UIComponentIdProvider.TARGET_ADD_CAPTION)); UI.getCurrent().addWindow(addTargetWindow); addTargetWindow.setVisible(Boolean.TRUE); } @@ -343,7 +343,7 @@ public class TargetTableHeader extends AbstractTableHeader { final Optional distributionSet = distributionSetManagement .findDistributionSetById(distributionSetId); if (!distributionSet.isPresent()) { - notification.displayWarning(i18n.get("distributionset.not.exists")); + notification.displayWarning(i18n.getMessage("distributionset.not.exists")); return; } final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distributionSet.get()); @@ -366,16 +366,16 @@ public class TargetTableHeader extends AbstractTableHeader { final Table source = transferable.getSourceComponent(); if (!source.getId().equals(UIComponentIdProvider.DIST_TABLE_ID)) { - notification.displayValidationError(i18n.get("message.action.not.allowed")); + notification.displayValidationError(i18n.getMessage("message.action.not.allowed")); isValid = Boolean.FALSE; } else { if (getDropppedDistributionDetails(transferable).size() > 1) { - notification.displayValidationError(i18n.get("message.onlyone.distribution.dropallowed")); + notification.displayValidationError(i18n.getMessage("message.onlyone.distribution.dropallowed")); isValid = Boolean.FALSE; } } } else { - notification.displayValidationError(i18n.get("message.action.not.allowed")); + notification.displayValidationError(i18n.getMessage("message.action.not.allowed")); isValid = Boolean.FALSE; } return isValid; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java index fee6a755e..6f522b7f1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java @@ -22,7 +22,7 @@ import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -41,7 +41,7 @@ public class TargetTableLayout extends AbstractTableLayout { private final TargetTableHeader targetTableHeader; public TargetTableLayout(final UIEventBus eventBus, final TargetTable targetTable, - final TargetManagement targetManagement, final EntityFactory entityFactory, final I18N i18n, + final TargetManagement targetManagement, final EntityFactory entityFactory, final VaadinMessageSource i18n, final UIEventBus eventbus, final UINotification notification, final ManagementUIState managementUIState, final ManagementViewClientCriterion managementViewClientCriterion, final DeploymentManagement deploymentManagement, final UiProperties uiproperties, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayoutWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayoutWindow.java index d2ae42aa6..62f9927a3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayoutWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayoutWindow.java @@ -23,7 +23,7 @@ import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout; import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.data.domain.PageRequest; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -54,7 +54,7 @@ public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLa * @param uiNotification * UINotification */ - public CreateUpdateTargetTagLayoutWindow(final I18N i18n, final TagManagement tagManagement, + public CreateUpdateTargetTagLayoutWindow(final VaadinMessageSource i18n, final TagManagement tagManagement, final EntityFactory entityFactory, final UIEventBus eventBus, final SpPermissionChecker permChecker, final UINotification uiNotification) { super(i18n, tagManagement, entityFactory, eventBus, permChecker, uiNotification); @@ -132,7 +132,7 @@ public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLa eventBus.publish(this, new TargetTagTableEvent(BaseEntityEventType.ADD_ENTITY, newTargetTag)); displaySuccess(newTargetTag.getName()); } else { - displayValidationError(i18n.get(MESSAGE_ERROR_MISSING_TAGNAME)); + displayValidationError(i18n.getMessage(MESSAGE_ERROR_MISSING_TAGNAME)); } } @@ -151,7 +151,7 @@ public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLa @Override protected String getWindowCaption() { - return i18n.get("caption.add.tag"); + return i18n.getMessage("caption.add.tag"); } @Override 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 be9acd712..f8b045b30 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 @@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.TargetFilterEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.vaadin.spring.events.EventBus; @@ -38,7 +38,7 @@ import com.vaadin.ui.VerticalLayout; public class FilterByStatusLayout extends VerticalLayout implements Button.ClickListener { private static final long serialVersionUID = -6930348859189929850L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient EventBus.UIEventBus eventBus; @@ -61,7 +61,7 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click private Button buttonClicked; private static final String BTN_CLICKED = "btnClicked"; - FilterByStatusLayout(final I18N i18n, final UIEventBus eventBus, final ManagementUIState managementUIState) { + FilterByStatusLayout(final VaadinMessageSource i18n, final UIEventBus eventBus, final ManagementUIState managementUIState) { this.i18n = i18n; this.eventBus = eventBus; this.managementUIState = managementUIState; @@ -83,7 +83,7 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click addStyleName("target-status-filters"); setMargin(false); - final Label targetFilterStatusLabel = new LabelBuilder().name(i18n.get("label.filter.by.status")).buildLabel(); + final Label targetFilterStatusLabel = new LabelBuilder().name(i18n.getMessage("label.filter.by.status")).buildLabel(); targetFilterStatusLabel.addStyleName("target-status-filters-title"); @@ -105,7 +105,7 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click setComponentAlignment(buttonLayout, Alignment.MIDDLE_LEFT); final HorizontalLayout overdueLayout = new HorizontalLayout(); - final Label overdueLabel = new LabelBuilder().name(i18n.get("label.filter.by.overdue")).buildLabel(); + final Label overdueLabel = new LabelBuilder().name(i18n.getMessage("label.filter.by.overdue")).buildLabel(); overdueLayout.setStyleName("overdue-button-layout"); overdueLayout.addComponent(overdue); overdueLayout.setComponentAlignment(overdue, Alignment.MIDDLE_LEFT); @@ -149,22 +149,22 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click */ private void getTargetFilterStatuses() { unknown = SPUIComponentProvider.getButton(UIComponentIdProvider.UNKNOWN_STATUS_ICON, - TargetUpdateStatus.UNKNOWN.toString(), i18n.get("tooltip.status.unknown"), + TargetUpdateStatus.UNKNOWN.toString(), i18n.getMessage("tooltip.status.unknown"), SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class); inSync = SPUIComponentProvider.getButton(UIComponentIdProvider.INSYNCH_STATUS_ICON, - TargetUpdateStatus.IN_SYNC.toString(), i18n.get("tooltip.status.insync"), + TargetUpdateStatus.IN_SYNC.toString(), i18n.getMessage("tooltip.status.insync"), SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class); pending = SPUIComponentProvider.getButton(UIComponentIdProvider.PENDING_STATUS_ICON, - TargetUpdateStatus.PENDING.toString(), i18n.get("tooltip.status.pending"), + TargetUpdateStatus.PENDING.toString(), i18n.getMessage("tooltip.status.pending"), SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class); error = SPUIComponentProvider.getButton(UIComponentIdProvider.ERROR_STATUS_ICON, - TargetUpdateStatus.ERROR.toString(), i18n.get("tooltip.status.error"), + TargetUpdateStatus.ERROR.toString(), i18n.getMessage("tooltip.status.error"), SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class); registered = SPUIComponentProvider.getButton(UIComponentIdProvider.REGISTERED_STATUS_ICON, - TargetUpdateStatus.REGISTERED.toString(), i18n.get("tooltip.status.registered"), + TargetUpdateStatus.REGISTERED.toString(), i18n.getMessage("tooltip.status.registered"), SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class); overdue = SPUIComponentProvider.getButton(UIComponentIdProvider.OVERDUE_STATUS_ICON, OVERDUE_CAPTION, - i18n.get("tooltip.status.overdue"), SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, + i18n.getMessage("tooltip.status.overdue"), SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class); applyStatusBtnStyle(); unknown.setData("filterStatusOne"); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java index aaa224dea..0ef0924ac 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java @@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -48,7 +48,7 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange private final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout; private final SpPermissionChecker permChecker; private final ManagementUIState managementUIState; - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient EventBus.UIEventBus eventBus; private VerticalLayout simpleFilterTab; @@ -56,7 +56,7 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange private Button config; MultipleTargetFilter(final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout, - final SpPermissionChecker permChecker, final ManagementUIState managementUIState, final I18N i18n, + final SpPermissionChecker permChecker, final ManagementUIState managementUIState, final VaadinMessageSource i18n, final UIEventBus eventBus, final ManagementViewClientCriterion managementViewClientCriterion, final UINotification notification, final EntityFactory entityFactory, final TargetFilterQueryManagement targetFilterQueryManagement) { @@ -129,7 +129,7 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange targetTagTableLayout.setComponentAlignment(filterByButtons, Alignment.MIDDLE_CENTER); targetTagTableLayout.setId(UIComponentIdProvider.TARGET_TAG_DROP_AREA_ID); targetTagTableLayout.setExpandRatio(filterByButtons, 1.0F); - simpleFilterTab.setCaption(i18n.get("caption.filter.simple")); + simpleFilterTab.setCaption(i18n.getMessage("caption.filter.simple")); simpleFilterTab.addComponent(targetTagTableLayout); simpleFilterTab.setExpandRatio(targetTagTableLayout, 1.0F); simpleFilterTab.addComponent(filterByStatusFotter); @@ -140,7 +140,7 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange } private Component getComplexFilterTab() { - targetFilterQueryButtonsTab.setCaption(i18n.get("caption.filter.custom")); + targetFilterQueryButtonsTab.setCaption(i18n.getMessage("caption.filter.custom")); return targetFilterQueryButtonsTab; } @@ -153,7 +153,7 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange */ @Override public void selectedTabChange(final SelectedTabChangeEvent event) { - if (i18n.get("caption.filter.simple").equals(getSelectedTab().getCaption())) { + if (i18n.getMessage("caption.filter.simple").equals(getSelectedTab().getCaption())) { managementUIState.setCustomFilterSelected(false); eventBus.publish(this, ManagementUIEvent.RESET_TARGET_FILTER_QUERY); } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java index 0b44455c8..4b26fe7fe 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java @@ -24,7 +24,7 @@ import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.tag.TagIdName; import org.eclipse.hawkbit.ui.management.targettable.TargetTable; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -57,7 +57,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref private final ManagementViewClientCriterion managementViewClientCriterion; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UINotification notification; @@ -66,7 +66,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref private final transient EntityFactory entityFactory; TargetTagFilterButtons(final UIEventBus eventBus, final ManagementUIState managementUIState, - final ManagementViewClientCriterion managementViewClientCriterion, final I18N i18n, + final ManagementViewClientCriterion managementViewClientCriterion, final VaadinMessageSource i18n, final UINotification notification, final SpPermissionChecker permChecker, final EntityFactory entityFactory) { super(eventBus, new TargetTagFilterButtonClick(eventBus, managementUIState)); @@ -136,7 +136,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref final String tagName = ((DragAndDropWrapper) (event.getTargetDetails().getTarget())).getData().toString(); if (tagName.equals(SPUIDefinitions.TARGET_TAG_BUTTON)) { notification.displayValidationError( - i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") })); + i18n.getMessage("message.tag.cannot.be.assigned", new Object[] { i18n.getMessage("label.no.tag.assigned") })); return false; } return true; @@ -153,7 +153,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref final Transferable transferable = event.getTransferable(); final Component compsource = transferable.getSourceComponent(); if (!(compsource instanceof AbstractTable)) { - notification.displayValidationError(i18n.get(SPUILabelDefinitions.ACTION_NOT_ALLOWED)); + notification.displayValidationError(i18n.getMessage(SPUILabelDefinitions.ACTION_NOT_ALLOWED)); return false; } @@ -167,7 +167,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref final Set deletedEntityByTransferable = source.getDeletedEntityByTransferable(tabletransferable); if (deletedEntityByTransferable.isEmpty()) { - final String actionDidNotWork = i18n.get("message.action.did.not.work", new Object[] {}); + final String actionDidNotWork = i18n.getMessage("message.action.did.not.work", new Object[] {}); notification.displayValidationError(actionDidNotWork); return false; } @@ -183,7 +183,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref private boolean checkForTargetUpdatePermission() { if (!permChecker.hasUpdateTargetPermission()) { - notification.displayValidationError(i18n.get("message.permission.insufficient")); + notification.displayValidationError(i18n.getMessage("message.permission.insufficient")); return false; } @@ -229,7 +229,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons implements Ref private boolean validateIfSourceisTargetTable(final Table source) { if (!source.getId().equals(UIComponentIdProvider.TARGET_TABLE_ID)) { - notification.displayValidationError(i18n.get(SPUILabelDefinitions.ACTION_NOT_ALLOWED)); + notification.displayValidationError(i18n.getMessage(SPUILabelDefinitions.ACTION_NOT_ALLOWED)); return false; } return true; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java index e276e9267..1ee33e3d7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java @@ -12,7 +12,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -27,7 +27,7 @@ public class TargetTagFilterHeader extends AbstractFilterHeader { private final ManagementUIState managementUIState; - TargetTagFilterHeader(final I18N i18n, final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout, + TargetTagFilterHeader(final VaadinMessageSource i18n, final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout, final ManagementUIState managementUIState, final SpPermissionChecker permChecker, final UIEventBus eventBus) { super(permChecker, eventBus, i18n); @@ -50,7 +50,7 @@ public class TargetTagFilterHeader extends AbstractFilterHeader { @Override protected String getTitle() { - return i18n.get("header.target.filter.tag", new Object[] {}); + return i18n.getMessage("header.target.filter.tag", new Object[] {}); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java index 85f278d27..fd14ca6f1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java @@ -17,7 +17,7 @@ import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventScope; @@ -31,7 +31,7 @@ public class TargetTagFilterLayout extends AbstractTargetTagFilterLayout impleme private static final long serialVersionUID = 2153612878428575009L; private final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout; - public TargetTagFilterLayout(final I18N i18n, final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout, + public TargetTagFilterLayout(final VaadinMessageSource i18n, final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout, final ManagementUIState managementUIState, final ManagementViewClientCriterion managementViewClientCriterion, final SpPermissionChecker permChecker, final UIEventBus eventBus, final UINotification notification, final EntityFactory entityFactory, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java index 61cd0c36c..db5babfd1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java @@ -25,7 +25,7 @@ import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.springframework.beans.factory.annotation.Autowired; @@ -61,7 +61,7 @@ public final class DashboardMenu extends CustomComponent { private static final String ID = "dashboard-menu"; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UiProperties uiProperties; @@ -82,7 +82,7 @@ public final class DashboardMenu extends CustomComponent { private boolean accessibleViewsEmpty; @Autowired - DashboardMenu(final I18N i18n, final UiProperties uiProperties, final HawkbitServerProperties serverProperties, + DashboardMenu(final VaadinMessageSource i18n, final UiProperties uiProperties, final HawkbitServerProperties serverProperties, final PermissionService permissionService, final List dashboardVaadinViews) { this.i18n = i18n; this.uiProperties = uiProperties; @@ -138,7 +138,7 @@ public final class DashboardMenu extends CustomComponent { } private Component buildTitle() { - final Label logo = new Label("" + i18n.get("menu.title") + "", ContentMode.HTML); + final Label logo = new Label("" + i18n.getMessage("menu.title") + "", ContentMode.HTML); logo.setSizeUndefined(); final HorizontalLayout logoWrapper = new HorizontalLayout(logo); logoWrapper.setComponentAlignment(logo, Alignment.TOP_CENTER); @@ -154,9 +154,9 @@ public final class DashboardMenu extends CustomComponent { if (!uiProperties.getLinks().getDocumentation().getRoot().isEmpty()) { final Link docuLink = SPUIComponentProvider.getLink(UIComponentIdProvider.LINK_DOCUMENTATION, - i18n.get("link.documentation.name"), uiProperties.getLinks().getDocumentation().getRoot(), + i18n.getMessage("link.documentation.name"), uiProperties.getLinks().getDocumentation().getRoot(), FontAwesome.QUESTION_CIRCLE, "_blank", linkStyle); - docuLink.setDescription(i18n.get("link.documentation.name")); + docuLink.setDescription(i18n.getMessage("link.documentation.name")); docuLink.setSizeFull(); links.addComponent(docuLink); links.setComponentAlignment(docuLink, Alignment.BOTTOM_CENTER); @@ -164,9 +164,9 @@ public final class DashboardMenu extends CustomComponent { if (!uiProperties.getLinks().getUserManagement().isEmpty()) { final Link userManagementLink = SPUIComponentProvider.getLink(UIComponentIdProvider.LINK_USERMANAGEMENT, - i18n.get("link.usermanagement.name"), uiProperties.getLinks().getUserManagement(), + i18n.getMessage("link.usermanagement.name"), uiProperties.getLinks().getUserManagement(), FontAwesome.USERS, "_blank", linkStyle); - userManagementLink.setDescription(i18n.get("link.usermanagement.name")); + userManagementLink.setDescription(i18n.getMessage("link.usermanagement.name")); links.addComponent(userManagementLink); userManagementLink.setSizeFull(); links.setComponentAlignment(userManagementLink, Alignment.BOTTOM_CENTER); @@ -174,9 +174,9 @@ public final class DashboardMenu extends CustomComponent { if (!uiProperties.getLinks().getSupport().isEmpty()) { final Link supportLink = SPUIComponentProvider.getLink(UIComponentIdProvider.LINK_SUPPORT, - i18n.get("link.support.name"), uiProperties.getLinks().getSupport(), FontAwesome.ENVELOPE_O, "", + i18n.getMessage("link.support.name"), uiProperties.getLinks().getSupport(), FontAwesome.ENVELOPE_O, "", linkStyle); - supportLink.setDescription(i18n.get("link.support.name")); + supportLink.setDescription(i18n.getMessage("link.support.name")); supportLink.setSizeFull(); links.addComponent(supportLink); links.setComponentAlignment(supportLink, Alignment.BOTTOM_CENTER); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutView.java index b8c87d4fe..89ec9614e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutView.java @@ -27,7 +27,7 @@ import org.eclipse.hawkbit.ui.rollout.rollout.RolloutListView; import org.eclipse.hawkbit.ui.rollout.rolloutgroup.RolloutGroupsListView; import org.eclipse.hawkbit.ui.rollout.rolloutgrouptargets.RolloutGroupTargetsListView; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus; @@ -71,7 +71,7 @@ public class RolloutView extends VerticalLayout implements View { final UIEventBus eventBus, final RolloutManagement rolloutManagement, final RolloutGroupManagement rolloutGroupManagement, final TargetManagement targetManagement, final UINotification uiNotification, final UiProperties uiProperties, final EntityFactory entityFactory, - final I18N i18n, final TargetFilterQueryManagement targetFilterQueryManagement) { + final VaadinMessageSource i18n, final TargetFilterQueryManagement targetFilterQueryManagement) { this.permChecker = permissionChecker; this.rolloutManagement = rolloutManagement; this.rolloutListView = new RolloutListView(permissionChecker, rolloutUIState, eventBus, rolloutManagement, 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 4d065f153..934e483b7 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 @@ -51,7 +51,7 @@ import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.Acti import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.groupschart.GroupsPieChart; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; @@ -117,7 +117,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { private final DefineGroupsLayout defineGroupsLayout; - private final I18N i18n; + private final VaadinMessageSource i18n; private final transient EventBus.UIEventBus eventBus; @@ -161,7 +161,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { AddUpdateRolloutWindowLayout(final RolloutManagement rolloutManagement, final TargetManagement targetManagement, final UINotification uiNotification, final UiProperties uiProperties, final EntityFactory entityFactory, - final I18N i18n, final UIEventBus eventBus, final TargetFilterQueryManagement targetFilterQueryManagement) { + final VaadinMessageSource i18n, final UIEventBus eventBus, final TargetFilterQueryManagement targetFilterQueryManagement) { actionTypeOptionGroupLayout = new ActionTypeOptionGroupLayout(i18n); autoStartOptionGroupLayout = new AutoStartOptionGroupLayout(i18n); this.rolloutManagement = rolloutManagement; @@ -210,12 +210,12 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { private void createRollout() { final Rollout rolloutToCreate = saveRollout(); - uiNotification.displaySuccess(i18n.get("message.save.success", rolloutToCreate.getName())); + uiNotification.displaySuccess(i18n.getMessage("message.save.success", rolloutToCreate.getName())); } private boolean duplicateCheck() { if (rolloutManagement.findRolloutByName(getRolloutName()).isPresent()) { - uiNotification.displayValidationError(i18n.get("message.rollout.duplicate.check", getRolloutName())); + uiNotification.displayValidationError(i18n.getMessage("message.rollout.duplicate.check", getRolloutName())); return false; } return true; @@ -250,7 +250,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { return; } - uiNotification.displaySuccess(i18n.get("message.update.success", updatedRollout.getName())); + uiNotification.displaySuccess(i18n.getMessage("message.update.success", updatedRollout.getName())); eventBus.publish(this, RolloutEvent.UPDATE_ROLLOUT); } @@ -258,7 +258,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { final String rolloutNameVal = getRolloutName(); if (!rollout.getName().equals(rolloutNameVal) && rolloutManagement.findRolloutByName(rolloutNameVal).isPresent()) { - uiNotification.displayValidationError(i18n.get("message.rollout.duplicate.check", rolloutNameVal)); + uiNotification.displayValidationError(i18n.getMessage("message.rollout.duplicate.check", rolloutNameVal)); return false; } return true; @@ -342,7 +342,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { } private CommonDialogWindow createWindow() { - return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.configure.rollout")) + return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.getMessage("caption.configure.rollout")) .content(this).layout(this).i18n(i18n) .helpLink(uiProperties.getLinks().getDocumentation().getRolloutView()) .saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow(); @@ -451,25 +451,25 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { } private Label getMandatoryLabel(final String key) { - final Label mandatoryLabel = getLabel(i18n.get(key)); + final Label mandatoryLabel = getLabel(i18n.getMessage(key)); mandatoryLabel.setContentMode(ContentMode.HTML); mandatoryLabel.setValue(mandatoryLabel.getValue().concat(" *")); return mandatoryLabel; } private Label getLabel(final String key) { - return new LabelBuilder().name(i18n.get(key)).buildLabel(); + return new LabelBuilder().name(i18n.getMessage(key)).buildLabel(); } private TextField createTextField(final String in18Key, final String id) { - return new TextFieldBuilder().prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent(); + return new TextFieldBuilder().prompt(i18n.getMessage(in18Key)).immediate(true).id(id).buildTextComponent(); } private TextField createIntegerTextField(final String in18Key, final String id) { final TextField textField = createTextField(in18Key, id); textField.setNullRepresentation(StringUtils.EMPTY); textField.setConverter(new StringToIntegerConverter()); - textField.setConversionError(i18n.get(MESSAGE_ENTER_NUMBER)); + textField.setConversionError(i18n.getMessage(MESSAGE_ENTER_NUMBER)); textField.setSizeUndefined(); return textField; } @@ -530,10 +530,10 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { tabSheet.setStyleName(SPUIStyleDefinitions.ROLLOUT_GROUPS); final TabSheet.Tab simpleTab = tabSheet.addTab(createSimpleGroupDefinitionTab(), - i18n.get("caption.rollout.tabs.simple")); + i18n.getMessage("caption.rollout.tabs.simple")); simpleTab.setId(UIComponentIdProvider.ROLLOUT_SIMPLE_TAB); - final TabSheet.Tab advancedTab = tabSheet.addTab(defineGroupsLayout, i18n.get("caption.rollout.tabs.advanced")); + final TabSheet.Tab advancedTab = tabSheet.addTab(defineGroupsLayout, i18n.getMessage("caption.rollout.tabs.advanced")); advancedTab.setId(UIComponentIdProvider.ROLLOUT_ADVANCED_TAB); tabSheet.addSelectedTabChangeListener(event -> validateGroups()); @@ -693,7 +693,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { private ComboBox createTargetFilterQueryCombo() { return new ComboBoxBuilder().setValueChangeListener(this::onTargetFilterChange) - .setPrompt(i18n.get("prompt.target.filter")).setId(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_COMBO_ID) + .setPrompt(i18n.getMessage("prompt.target.filter")).setId(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_COMBO_ID) .buildCombBox(); } @@ -712,7 +712,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { } private String getTargetPerGroupMessage(final String value) { - return new StringBuilder(i18n.get("label.target.per.group")).append(value).toString(); + return new StringBuilder(i18n.getMessage("label.target.per.group")).append(value).toString(); } private void populateTargetFilterQuery() { @@ -753,7 +753,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { private TextArea createDescription() { final TextArea descriptionField = new TextAreaBuilder().style("text-area-style") - .prompt(i18n.get("textfield.description")).id(UIComponentIdProvider.ROLLOUT_DESCRIPTION_ID) + .prompt(i18n.getMessage("textfield.description")).id(UIComponentIdProvider.ROLLOUT_DESCRIPTION_ID) .buildTextComponent(); descriptionField.setNullRepresentation(StringUtils.EMPTY); descriptionField.setSizeUndefined(); @@ -804,7 +804,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { } private ComboBox createDistributionSetCombo() { - return new ComboBoxBuilder().setPrompt(i18n.get("prompt.distribution.set")) + return new ComboBoxBuilder().setPrompt(i18n.getMessage("prompt.distribution.set")) .setId(UIComponentIdProvider.ROLLOUT_DS_ID).buildCombBox(); } @@ -833,11 +833,11 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { @Override public void validate(final Object value) { if (isNoOfGroupsOrTargetFilterEmpty()) { - uiNotification.displayValidationError(i18n.get("message.rollout.noofgroups.or.targetfilter.missing")); + uiNotification.displayValidationError(i18n.getMessage("message.rollout.noofgroups.or.targetfilter.missing")); } else { if (value != null) { final int groupSize = getGroupSize(); - new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, groupSize), 0, groupSize) + new IntegerRangeValidator(i18n.getMessage(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, groupSize), 0, groupSize) .validate(Integer.valueOf(value.toString())); } } @@ -860,7 +860,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { @Override public void validate(final Object value) { if (value != null) { - new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100) + new IntegerRangeValidator(i18n.getMessage(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100) .validate(Integer.valueOf(value.toString())); } } @@ -872,7 +872,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { @Override public void validate(final Object value) { if (value != null) { - new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 1, 500), 1, 500) + new IntegerRangeValidator(i18n.getMessage(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 1, 500), 1, 500) .validate(Integer.valueOf(value.toString())); } } @@ -895,7 +895,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { setAutoStartType(rollout); if (copy) { - rolloutName.setValue(i18n.get("textfield.rollout.copied.name", rollout.getName())); + rolloutName.setValue(i18n.getMessage("textfield.rollout.copied.name", rollout.getName())); populateTargetFilterQuery(rollout); defineGroupsLayout.populateByRollout(rollout); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AutoStartOptionGroupLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AutoStartOptionGroupLayout.java index 8036d76e5..f9587d48a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AutoStartOptionGroupLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AutoStartOptionGroupLayout.java @@ -12,7 +12,8 @@ import java.time.LocalDateTime; import java.util.Date; import java.util.TimeZone; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroup; @@ -35,7 +36,7 @@ public class AutoStartOptionGroupLayout extends HorizontalLayout { private static final long serialVersionUID = -8460459258964093525L; private static final String STYLE_DIST_WINDOW_AUTO_START = "dist-window-actiontype"; - private final I18N i18n; + private final VaadinMessageSource i18n; private FlexibleOptionGroup autoStartOptionGroup; @@ -47,7 +48,7 @@ public class AutoStartOptionGroupLayout extends HorizontalLayout { * @param i18n * the internationalization helper */ - AutoStartOptionGroupLayout(final I18N i18n) { + AutoStartOptionGroupLayout(final VaadinMessageSource i18n) { this.i18n = i18n; createOptionGroup(); @@ -89,8 +90,8 @@ public class AutoStartOptionGroupLayout extends HorizontalLayout { final Label manualLabel = new Label(); manualLabel.setStyleName("statusIconPending"); manualLabel.setIcon(FontAwesome.HAND_PAPER_O); - manualLabel.setCaption(i18n.get("caption.rollout.start.manual")); - manualLabel.setDescription(i18n.get("caption.rollout.start.manual.desc")); + manualLabel.setCaption(i18n.getMessage("caption.rollout.start.manual")); + manualLabel.setDescription(i18n.getMessage("caption.rollout.start.manual.desc")); manualLabel.setStyleName("padding-right-style"); addComponent(manualLabel); @@ -102,8 +103,8 @@ public class AutoStartOptionGroupLayout extends HorizontalLayout { final Label autoStartLabel = new Label(); autoStartLabel.setSizeFull(); autoStartLabel.setIcon(FontAwesome.PLAY); - autoStartLabel.setCaption(i18n.get("caption.rollout.start.auto")); - autoStartLabel.setDescription(i18n.get("caption.rollout.start.auto.desc")); + autoStartLabel.setCaption(i18n.getMessage("caption.rollout.start.auto")); + autoStartLabel.setDescription(i18n.getMessage("caption.rollout.start.auto.desc")); autoStartLabel.setStyleName("padding-right-style"); addComponent(autoStartLabel); @@ -116,8 +117,8 @@ public class AutoStartOptionGroupLayout extends HorizontalLayout { final Label scheduledLabel = new Label(); scheduledLabel.setStyleName("statusIconPending"); scheduledLabel.setIcon(FontAwesome.CLOCK_O); - scheduledLabel.setCaption(i18n.get("caption.rollout.start.scheduled")); - scheduledLabel.setDescription(i18n.get("caption.rollout.start.scheduled.desc")); + 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); @@ -132,7 +133,7 @@ public class AutoStartOptionGroupLayout extends HorizontalLayout { Date.from(LocalDateTime.now().plusMinutes(30).atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant())); startAtDateField.setImmediate(true); startAtDateField.setTimeZone(tz); - startAtDateField.setLocale(i18n.getLocale()); + startAtDateField.setLocale(HawkbitCommonUtil.getLocale()); startAtDateField.setResolution(Resolution.MINUTE); startAtDateField.addStyleName(ValoTheme.DATEFIELD_SMALL); addComponent(startAtDateField); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DefineGroupsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DefineGroupsLayout.java index 16d4f54c8..c30d67a20 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DefineGroupsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DefineGroupsLayout.java @@ -30,7 +30,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorderWithIcon; import org.eclipse.hawkbit.ui.filtermanagement.TargetFilterBeanQuery; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -68,7 +68,7 @@ public class DefineGroupsLayout extends GridLayout { private static final long serialVersionUID = 2939193468001472916L; - private I18N i18n; + private VaadinMessageSource i18n; private transient EntityFactory entityFactory; @@ -98,7 +98,7 @@ public class DefineGroupsLayout extends GridLayout { private boolean validationRequested; - DefineGroupsLayout(I18N i18n, EntityFactory entityFactory, RolloutManagement rolloutManagement, + DefineGroupsLayout(VaadinMessageSource i18n, EntityFactory entityFactory, RolloutManagement rolloutManagement, TargetFilterQueryManagement targetFilterQueryManagement) { this.i18n = i18n; this.entityFactory = entityFactory; @@ -148,12 +148,12 @@ public class DefineGroupsLayout extends GridLayout { } private Label getLabel(final String key) { - return new LabelBuilder().name(i18n.get(key)).buildLabel(); + return new LabelBuilder().name(i18n.getMessage(key)).buildLabel(); } private Button createAddButton() { Button button = SPUIComponentProvider.getButton(UIComponentIdProvider.ROLLOUT_GROUP_ADD_ID, - i18n.get("button.rollout.add.group"), "", "", true, FontAwesome.PLUS, + i18n.getMessage("button.rollout.add.group"), "", "", true, FontAwesome.PLUS, SPUIButtonStyleNoBorderWithIcon.class); button.setSizeUndefined(); button.addStyleName("default-color"); @@ -362,7 +362,7 @@ public class DefineGroupsLayout extends GridLayout { private void init() { groupsCount += 1; groupName = createTextField("textfield.name", UIComponentIdProvider.ROLLOUT_GROUP_LIST_GRID_ID); - groupName.setValue(i18n.get("textfield.rollout.group.default.name", groupsCount)); + groupName.setValue(i18n.getMessage("textfield.rollout.group.default.name", groupsCount)); groupName.setStyleName("rollout-group-name"); targetFilterQueryCombo = createTargetFilterQueryCombo(); @@ -389,17 +389,17 @@ public class DefineGroupsLayout extends GridLayout { } private TextField createTextField(final String in18Key, final String id) { - final TextField textField = new TextFieldBuilder().prompt(i18n.get(in18Key)).immediate(true).id(id) + final TextField textField = new TextFieldBuilder().prompt(i18n.getMessage(in18Key)).immediate(true).id(id) .buildTextComponent(); textField.setSizeUndefined(); textField.addValidator( - new StringLengthValidator(i18n.get("message.rollout.group.name.invalid"), 1, 64, false)); + new StringLengthValidator(i18n.getMessage("message.rollout.group.name.invalid"), 1, 64, false)); textField.addValueChangeListener(event -> valueChanged()); return textField; } private TextField createPercentageField(final String in18Key, final String id) { - final TextField textField = new TextFieldBuilder().prompt(i18n.get(in18Key)).immediate(true).id(id) + final TextField textField = new TextFieldBuilder().prompt(i18n.getMessage(in18Key)).immediate(true).id(id) .buildTextComponent(); textField.setWidth(80, Unit.PIXELS); textField.setNullRepresentation(""); @@ -422,7 +422,7 @@ public class DefineGroupsLayout extends GridLayout { private void validateMandatoryPercentage(final Object value) { if (value != null) { - final String message = i18n.get("message.rollout.field.value.range", 0, 100); + final String message = i18n.getMessage("message.rollout.field.value.range", 0, 100); if (value instanceof Float) { new FloatRangeValidator(message, 0F, 100F).validate(value); } @@ -430,7 +430,7 @@ public class DefineGroupsLayout extends GridLayout { new IntegerRangeValidator(message, 0, 100).validate(value); } } else { - throw new Validator.EmptyValueException(i18n.get("message.enter.number")); + throw new Validator.EmptyValueException(i18n.getMessage("message.enter.number")); } } @@ -442,7 +442,7 @@ public class DefineGroupsLayout extends GridLayout { private ComboBox createTargetFilterQueryCombo() { return new ComboBoxBuilder().setId(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_COMBO_ID) - .setPrompt(i18n.get("prompt.target.filter")).setValueChangeListener(event -> valueChanged()) + .setPrompt(i18n.getMessage("prompt.target.filter")).setValueChangeListener(event -> valueChanged()) .buildCombBox(); } @@ -599,7 +599,7 @@ public class DefineGroupsLayout extends GridLayout { * Displays an error for the row */ public void markWithLastGroupError() { - targetPercentage.setComponentError(new UserError(i18n.get("message.rollout.remaining.targets.error"))); + targetPercentage.setComponentError(new UserError(i18n.getMessage("message.rollout.remaining.targets.error"))); } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/GroupsLegendLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/GroupsLegendLayout.java index c2afb0759..f8dd10c6d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/GroupsLegendLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/GroupsLegendLayout.java @@ -15,7 +15,7 @@ import org.eclipse.hawkbit.repository.builder.RolloutGroupCreate; import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroupsValidation; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import com.vaadin.ui.Component; import com.vaadin.ui.Label; @@ -30,7 +30,7 @@ public class GroupsLegendLayout extends VerticalLayout { private static final long serialVersionUID = 5483206203739308677L; - private final I18N i18n; + private final VaadinMessageSource i18n; private Label totalTargetsLabel; @@ -43,7 +43,7 @@ public class GroupsLegendLayout extends VerticalLayout { /** * Initializes a new GroupsLegendLayout */ - GroupsLegendLayout(final I18N i18n) { + GroupsLegendLayout(final VaadinMessageSource i18n) { this.i18n = i18n; init(); @@ -90,7 +90,7 @@ public class GroupsLegendLayout extends VerticalLayout { label.addStyleName("rollout-target-count-loading"); label.setImmediate(true); label.setSizeUndefined(); - label.setValue(i18n.get("label.rollout.calculating")); + label.setValue(i18n.getMessage("label.rollout.calculating")); return label; } @@ -109,7 +109,7 @@ public class GroupsLegendLayout extends VerticalLayout { } private String getTotalTargetMessage(final long totalTargetsCount) { - return i18n.get("label.target.filter.count") + totalTargetsCount; + return i18n.getMessage("label.target.filter.count") + totalTargetsCount; } /** @@ -153,7 +153,7 @@ public class GroupsLegendLayout extends VerticalLayout { if (targetsPerGroup.size() > i) { final Long targetCount = targetsPerGroup.get(i); label.setValue( - getTargetsInGroupMessage(targetCount, i18n.get("textfield.rollout.group.default.name", i + 1))); + getTargetsInGroupMessage(targetCount, i18n.getMessage("textfield.rollout.group.default.name", i + 1))); label.setVisible(true); } else { label.setValue(""); @@ -241,7 +241,7 @@ public class GroupsLegendLayout extends VerticalLayout { } private String getTargetsInGroupMessage(final Long targets, final String groupName) { - return i18n.get("label.rollout.targets.in.group", targets, groupName); + return i18n.getMessage("label.rollout.targets.in.group", targets, groupName); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java index 60da3e35e..d32e60d3f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java @@ -63,7 +63,7 @@ import org.eclipse.hawkbit.ui.rollout.StatusFontIcon; import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -137,7 +137,7 @@ public class RolloutListGrid extends AbstractGrid { statusIconMap.put(RolloutStatus.DELETING, new StatusFontIcon(null, SPUIStyleDefinitions.STATUS_SPINNER_RED)); } - RolloutListGrid(final I18N i18n, final UIEventBus eventBus, final RolloutManagement rolloutManagement, + RolloutListGrid(final VaadinMessageSource i18n, final UIEventBus eventBus, final RolloutManagement rolloutManagement, final UINotification uiNotification, final RolloutUIState rolloutUIState, final SpPermissionChecker permissionChecker, final TargetManagement targetManagement, final EntityFactory entityFactory, final UiProperties uiProperties, @@ -310,35 +310,35 @@ public class RolloutListGrid extends AbstractGrid { @Override protected void setColumnHeaderNames() { - getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name")); - getColumn(DS_TYPE).setHeaderCaption(i18n.get("header.type")); - getColumn(SW_MODULES).setHeaderCaption(i18n.get("header.swmodules")); - getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption(i18n.get("header.migrations.step")); - getColumn(VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset")); - getColumn(VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups")); - getColumn(VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets")); - getColumn(VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate")); - getColumn(VAR_CREATED_USER).setHeaderCaption(i18n.get("header.createdBy")); - getColumn(VAR_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate")); - getColumn(VAR_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy")); - getColumn(VAR_DESC).setHeaderCaption(i18n.get("header.description")); - getColumn(VAR_TOTAL_TARGETS_COUNT_STATUS).setHeaderCaption(i18n.get("header.detail.status")); - getColumn(VAR_STATUS).setHeaderCaption(i18n.get("header.status")); + getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.getMessage("header.name")); + getColumn(DS_TYPE).setHeaderCaption(i18n.getMessage("header.type")); + getColumn(SW_MODULES).setHeaderCaption(i18n.getMessage("header.swmodules")); + getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption(i18n.getMessage("header.migrations.step")); + getColumn(VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.getMessage("header.distributionset")); + getColumn(VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.getMessage("header.numberofgroups")); + getColumn(VAR_TOTAL_TARGETS).setHeaderCaption(i18n.getMessage("header.total.targets")); + getColumn(VAR_CREATED_DATE).setHeaderCaption(i18n.getMessage("header.createdDate")); + getColumn(VAR_CREATED_USER).setHeaderCaption(i18n.getMessage("header.createdBy")); + getColumn(VAR_MODIFIED_DATE).setHeaderCaption(i18n.getMessage("header.modifiedDate")); + getColumn(VAR_MODIFIED_BY).setHeaderCaption(i18n.getMessage("header.modifiedBy")); + getColumn(VAR_DESC).setHeaderCaption(i18n.getMessage("header.description")); + getColumn(VAR_TOTAL_TARGETS_COUNT_STATUS).setHeaderCaption(i18n.getMessage("header.detail.status")); + getColumn(VAR_STATUS).setHeaderCaption(i18n.getMessage("header.status")); - getColumn(RUN_OPTION).setHeaderCaption(i18n.get("header.action.run")); - getColumn(PAUSE_OPTION).setHeaderCaption(i18n.get("header.action.pause")); + getColumn(RUN_OPTION).setHeaderCaption(i18n.getMessage("header.action.run")); + getColumn(PAUSE_OPTION).setHeaderCaption(i18n.getMessage("header.action.pause")); if (permissionChecker.hasRolloutUpdatePermission()) { - getColumn(UPDATE_OPTION).setHeaderCaption(i18n.get("header.action.update")); + getColumn(UPDATE_OPTION).setHeaderCaption(i18n.getMessage("header.action.update")); } if (permissionChecker.hasRolloutCreatePermission()) { - getColumn(COPY_OPTION).setHeaderCaption(i18n.get("header.action.copy")); + getColumn(COPY_OPTION).setHeaderCaption(i18n.getMessage("header.action.copy")); } - getColumn(DELETE_OPTION).setHeaderCaption(i18n.get("header.action.delete")); + getColumn(DELETE_OPTION).setHeaderCaption(i18n.getMessage("header.action.delete")); - joinColumns().setText(i18n.get("header.action")); + joinColumns().setText(i18n.getMessage("header.action")); } private HeaderCell joinColumns() { @@ -473,7 +473,7 @@ public class RolloutListGrid extends AbstractGrid { final String rolloutName = (String) row.getItemProperty(VAR_NAME).getValue(); rolloutManagement.pauseRollout(rolloutId); - uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName)); + uiNotification.displaySuccess(i18n.getMessage("message.rollout.paused", rolloutName)); } private void startOrResumeRollout(final Long rolloutId) { @@ -484,27 +484,27 @@ public class RolloutListGrid extends AbstractGrid { if (RolloutStatus.READY.equals(rolloutStatus)) { rolloutManagement.startRollout(rolloutId); - uiNotification.displaySuccess(i18n.get("message.rollout.started", rolloutName)); + uiNotification.displaySuccess(i18n.getMessage("message.rollout.started", rolloutName)); return; } if (RolloutStatus.PAUSED.equals(rolloutStatus)) { rolloutManagement.resumeRollout(rolloutId); - uiNotification.displaySuccess(i18n.get("message.rollout.resumed", rolloutName)); + uiNotification.displaySuccess(i18n.getMessage("message.rollout.resumed", rolloutName)); return; } } private void updateRollout(final Long rolloutId) { final CommonDialogWindow addTargetWindow = addUpdateRolloutWindow.getWindow(rolloutId, false); - addTargetWindow.setCaption(i18n.get("caption.update.rollout")); + addTargetWindow.setCaption(i18n.getMessage("caption.update.rollout")); UI.getCurrent().addWindow(addTargetWindow); addTargetWindow.setVisible(Boolean.TRUE); } private void copyRollout(final Long rolloutId) { final CommonDialogWindow addTargetWindow = addUpdateRolloutWindow.getWindow(rolloutId, true); - addTargetWindow.setCaption(i18n.get("caption.create.rollout")); + addTargetWindow.setCaption(i18n.getMessage("caption.create.rollout")); UI.getCurrent().addWindow(addTargetWindow); addTargetWindow.setVisible(Boolean.TRUE); } @@ -517,15 +517,15 @@ public class RolloutListGrid extends AbstractGrid { } final String formattedConfirmationQuestion = getConfirmationQuestion(rollout.get()); - final ConfirmationDialog confirmationDialog = new ConfirmationDialog(i18n.get("caption.confirm.delete.rollout"), - formattedConfirmationQuestion, i18n.get("button.ok"), i18n.get("button.cancel"), ok -> { + final ConfirmationDialog confirmationDialog = new ConfirmationDialog(i18n.getMessage("caption.confirm.delete.rollout"), + formattedConfirmationQuestion, i18n.getMessage("button.ok"), i18n.getMessage("button.cancel"), ok -> { if (!ok) { return; } final Item row = getContainerDataSource().getItem(rolloutId); final String rolloutName = (String) row.getItemProperty(VAR_NAME).getValue(); rolloutManagement.deleteRollout(rolloutId); - uiNotification.displaySuccess(i18n.get("message.rollout.deleted", rolloutName)); + uiNotification.displaySuccess(i18n.getMessage("message.rollout.deleted", rolloutName)); }); UI.getCurrent().addWindow(confirmationDialog.getWindow()); confirmationDialog.getWindow().bringToFront(); @@ -541,10 +541,10 @@ public class RolloutListGrid extends AbstractGrid { final Long runningActions = statusTotalCount.get(Status.RUNNING); String rolloutDetailsMessage = StringUtils.EMPTY; if ((scheduledActions > 0) || (runningActions > 0)) { - rolloutDetailsMessage = i18n.get("message.delete.rollout.details", runningActions, scheduledActions); + rolloutDetailsMessage = i18n.getMessage("message.delete.rollout.details", runningActions, scheduledActions); } - return i18n.get("message.delete.rollout", rollout.getName(), rolloutDetailsMessage); + return i18n.getMessage("message.delete.rollout", rollout.getName(), rolloutDetailsMessage); } private String getDescription(final CellReference cell) { 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 5ba538c60..6837862fb 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 @@ -18,7 +18,7 @@ import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader; 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.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -44,7 +44,7 @@ public class RolloutListHeader extends AbstractGridHeader { RolloutListHeader(final SpPermissionChecker permissionChecker, final RolloutUIState rolloutUIState, final UIEventBus eventBus, final RolloutManagement rolloutManagement, final TargetManagement targetManagement, final UINotification uiNotification, - final UiProperties uiProperties, final EntityFactory entityFactory, final I18N i18n, + final UiProperties uiProperties, final EntityFactory entityFactory, final VaadinMessageSource i18n, final TargetFilterQueryManagement targetFilterQueryManagement) { super(permissionChecker, rolloutUIState, i18n); this.eventBus = eventBus; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListView.java index 9504a8c9c..c0e14a253 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListView.java @@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.common.grid.AbstractGridLayout; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -32,7 +32,7 @@ public class RolloutListView extends AbstractGridLayout { public RolloutListView(final SpPermissionChecker permissionChecker, final RolloutUIState rolloutUIState, final UIEventBus eventBus, final RolloutManagement rolloutManagement, final TargetManagement targetManagement, final UINotification uiNotification, - final UiProperties uiProperties, final EntityFactory entityFactory, final I18N i18n, + final UiProperties uiProperties, final EntityFactory entityFactory, final VaadinMessageSource i18n, final TargetFilterQueryManagement targetFilterQueryManagement) { super(new RolloutListHeader(permissionChecker, rolloutUIState, eventBus, rolloutManagement, targetManagement, uiNotification, uiProperties, entityFactory, i18n, targetFilterQueryManagement), diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupListGrid.java index f5d27a47a..d258eda1c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupListGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupListGrid.java @@ -30,7 +30,7 @@ import org.eclipse.hawkbit.ui.rollout.StatusFontIcon; import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -91,7 +91,7 @@ public class RolloutGroupListGrid extends AbstractGrid { * @param permissionChecker * SpPermissionChecker */ - public RolloutGroupListGrid(final I18N i18n, final UIEventBus eventBus, + public RolloutGroupListGrid(final VaadinMessageSource i18n, final UIEventBus eventBus, final RolloutGroupManagement rolloutGroupManagement, final RolloutUIState rolloutUIState, final SpPermissionChecker permissionChecker) { super(i18n, eventBus, permissionChecker); @@ -194,22 +194,22 @@ public class RolloutGroupListGrid extends AbstractGrid { @Override protected void setColumnHeaderNames() { - getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name")); - getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status")); + getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.getMessage("header.name")); + getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.getMessage("header.status")); getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS) - .setHeaderCaption(i18n.get("header.detail.status")); + .setHeaderCaption(i18n.getMessage("header.detail.status")); getColumn(SPUILabelDefinitions.ROLLOUT_GROUP_INSTALLED_PERCENTAGE) - .setHeaderCaption(i18n.get("header.rolloutgroup.installed.percentage")); + .setHeaderCaption(i18n.getMessage("header.rolloutgroup.installed.percentage")); getColumn(SPUILabelDefinitions.ROLLOUT_GROUP_ERROR_THRESHOLD) - .setHeaderCaption(i18n.get("header.rolloutgroup.threshold.error")); + .setHeaderCaption(i18n.getMessage("header.rolloutgroup.threshold.error")); getColumn(SPUILabelDefinitions.ROLLOUT_GROUP_THRESHOLD) - .setHeaderCaption(i18n.get("header.rolloutgroup.threshold")); - getColumn(SPUILabelDefinitions.VAR_CREATED_USER).setHeaderCaption(i18n.get("header.createdBy")); - getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate")); - getColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate")); - getColumn(SPUILabelDefinitions.VAR_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy")); - getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.get("header.description")); - getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets")); + .setHeaderCaption(i18n.getMessage("header.rolloutgroup.threshold")); + getColumn(SPUILabelDefinitions.VAR_CREATED_USER).setHeaderCaption(i18n.getMessage("header.createdBy")); + getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.getMessage("header.createdDate")); + getColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE).setHeaderCaption(i18n.getMessage("header.modifiedDate")); + getColumn(SPUILabelDefinitions.VAR_MODIFIED_BY).setHeaderCaption(i18n.getMessage("header.modifiedBy")); + getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.getMessage("header.description")); + getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.getMessage("header.total.targets")); } @Override 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 f122d6a60..d77d1c393 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 @@ -14,7 +14,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; 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.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -48,7 +48,7 @@ public class RolloutGroupsListHeader extends AbstractGridHeader { * @param i18n * I18N */ - public RolloutGroupsListHeader(final UIEventBus eventBus, final RolloutUIState rolloutUiState, final I18N i18n) { + public RolloutGroupsListHeader(final UIEventBus eventBus, final RolloutUIState rolloutUiState, final VaadinMessageSource i18n) { super(null, rolloutUiState, i18n); this.eventBus = eventBus; eventBus.subscribe(this); @@ -142,8 +142,8 @@ public class RolloutGroupsListHeader extends AbstractGridHeader { final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null, SPUIButtonStyleSmallNoBorder.class); rolloutsListViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links"); - rolloutsListViewLink.setDescription(i18n.get("message.rollouts")); - rolloutsListViewLink.setCaption(i18n.get("message.rollouts")); + rolloutsListViewLink.setDescription(i18n.getMessage("message.rollouts")); + rolloutsListViewLink.setCaption(i18n.getMessage("message.rollouts")); rolloutsListViewLink.addClickListener(value -> showRolloutListView()); final HorizontalLayout headerCaptionLayout = new HorizontalLayout(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupsListView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupsListView.java index 0ecd91595..de79fd6b2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupsListView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupsListView.java @@ -12,7 +12,7 @@ import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.grid.AbstractGridLayout; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.vaadin.spring.events.EventBus.UIEventBus; import com.vaadin.ui.Label; @@ -38,7 +38,7 @@ public class RolloutGroupsListView extends AbstractGridLayout { * @param permissionChecker * SpPermissionChecker */ - public RolloutGroupsListView(final I18N i18n, final UIEventBus eventBus, + public RolloutGroupsListView(final VaadinMessageSource i18n, final UIEventBus eventBus, final RolloutGroupManagement rolloutGroupManagement, final RolloutUIState rolloutUIState, final SpPermissionChecker permissionChecker) { super(new RolloutGroupsListHeader(eventBus, rolloutUIState, i18n), diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsCountLabelMessage.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsCountLabelMessage.java index 05c09850c..bebd2d039 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsCountLabelMessage.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsCountLabelMessage.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.rollout.rolloutgrouptargets; import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; @@ -34,10 +34,10 @@ public class RolloutGroupTargetsCountLabelMessage extends Label { private final RolloutGroupTargetsListGrid rolloutGroupTargetsListGrid; - private final I18N i18n; + private final VaadinMessageSource i18n; RolloutGroupTargetsCountLabelMessage(final RolloutUIState rolloutUIState, - final RolloutGroupTargetsListGrid rolloutGroupTargetsListGrid, final I18N i18n, final UIEventBus eventBus) { + final RolloutGroupTargetsListGrid rolloutGroupTargetsListGrid, final VaadinMessageSource i18n, final UIEventBus eventBus) { this.rolloutUIState = rolloutUIState; this.rolloutGroupTargetsListGrid = rolloutGroupTargetsListGrid; this.i18n = i18n; @@ -71,7 +71,7 @@ public class RolloutGroupTargetsCountLabelMessage extends Label { if (rolloutUIState.getRolloutGroupTargetsTruncated() != null) { // set the icon setIcon(FontAwesome.INFO_CIRCLE); - setDescription(i18n.get("rollout.group.label.target.truncated", + setDescription(i18n.getMessage("rollout.group.label.target.truncated", rolloutUIState.getRolloutGroupTargetsTruncated(), SPUIDefinitions.MAX_TABLE_ENTRIES)); totalTargetTableEnteries += rolloutUIState.getRolloutGroupTargetsTruncated(); } else { @@ -79,12 +79,12 @@ public class RolloutGroupTargetsCountLabelMessage extends Label { setDescription(null); } - final StringBuilder message = new StringBuilder(i18n.get("label.target.filter.count")); + final StringBuilder message = new StringBuilder(i18n.getMessage("label.target.filter.count")); message.append(rolloutUIState.getRolloutGroupTargetsTotalCount()); if (totalTargetTableEnteries > SPUIDefinitions.MAX_TABLE_ENTRIES) { message.append(HawkbitCommonUtil.SP_STRING_PIPE); - message.append(i18n.get("label.filter.shown")); + message.append(i18n.getMessage("label.filter.shown")); message.append(SPUIDefinitions.MAX_TABLE_ENTRIES); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListGrid.java index eba7eee85..c80455f0e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListGrid.java @@ -23,7 +23,7 @@ import org.eclipse.hawkbit.ui.rollout.StatusFontIcon; import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -81,7 +81,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid { * @param rolloutUIState * RolloutUIState */ - public RolloutGroupTargetsListGrid(final I18N i18n, final UIEventBus eventBus, + public RolloutGroupTargetsListGrid(final VaadinMessageSource i18n, final UIEventBus eventBus, final RolloutUIState rolloutUIState) { super(i18n, eventBus, null); this.rolloutUIState = rolloutUIState; @@ -147,13 +147,13 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid { @Override protected void setColumnHeaderNames() { - getColumn(SPUILabelDefinitions.VAR_NAME).setHeaderCaption(i18n.get("header.name")); - getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status")); - getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate")); - getColumn(SPUILabelDefinitions.VAR_CREATED_BY).setHeaderCaption(i18n.get("header.createdBy")); - getColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate")); - getColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy")); - getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.get("header.description")); + getColumn(SPUILabelDefinitions.VAR_NAME).setHeaderCaption(i18n.getMessage("header.name")); + getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.getMessage("header.status")); + getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.getMessage("header.createdDate")); + getColumn(SPUILabelDefinitions.VAR_CREATED_BY).setHeaderCaption(i18n.getMessage("header.createdBy")); + getColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setHeaderCaption(i18n.getMessage("header.modifiedDate")); + getColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setHeaderCaption(i18n.getMessage("header.modifiedBy")); + getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.getMessage("header.description")); } @Override @@ -279,7 +279,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid { return RolloutGroupStatus.READY.toString().toLowerCase(); } else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) { final String ds = rolloutUIState.getRolloutDistributionSet().orElse(""); - return i18n.get("message.dist.already.assigned", new Object[] { ds }); + return i18n.getMessage("message.dist.already.assigned", new Object[] { ds }); } return "unknown"; } 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 b7a9297c4..b5de515d7 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 @@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; 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.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -40,7 +40,7 @@ public class RolloutGroupTargetsListHeader extends AbstractGridHeader { private Button rolloutNameLink; private Label headerCaption; - public RolloutGroupTargetsListHeader(final UIEventBus eventBus, final I18N i18n, + public RolloutGroupTargetsListHeader(final UIEventBus eventBus, final VaadinMessageSource i18n, final RolloutUIState rolloutUiState) { super(null, rolloutUiState, i18n); this.eventBus = eventBus; @@ -145,8 +145,8 @@ public class RolloutGroupTargetsListHeader extends AbstractGridHeader { final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null, SPUIButtonStyleSmallNoBorder.class); rolloutsListViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links"); - rolloutsListViewLink.setDescription(i18n.get("message.rollouts")); - rolloutsListViewLink.setCaption(i18n.get("message.rollouts")); + rolloutsListViewLink.setDescription(i18n.getMessage("message.rollouts")); + rolloutsListViewLink.setCaption(i18n.getMessage("message.rollouts")); rolloutsListViewLink.addClickListener(value -> showRolloutListView()); rolloutNameLink = SPUIComponentProvider.getButton(null, "", "", null, false, null, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListView.java index aa2aeb777..1a4ed8396 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListView.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.rollout.rolloutgrouptargets; import org.eclipse.hawkbit.ui.common.grid.AbstractGridLayout; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.vaadin.spring.events.EventBus.UIEventBus; import com.vaadin.ui.Label; @@ -24,7 +24,7 @@ public class RolloutGroupTargetsListView extends AbstractGridLayout { private final RolloutGroupTargetsCountLabelMessage rolloutGroupTargetsCountLabelMessage; - public RolloutGroupTargetsListView(final UIEventBus eventBus, final I18N i18n, + public RolloutGroupTargetsListView(final UIEventBus eventBus, final VaadinMessageSource i18n, final RolloutUIState rolloutUIState) { super(new RolloutGroupTargetsListHeader(eventBus, i18n, rolloutUIState), new RolloutGroupTargetsListGrid(i18n, eventBus, rolloutUIState)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java index fbeac2502..94b374e73 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java @@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.AuthenticationC import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.CertificateAuthenticationConfigurationItem; import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.GatewaySecurityTokenAuthenticationConfigurationItem; import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.TargetSecurityTokenAuthenticationConfigurationItem; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import com.vaadin.data.Property.ValueChangeEvent; @@ -37,7 +37,7 @@ public class AuthenticationConfigurationView extends BaseConfigurationView private static final long serialVersionUID = 1L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final CertificateAuthenticationConfigurationItem certificateAuthenticationConfigurationItem; @@ -55,7 +55,7 @@ public class AuthenticationConfigurationView extends BaseConfigurationView private CheckBox downloadAnonymousCheckBox; - AuthenticationConfigurationView(final I18N i18n, final TenantConfigurationManagement tenantConfigurationManagement, + AuthenticationConfigurationView(final VaadinMessageSource i18n, final TenantConfigurationManagement tenantConfigurationManagement, final SecurityTokenGenerator securityTokenGenerator) { this.i18n = i18n; this.certificateAuthenticationConfigurationItem = new CertificateAuthenticationConfigurationItem( @@ -81,7 +81,7 @@ public class AuthenticationConfigurationView extends BaseConfigurationView vLayout.setMargin(true); vLayout.setSizeFull(); - final Label headerDisSetType = new Label(i18n.get("configuration.authentication.title")); + final Label headerDisSetType = new Label(i18n.getMessage("configuration.authentication.title")); headerDisSetType.addStyleName("config-panel-header"); vLayout.addComponent(headerDisSetType); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java index bd034720e..3232b6909 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java @@ -14,7 +14,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.TenantMetaData; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -47,7 +47,7 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView { private final Label changeIcon; DefaultDistributionSetTypeLayout(final SystemManagement systemManagement, - final DistributionSetManagement distributionSetManagement, final I18N i18n, + final DistributionSetManagement distributionSetManagement, final VaadinMessageSource i18n, final SpPermissionChecker permChecker) { this.systemManagement = systemManagement; combobox = SPUIComponentProvider.getComboBox(null, "330", null, null, false, "", "label.combobox.tag"); @@ -63,7 +63,7 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView { final VerticalLayout vlayout = new VerticalLayout(); vlayout.setMargin(true); vlayout.setSizeFull(); - final String disSetTypeTitle = i18n.get("configuration.defaultdistributionset.title"); + final String disSetTypeTitle = i18n.getMessage("configuration.defaultdistributionset.title"); final Label headerDisSetType = new Label(disSetTypeTitle); headerDisSetType.addStyleName("config-panel-header"); @@ -75,7 +75,7 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView { hlayout.setSpacing(true); hlayout.setStyleName("config-h-panel"); - final Label configurationLabel = new Label(i18n.get("configuration.defaultdistributionset.select.label")); + final Label configurationLabel = new Label(i18n.getMessage("configuration.defaultdistributionset.select.label")); hlayout.addComponent(configurationLabel); hlayout.setComponentAlignment(configurationLabel, Alignment.MIDDLE_LEFT); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/PollingConfigurationView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/PollingConfigurationView.java index 2af11cf32..ff74b4226 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/PollingConfigurationView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/PollingConfigurationView.java @@ -16,7 +16,7 @@ import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.tenancy.configuration.DurationHelper; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.eclipse.hawkbit.ui.tenantconfiguration.polling.DurationConfigField; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import com.vaadin.ui.Label; @@ -39,7 +39,7 @@ public class PollingConfigurationView extends BaseConfigurationView private Duration tenantPollTime; private Duration tenantOverdueTime; - PollingConfigurationView(final I18N i18n, final ControllerPollProperties controllerPollProperties, + PollingConfigurationView(final VaadinMessageSource i18n, final ControllerPollProperties controllerPollProperties, final TenantConfigurationManagement tenantConfigurationManagement) { this.tenantConfigurationManagement = tenantConfigurationManagement; @@ -71,20 +71,20 @@ public class PollingConfigurationView extends BaseConfigurationView final VerticalLayout vLayout = new VerticalLayout(); vLayout.setMargin(true); - final Label headerDisSetType = new Label(i18n.get("configuration.polling.title")); + final Label headerDisSetType = new Label(i18n.getMessage("configuration.polling.title")); headerDisSetType.addStyleName("config-panel-header"); vLayout.addComponent(headerDisSetType); fieldPollTime = DurationConfigField.builder(UIComponentIdProvider.SYSTEM_CONFIGURATION_POLLING) - .caption(i18n.get("configuration.polling.time")) - .checkBoxTooltip(i18n.get("configuration.polling.custom.value")).range(minDuration, maxDuration) + .caption(i18n.getMessage("configuration.polling.time")) + .checkBoxTooltip(i18n.getMessage("configuration.polling.custom.value")).range(minDuration, maxDuration) .globalDuration(globalPollTime).tenantDuration(tenantPollTime).build(); fieldPollTime.addChangeListener(this); vLayout.addComponent(fieldPollTime); fieldPollingOverdueTime = DurationConfigField.builder(UIComponentIdProvider.SYSTEM_CONFIGURATION_OVERDUE) - .caption(i18n.get("configuration.polling.overduetime")) - .checkBoxTooltip(i18n.get("configuration.polling.custom.value")).range(minDuration, maxDuration) + .caption(i18n.getMessage("configuration.polling.overduetime")) + .checkBoxTooltip(i18n.getMessage("configuration.polling.custom.value")).range(minDuration, maxDuration) .globalDuration(globalOverdueTime).tenantDuration(tenantOverdueTime).build(); fieldPollingOverdueTime.addChangeListener(this); vLayout.addComponent(fieldPollingOverdueTime); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardView.java index afbf5a64d..3a55c2bff 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardView.java @@ -25,7 +25,7 @@ import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem.ConfigurationItemChangeListener; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; @@ -60,7 +60,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements private final PollingConfigurationView pollingConfigurationView; - private final I18N i18n; + private final VaadinMessageSource i18n; private final UiProperties uiProperties; @@ -75,7 +75,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements private Collection customConfigurationViews; @Autowired - TenantConfigurationDashboardView(final I18N i18n, final UiProperties uiProperties, + TenantConfigurationDashboardView(final VaadinMessageSource i18n, final UiProperties uiProperties, final UINotification uINotification, final SystemManagement systemManagement, final DistributionSetManagement distributionSetManagement, final TenantConfigurationManagement tenantConfigurationManagement, @@ -133,14 +133,14 @@ public class TenantConfigurationDashboardView extends CustomComponent implements saveConfigurationBtn = SPUIComponentProvider.getButton(UIComponentIdProvider.SYSTEM_CONFIGURATION_SAVE, "", "", "", true, FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class); saveConfigurationBtn.setEnabled(false); - saveConfigurationBtn.setDescription(i18n.get("configuration.savebutton.tooltip")); + saveConfigurationBtn.setDescription(i18n.getMessage("configuration.savebutton.tooltip")); saveConfigurationBtn.addClickListener(event -> saveConfiguration()); hlayout.addComponent(saveConfigurationBtn); undoConfigurationBtn = SPUIComponentProvider.getButton(UIComponentIdProvider.SYSTEM_CONFIGURATION_CANCEL, "", "", "", true, FontAwesome.UNDO, SPUIButtonStyleSmallNoBorder.class); undoConfigurationBtn.setEnabled(false); - undoConfigurationBtn.setDescription(i18n.get("configuration.cancellbutton.tooltip")); + undoConfigurationBtn.setDescription(i18n.getMessage("configuration.cancellbutton.tooltip")); undoConfigurationBtn.addClickListener(event -> undoConfiguration()); hlayout.addComponent(undoConfigurationBtn); @@ -156,7 +156,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements final boolean isUserInputValid = configurationViews.stream().allMatch(ConfigurationGroup::isUserInputValid); if (!isUserInputValid) { - uINotification.displayValidationError(i18n.get("notification.configuration.save.notpossible")); + uINotification.displayValidationError(i18n.getMessage("notification.configuration.save.notpossible")); return; } configurationViews.forEach(ConfigurationGroup::save); @@ -164,7 +164,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements // More methods saveConfigurationBtn.setEnabled(false); undoConfigurationBtn.setEnabled(false); - uINotification.displaySuccess(i18n.get("notification.configuration.save.successful")); + uINotification.displaySuccess(i18n.getMessage("notification.configuration.save.successful")); } private void undoConfiguration() { 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 3501b36d7..60b7f634d 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 @@ -14,7 +14,7 @@ import java.util.List; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import com.vaadin.ui.VerticalLayout; @@ -26,7 +26,7 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay private static final long serialVersionUID = 1L; - private final I18N i18n; + private final VaadinMessageSource i18n; private final String configurationKey; private final transient TenantConfigurationManagement tenantConfigurationManagement; @@ -41,7 +41,7 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay * configuration value */ public AbstractAuthenticationTenantConfigurationItem(final String configurationKey, - final TenantConfigurationManagement tenantConfigurationManagement, final I18N i18n) { + final TenantConfigurationManagement tenantConfigurationManagement, final VaadinMessageSource i18n) { this.configurationKey = configurationKey; this.tenantConfigurationManagement = tenantConfigurationManagement; this.i18n = i18n; @@ -52,7 +52,7 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay */ protected void init(final String labelText) { setImmediate(true); - addComponent(new LabelBuilder().name(i18n.get(labelText)).buildLabel()); + addComponent(new LabelBuilder().name(i18n.getMessage(labelText)).buildLabel()); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AnonymousDownloadAuthenticationConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AnonymousDownloadAuthenticationConfigurationItem.java index f3e8d76f5..30c7e9c91 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AnonymousDownloadAuthenticationConfigurationItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AnonymousDownloadAuthenticationConfigurationItem.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration.authentication; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; /** * This class represents the UI item for the anonymous download by in the @@ -24,7 +24,7 @@ public class AnonymousDownloadAuthenticationConfigurationItem extends AbstractAu private boolean configurationEnabledChange; public AnonymousDownloadAuthenticationConfigurationItem( - final TenantConfigurationManagement tenantConfigurationManagement, final I18N i18n) { + final TenantConfigurationManagement tenantConfigurationManagement, final VaadinMessageSource i18n) { super(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED, tenantConfigurationManagement, i18n); super.init("label.configuration.anonymous.download"); 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 6937143a5..819e24579 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,7 +12,7 @@ import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -35,7 +35,7 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti private final TextField caRootAuthorityTextField; public CertificateAuthenticationConfigurationItem(final TenantConfigurationManagement tenantConfigurationManagement, - final I18N i18n) { + final VaadinMessageSource i18n) { super(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED, tenantConfigurationManagement, i18n); super.init("label.configuration.auth.header"); 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 48cf132f4..35b262fc3 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 @@ -15,7 +15,7 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T 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.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import com.vaadin.server.FontAwesome; import com.vaadin.ui.Button; @@ -44,7 +44,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac private final VerticalLayout detailLayout; public GatewaySecurityTokenAuthenticationConfigurationItem( - final TenantConfigurationManagement tenantConfigurationManagement, final I18N i18n, + final TenantConfigurationManagement tenantConfigurationManagement, final VaadinMessageSource i18n, final SecurityTokenGenerator securityTokenGenerator) { super(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, tenantConfigurationManagement, i18n); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TargetSecurityTokenAuthenticationConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TargetSecurityTokenAuthenticationConfigurationItem.java index 97d06ec90..e6bf25991 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TargetSecurityTokenAuthenticationConfigurationItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TargetSecurityTokenAuthenticationConfigurationItem.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration.authentication; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; -import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; /** * This class represents the UI item for the target security token section in @@ -24,7 +24,7 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract private boolean configurationEnabledChange; public TargetSecurityTokenAuthenticationConfigurationItem( - final TenantConfigurationManagement tenantConfigurationManagement, final I18N i18n) { + final TenantConfigurationManagement tenantConfigurationManagement, final VaadinMessageSource i18n) { super(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, tenantConfigurationManagement, i18n); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index e433a6dbd..d714dc8f5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.ui.utils; import java.util.Collections; +import java.util.Locale; import java.util.Map; import java.util.TimeZone; @@ -31,6 +32,7 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Table; +import com.vaadin.ui.UI; /** * Common util class. @@ -184,7 +186,7 @@ public final class HawkbitCommonUtil { * @param i18N * @return PollStatusToolTip */ - public static String getPollStatusToolTip(final PollStatus pollStatus, final I18N i18N) { + public static String getPollStatusToolTip(final PollStatus pollStatus, final VaadinMessageSource i18N) { if (pollStatus != null && pollStatus.getLastPollDate() != null && pollStatus.isOverdue()) { final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone(); return "Overdue for " + SPDateTimeUtil.getDurationFormattedString( @@ -306,29 +308,29 @@ public final class HawkbitCommonUtil { * @return message */ public static String createAssignmentMessage(final String tagName, - final AssignmentResult result, final I18N i18n) { + final AssignmentResult result, final VaadinMessageSource i18n) { final StringBuilder formMsg = new StringBuilder(); final int assignedCount = result.getAssigned(); final int alreadyAssignedCount = result.getAlreadyAssigned(); final int unassignedCount = result.getUnassigned(); if (assignedCount == 1) { - formMsg.append(i18n.get("message.target.assigned.one", + formMsg.append(i18n.getMessage("message.target.assigned.one", new Object[] { result.getAssignedEntity().get(0).getName(), tagName })).append("
"); } else if (assignedCount > 1) { - formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, tagName })) + formMsg.append(i18n.getMessage("message.target.assigned.many", new Object[] { assignedCount, tagName })) .append("
"); if (alreadyAssignedCount > 0) { - final String alreadyAssigned = i18n.get("message.target.alreadyAssigned", + final String alreadyAssigned = i18n.getMessage("message.target.alreadyAssigned", new Object[] { alreadyAssignedCount }); formMsg.append(alreadyAssigned).append("
"); } } if (unassignedCount == 1) { - formMsg.append(i18n.get("message.target.unassigned.one", + formMsg.append(i18n.getMessage("message.target.unassigned.one", new Object[] { result.getUnassignedEntity().get(0).getName(), tagName })).append("
"); } else if (unassignedCount > 1) { - formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, tagName })) + formMsg.append(i18n.getMessage("message.target.unassigned.many", new Object[] { unassignedCount, tagName })) .append("
"); } return formMsg.toString(); @@ -506,7 +508,7 @@ public final class HawkbitCommonUtil { * label style * @param id * label id - * @return + * @return formatted string */ public static String getStatusLabelDetailsInString(final String value, final String style, final String id) { final StringBuilder val = new StringBuilder(); @@ -533,4 +535,17 @@ public final class HawkbitCommonUtil { return statusFontIcon.getFontIcon() != null ? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null; } + + /** + * Gets the locale of the current Vaadin UI. If the locale can not be + * determined, the default locale is returned instead. + * + * @return the current locale, never {@code null}. + * @see com.vaadin.ui.UI#getLocale() + * @see java.util.Locale#getDefault() + */ + public static Locale getLocale() { + final UI currentUI = UI.getCurrent(); + return currentUI == null ? Locale.getDefault() : currentUI.getLocale(); + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/I18N.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/I18N.java deleted file mode 100644 index 46ee775a4..000000000 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/I18N.java +++ /dev/null @@ -1,113 +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 - */ -/* - * Copyright 2015 The original authors Licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable - * law or agreed to in writing, software distributed under the License is distributed on an "AS IS" - * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - */ - -/** - * copied and adapted by Bosch Software Innovations GmbH, Germany. - * - * @see https://github.com/peholmst/vaadin4spring/blob/master/addons/i18n/src/main/java/org/vaadin/spring/i18n/I18N.java - */ -package org.eclipse.hawkbit.ui.utils; - -import java.io.Serializable; -import java.util.Locale; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.context.NoSuchMessageException; -import org.springframework.stereotype.Service; - -import com.vaadin.ui.UI; - -/** - * Utility class leveraging Spring Boot auto configuration of - * {@link MessageSource}. - * - */ -@Service -public class I18N implements Serializable { - private static final long serialVersionUID = 1L; - - private static final Logger LOG = LoggerFactory.getLogger(I18N.class); - - private final transient MessageSource source; - - @Autowired - I18N(final MessageSource source) { - this.source = source; - } - - /** - * Tries to resolve the message. - * - * @param code - * the code to lookup up. - * @param args - * Array of arguments that will be filled in for params within - * the message. - * - * @return the resolved message, or the message code if the lookup fails. - * - * @see MessageSource#getMessage(String, Object[], Locale) - * @see #getLocale() - */ - public String get(final String code, final Object... args) { - return getMessage(code, args); - } - - /** - * Tries to resolve the message. - * - * @param code - * the code to lookup up. - * - * @return the resolved message, or the message code if the lookup fails. - * - * @see MessageSource#getMessage(String, Object[], Locale) - * @see #getLocale() - */ - public String get(final String code) { - return getMessage(code, null); - } - - private String getMessage(final String code, final Object[] args) { - try { - return source.getMessage(code, args, getLocale()); - } catch (final NoSuchMessageException ex) { - LOG.error("Failed to retrieve message!", ex); - return code; - } - } - - /** - * Gets the locale of the current Vaadin UI. If the locale can not be - * determinted, the default locale is returned instead. - * - * @return the current locale, never {@code null}. - * @see com.vaadin.ui.UI#getLocale() - * @see java.util.Locale#getDefault() - */ - public Locale getLocale() { - final UI currentUI = UI.getCurrent(); - Locale locale = currentUI == null ? null : currentUI.getLocale(); - if (locale == null) { - locale = Locale.getDefault(); - } - return locale; - } -} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java index 1d1687dda..86071e8e2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java @@ -23,11 +23,6 @@ import com.vaadin.server.WebBrowser; /** * Common Util to get date/time related information. - * - * - * - * - * */ public final class SPDateTimeUtil { @@ -137,7 +132,8 @@ public final class SPDateTimeUtil { * 'year' * @return a formatted string for duration label */ - public static String getDurationFormattedString(final long startMillis, final long endMillis, final I18N i18N) { + public static String getDurationFormattedString(final long startMillis, final long endMillis, + final VaadinMessageSource i18N) { final String formatDuration = DurationFormatUtils.formatPeriod(startMillis, endMillis, DURATION_FORMAT, false, getBrowserTimeZone()); @@ -150,8 +146,8 @@ public final class SPDateTimeUtil { } final int value = Integer.parseInt(split[index]); if (value != 0) { - final String suffix = (value == 1) ? i18N.get(DURATION_I18N.get(index).getSingle()) - : i18N.get(DURATION_I18N.get(index).getPlural()); + final String suffix = (value == 1) ? i18N.getMessage(DURATION_I18N.get(index).getSingle()) + : i18N.getMessage(DURATION_I18N.get(index).getPlural()); formattedDuration.append(value).append(' ').append(suffix); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/VaadinMessageSource.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/VaadinMessageSource.java new file mode 100644 index 000000000..d36b0ae79 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/VaadinMessageSource.java @@ -0,0 +1,65 @@ +/** + * 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.utils; + +import java.io.Serializable; +import java.util.Locale; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.NoSuchMessageException; + +import com.vaadin.ui.UI; + +/** + * Utility class leveraging Spring Boot auto configuration of + * {@link MessageSource} and with Vaadins {@link UI#getLocale()}. + * + */ +public class VaadinMessageSource implements Serializable { + private static final long serialVersionUID = 1L; + + private static final Logger LOG = LoggerFactory.getLogger(VaadinMessageSource.class); + + private final transient MessageSource source; + + /** + * @param source + * from Spring to resolve messages + */ + public VaadinMessageSource(final MessageSource source) { + this.source = source; + } + + /** + * Tries to resolve the message based on + * {@link HawkbitCommonUtil#getLocale()}. Returns message code if fitting + * message could not be found. + * + * @param code + * the code to lookup up. + * @param args + * Array of arguments that will be filled in for params within + * the message. + * + * @return the resolved message, or the message code if the lookup fails. + * + * @see MessageSource#getMessage(String, Object[], Locale) + * @see HawkbitCommonUtil#getLocale() + */ + public String getMessage(final String code, final Object... args) { + try { + return source.getMessage(code, args, HawkbitCommonUtil.getLocale()); + } catch (final NoSuchMessageException ex) { + LOG.error("Failed to retrieve message!", ex); + return code; + } + } +}