Modify scope of protected attributes to private.

Create getter/setter to access the  the attribute.

see clean code Protected variables should be avoided because:
http://programmers.stackexchange.com/questions/162643/why-is-clean-code-suggesting-avoiding-protected-variables

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-04-08 15:01:26 +02:00
parent a021630c04
commit 3070dcfc3d
7 changed files with 135 additions and 122 deletions

View File

@@ -52,16 +52,16 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
@Override
protected void addTabs(final TabSheet detailsTab) {
detailsTab.addTab(createDetailsLayout(), i18n.get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), i18n.get("caption.tab.description"), null);
detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null);
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);
}
@Override
protected void onEdit(final ClickEvent event) {
final Window addSoftwareModule = softwareModuleAddUpdateWindow
.createUpdateSoftwareModuleWindow(getSelectedBaseEntityId());
addSoftwareModule.setCaption(i18n.get("upload.caption.update.swmodule"));
addSoftwareModule.setCaption(getI18n().get("upload.caption.update.swmodule"));
UI.getCurrent().addWindow(addSoftwareModule);
addSoftwareModule.setVisible(Boolean.TRUE);
}
@@ -69,14 +69,14 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
@Override
protected void populateDetailsWidget() {
String maxAssign = HawkbitCommonUtil.SP_STRING_EMPTY;
if (selectedBaseEntity != null) {
if (selectedBaseEntity.getType().getMaxAssignments() == Integer.MAX_VALUE) {
maxAssign = i18n.get("label.multiAssign.type");
if (getSelectedBaseEntity() != null) {
if (getSelectedBaseEntity().getType().getMaxAssignments() == Integer.MAX_VALUE) {
maxAssign = getI18n().get("label.multiAssign.type");
} else {
maxAssign = i18n.get("label.singleAssign.type");
maxAssign = getI18n().get("label.singleAssign.type");
}
updateSoftwareModuleDetailsLayout(selectedBaseEntity.getType().getName(), selectedBaseEntity.getVendor(),
maxAssign);
updateSoftwareModuleDetailsLayout(getSelectedBaseEntity().getType().getName(),
getSelectedBaseEntity().getVendor(), maxAssign);
} else {
updateSoftwareModuleDetailsLayout(HawkbitCommonUtil.SP_STRING_EMPTY, HawkbitCommonUtil.SP_STRING_EMPTY,
maxAssign);
@@ -88,19 +88,19 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
detailsTabLayout.removeAllComponents();
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.vendor"),
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"),
HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor);
vendorLabel.setId(SPUIComponetIdProvider.DETAILS_VENDOR_LABEL_ID);
detailsTabLayout.addComponent(vendorLabel);
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.assigned.type"),
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"),
HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign);
assignLabel.setId(SPUIComponetIdProvider.SWM_DTLS_MAX_ASSIGN);
detailsTabLayout.addComponent(assignLabel);
@@ -109,7 +109,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
@Override
protected String getDefaultCaption() {
return i18n.get("upload.swModuleTable.header");
return getI18n().get("upload.swModuleTable.header");
}
@Override
@@ -129,7 +129,7 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
return getPermissionChecker().hasUpdateDistributionPermission();
}
@Override

View File

@@ -22,6 +22,7 @@ public abstract class AbstractNamedVersionedEntityTableDetailsLayout<T extends N
@Override
protected String getName() {
return HawkbitCommonUtil.getFormattedNameVersion(selectedBaseEntity.getName(), selectedBaseEntity.getVersion());
return HawkbitCommonUtil.getFormattedNameVersion(getSelectedBaseEntity().getName(),
getSelectedBaseEntity().getVersion());
}
}

View File

@@ -49,15 +49,15 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
private static final long serialVersionUID = 4862529368471627190L;
@Autowired
protected I18N i18n;
private I18N i18n;
@Autowired
protected transient EventBus.SessionEventBus eventBus;
private transient EventBus.SessionEventBus eventBus;
@Autowired
protected SpPermissionChecker permissionChecker;
private SpPermissionChecker permissionChecker;
protected T selectedBaseEntity;
private T selectedBaseEntity;
private Label caption;
@@ -89,6 +89,26 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
eventBus.unsubscribe(this);
}
protected SpPermissionChecker getPermissionChecker() {
return permissionChecker;
}
protected EventBus.SessionEventBus getEventBus() {
return eventBus;
}
protected I18N getI18n() {
return i18n;
}
protected T getSelectedBaseEntity() {
return selectedBaseEntity;
}
public void setSelectedBaseEntity(final T selectedBaseEntity) {
this.selectedBaseEntity = selectedBaseEntity;
}
/**
* Default implementation to handle a entity event.
*
@@ -118,7 +138,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
editButton = SPUIComponentProvider.getButton("", "", "", null, false, FontAwesome.PENCIL_SQUARE_O,
SPUIButtonStyleSmallNoBorder.class);
editButton.setId(getEditButtonId());
editButton.addClickListener(event -> onEdit(event));
editButton.addClickListener(this::onEdit);
editButton.setEnabled(false);

View File

@@ -92,7 +92,8 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
@Override
protected void init() {
softwareModuleTable = new SoftwareModuleDetailsTable();
softwareModuleTable.init(i18n, true, permissionChecker, distributionSetManagement, eventBus, manageDistUIState);
softwareModuleTable.init(getI18n(), true, getPermissionChecker(), distributionSetManagement, getEventBus(),
manageDistUIState);
super.init();
}
@@ -109,7 +110,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
}
private void populateModule() {
softwareModuleTable.populateModule(selectedBaseEntity);
softwareModuleTable.populateModule(getSelectedBaseEntity());
showUnsavedAssignment();
}
@@ -157,12 +158,8 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
}
}
/**
* @param item
* @param entry
*/
private void assignSoftModuleButton(final Item item, final Map.Entry<String, StringBuilder> entry) {
if (permissionChecker.hasUpdateDistributionPermission() && distributionSetManagement
if (getPermissionChecker().hasUpdateDistributionPermission() && distributionSetManagement
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
.getAssignedTargets().isEmpty()) {
final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true,
@@ -227,15 +224,16 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
private void populateTags() {
tagsLayout.removeAllComponents();
if (null != selectedBaseEntity) {
tagsLayout.addComponent(distributionTagToken.getTokenField());
if (getSelectedBaseEntity() == null) {
return;
}
tagsLayout.addComponent(distributionTagToken.getTokenField());
}
private void populateDetails() {
if (selectedBaseEntity != null) {
updateDistributionSetDetailsLayout(selectedBaseEntity.getType().getName(),
selectedBaseEntity.isRequiredMigrationStep());
if (getSelectedBaseEntity() != null) {
updateDistributionSetDetailsLayout(getSelectedBaseEntity().getType().getName(),
getSelectedBaseEntity().isRequiredMigrationStep());
} else {
updateDistributionSetDetailsLayout(null, null);
}
@@ -246,16 +244,16 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
detailsTabLayout.removeAllComponents();
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
if (isMigrationRequired != null) {
detailsTabLayout.addComponent(
SPUIComponentProvider.createNameValueLabel(i18n.get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no")));
detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel(
getI18n().get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? getI18n().get("label.yes") : getI18n().get("label.no")));
}
}
@@ -263,7 +261,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
protected void onEdit(final ClickEvent event) {
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow();
distributionAddUpdateWindowLayout.populateValuesOfDistribution(getSelectedBaseEntityId());
newDistWindow.setCaption(i18n.get("caption.update.dist"));
newDistWindow.setCaption(getI18n().get("caption.update.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
}
@@ -286,21 +284,21 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
@Override
protected String getDefaultCaption() {
return i18n.get("distribution.details.header");
return getI18n().get("distribution.details.header");
}
@Override
protected void addTabs(final TabSheet detailsTab) {
detailsTab.addTab(createDetailsLayout(), i18n.get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), i18n.get("caption.tab.description"), null);
detailsTab.addTab(createSoftwareModuleTab(), i18n.get("caption.softwares.distdetail.tab"), null);
detailsTab.addTab(createTagsLayout(), i18n.get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null);
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);
}
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
return getPermissionChecker().hasUpdateDistributionPermission();
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -322,9 +320,9 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
final DistributionSetIdName distIdName = softwareModuleAssignmentDiscardEvent
.getDistributionSetIdName();
if (distIdName.getId().equals(getSelectedBaseEntityId())
&& distIdName.getName().equals(selectedBaseEntity.getName())) {
selectedBaseEntity = distributionSetManagement
.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
&& distIdName.getName().equals(getSelectedBaseEntity().getName())) {
setSelectedBaseEntity(
distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()));
populateModule();
}
});
@@ -335,10 +333,10 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
void onEvent(final SaveActionWindowEvent saveActionWindowEvent) {
if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS)
&& selectedBaseEntity != null) {
&& getSelectedBaseEntity() != null) {
assignedSWModule.clear();
selectedBaseEntity = distributionSetManagement
.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
setSelectedBaseEntity(
distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()));
UI.getCurrent().access(() -> populateModule());
}
}

View File

@@ -54,7 +54,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
protected void onEdit(final ClickEvent event) {
final Window addSoftwareModule = softwareModuleAddUpdateWindow
.createUpdateSoftwareModuleWindow(getSelectedBaseEntityId());
addSoftwareModule.setCaption(i18n.get("upload.caption.update.swmodule"));
addSoftwareModule.setCaption(getI18n().get("upload.caption.update.swmodule"));
UI.getCurrent().addWindow(addSoftwareModule);
addSoftwareModule.setVisible(Boolean.TRUE);
}
@@ -66,14 +66,14 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
@Override
protected void addTabs(final TabSheet detailsTab) {
detailsTab.addTab(createDetailsLayout(), i18n.get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), i18n.get("caption.tab.description"), null);
detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null);
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);
}
@Override
protected String getDefaultCaption() {
return i18n.get("upload.swModuleTable.header");
return getI18n().get("upload.swModuleTable.header");
}
@Override
@@ -88,7 +88,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
return getPermissionChecker().hasUpdateDistributionPermission();
}
@Override
@@ -98,14 +98,14 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
private void populateDetails() {
String maxAssign = HawkbitCommonUtil.SP_STRING_EMPTY;
if (selectedBaseEntity != null) {
if (selectedBaseEntity.getType().getMaxAssignments() == Integer.MAX_VALUE) {
maxAssign = i18n.get("label.multiAssign.type");
if (getSelectedBaseEntity() != null) {
if (getSelectedBaseEntity().getType().getMaxAssignments() == Integer.MAX_VALUE) {
maxAssign = getI18n().get("label.multiAssign.type");
} else {
maxAssign = i18n.get("label.singleAssign.type");
maxAssign = getI18n().get("label.singleAssign.type");
}
updateSwModuleDetailsLayout(selectedBaseEntity.getType().getName(), selectedBaseEntity.getVendor(),
maxAssign);
updateSwModuleDetailsLayout(getSelectedBaseEntity().getType().getName(),
getSelectedBaseEntity().getVendor(), maxAssign);
} else {
updateSwModuleDetailsLayout(HawkbitCommonUtil.SP_STRING_EMPTY, HawkbitCommonUtil.SP_STRING_EMPTY,
maxAssign);
@@ -117,19 +117,19 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay
final VerticalLayout detailsTabLayout = getDetailsLayout();
detailsTabLayout.removeAllComponents();
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.vendor"),
final Label vendorLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.vendor"),
HawkbitCommonUtil.trimAndNullIfEmpty(vendor) == null ? "" : vendor);
vendorLabel.setId(SPUIComponetIdProvider.DETAILS_VENDOR_LABEL_ID);
detailsTabLayout.addComponent(vendorLabel);
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.assigned.type"),
final Label assignLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.assigned.type"),
HawkbitCommonUtil.trimAndNullIfEmpty(maxAssign) == null ? "" : maxAssign);
assignLabel.setId(SPUIComponetIdProvider.SWM_DTLS_MAX_ASSIGN);
detailsTabLayout.addComponent(assignLabel);

View File

@@ -52,7 +52,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Override
protected void init() {
softwareModuleTable = new SoftwareModuleDetailsTable();
softwareModuleTable.init(i18n, false, permissionChecker, null, null, null);
softwareModuleTable.init(getI18n(), false, getPermissionChecker(), null, null, null);
super.init();
}
@@ -63,23 +63,23 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Override
protected String getDefaultCaption() {
return i18n.get("distribution.details.header");
return getI18n().get("distribution.details.header");
}
@Override
protected void addTabs(final TabSheet detailsTab) {
detailsTab.addTab(createDetailsLayout(), i18n.get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), i18n.get("caption.tab.description"), null);
detailsTab.addTab(createSoftwareModuleTab(), i18n.get("caption.softwares.distdetail.tab"), null);
detailsTab.addTab(createTagsLayout(), i18n.get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null);
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);
}
@Override
protected void onEdit(final ClickEvent event) {
final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow();
distributionAddUpdateWindowLayout.populateValuesOfDistribution(getSelectedBaseEntityId());
newDistWindow.setCaption(i18n.get("caption.update.dist"));
newDistWindow.setCaption(getI18n().get("caption.update.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
}
@@ -102,7 +102,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateDistributionPermission();
return getPermissionChecker().hasUpdateDistributionPermission();
}
@Override
@@ -112,8 +112,8 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
@Override
protected void populateDetailsWidget() {
softwareModuleTable.populateModule(selectedBaseEntity);
populateDetails(selectedBaseEntity);
softwareModuleTable.populateModule(getSelectedBaseEntity());
populateDetails(getSelectedBaseEntity());
}
@@ -130,16 +130,16 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
detailsTabLayout.removeAllComponents();
if (type != null) {
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.type"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.type"),
type);
typeLabel.setId(SPUIComponetIdProvider.DETAILS_TYPE_LABEL_ID);
detailsTabLayout.addComponent(typeLabel);
}
if (isMigrationRequired != null) {
detailsTabLayout.addComponent(
SPUIComponentProvider.createNameValueLabel(i18n.get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no")));
detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel(
getI18n().get("checkbox.dist.migration.required"),
isMigrationRequired.equals(Boolean.TRUE) ? getI18n().get("label.yes") : getI18n().get("label.no")));
}
}

View File

@@ -43,9 +43,6 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Target details layout.
*
*
*
*/
@SpringComponent
@ViewScope
@@ -65,9 +62,6 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
private VerticalLayout assignedDistLayout;
private VerticalLayout installedDistLayout;
/**
* Initialize the Target details.
*/
@Override
public void init() {
super.init();
@@ -76,18 +70,18 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
@Override
protected String getDefaultCaption() {
return i18n.get("target.details.header");
return getI18n().get("target.details.header");
}
@Override
protected void addTabs(final TabSheet detailsTab) {
detailsTab.addTab(createDetailsLayout(), i18n.get("caption.tab.details"), null);
detailsTab.addTab(createDescriptionLayout(), i18n.get("caption.tab.description"), null);
detailsTab.addTab(createAttributesLayout(), i18n.get("caption.attributes.tab"), null);
detailsTab.addTab(createAssignedDistLayout(), i18n.get("header.target.assigned"), null);
detailsTab.addTab(createInstalledDistLayout(), i18n.get("header.target.installed"), null);
detailsTab.addTab(createTagsLayout(), i18n.get("caption.tags.tab"), null);
detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null);
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);
}
@@ -109,12 +103,12 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
@Override
protected void onEdit(final ClickEvent event) {
if (selectedBaseEntity == null) {
if (getSelectedBaseEntity() == null) {
return;
}
final Window newDistWindow = targetAddUpdateWindowLayout.getWindow();
targetAddUpdateWindowLayout.populateValuesOfTarget(selectedBaseEntity.getControllerId());
newDistWindow.setCaption(i18n.get("caption.update.dist"));
targetAddUpdateWindowLayout.populateValuesOfTarget(getSelectedBaseEntity().getControllerId());
newDistWindow.setCaption(getI18n().get("caption.update.dist"));
UI.getCurrent().addWindow(newDistWindow);
newDistWindow.setVisible(Boolean.TRUE);
}
@@ -136,24 +130,24 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
@Override
protected void populateDetailsWidget() {
if (selectedBaseEntity != null) {
updateDetailsLayout(selectedBaseEntity.getControllerId(), selectedBaseEntity.getTargetInfo().getAddress(),
selectedBaseEntity.getSecurityToken(),
SPDateTimeUtil.getFormattedDate(selectedBaseEntity.getTargetInfo().getLastTargetQuery()));
if (getSelectedBaseEntity() != null) {
updateDetailsLayout(getSelectedBaseEntity().getControllerId(),
getSelectedBaseEntity().getTargetInfo().getAddress(), getSelectedBaseEntity().getSecurityToken(),
SPDateTimeUtil.getFormattedDate(getSelectedBaseEntity().getTargetInfo().getLastTargetQuery()));
populateDistributionDtls(installedDistLayout,
selectedBaseEntity.getTargetInfo().getInstalledDistributionSet());
populateDistributionDtls(assignedDistLayout, selectedBaseEntity.getAssignedDistributionSet());
getSelectedBaseEntity().getTargetInfo().getInstalledDistributionSet());
populateDistributionDtls(assignedDistLayout, getSelectedBaseEntity().getAssignedDistributionSet());
} else {
updateDetailsLayout(null, null, null, null);
populateDistributionDtls(installedDistLayout, null);
populateDistributionDtls(assignedDistLayout, null);
}
updateAttributesLayout(selectedBaseEntity);
updateAttributesLayout(getSelectedBaseEntity());
}
@Override
protected String getName() {
return selectedBaseEntity.getName();
return getSelectedBaseEntity().getName();
}
private void updateDetailsLayout(final String controllerId, final URI address, final String securityToken,
@@ -161,17 +155,18 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
final VerticalLayout detailsTabLayout = getDetailsLayout();
detailsTabLayout.removeAllComponents();
final Label controllerLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.target.id"),
final Label controllerLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.target.id"),
HawkbitCommonUtil.trimAndNullIfEmpty(controllerId) == null ? "" : controllerId);
controllerLabel.setId(SPUIComponetIdProvider.TARGET_CONTROLLER_ID);
detailsTabLayout.addComponent(controllerLabel);
final Label lastPollDtLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.target.lastpolldate"),
final Label lastPollDtLabel = SPUIComponentProvider.createNameValueLabel(
getI18n().get("label.target.lastpolldate"),
HawkbitCommonUtil.trimAndNullIfEmpty(lastQueryDate) == null ? "" : lastQueryDate);
lastPollDtLabel.setId(SPUIComponetIdProvider.TARGET_LAST_QUERY_DT);
detailsTabLayout.addComponent(lastPollDtLabel);
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(i18n.get("label.ip"),
final Label typeLabel = SPUIComponentProvider.createNameValueLabel(getI18n().get("label.ip"),
address == null ? StringUtils.EMPTY : address.toString());
typeLabel.setId(SPUIComponetIdProvider.TARGET_IP_ADDRESS);
detailsTabLayout.addComponent(typeLabel);
@@ -187,7 +182,7 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
final HorizontalLayout securityTokenLayout = new HorizontalLayout();
final Label securityTableLbl = new Label(
SPUIComponentProvider.getBoldHTMLText(i18n.get("label.target.security.token")), ContentMode.HTML);
SPUIComponentProvider.getBoldHTMLText(getI18n().get("label.target.security.token")), ContentMode.HTML);
securityTableLbl.addStyleName(SPUIDefinitions.TEXT_STYLE);
securityTableLbl.addStyleName("label-style");
@@ -207,18 +202,17 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
private void populateDistributionDtls(final VerticalLayout layout, final DistributionSet distributionSet) {
layout.removeAllComponents();
if (distributionSet != null) {
// Display distribution set name
layout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.name"),
distributionSet.getName()));
layout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.dist.details.version"),
distributionSet.getVersion()));
/* Module info */
distributionSet.getModules()
.forEach(module -> layout.addComponent(getSWModlabel(module.getType().getName(), module)));
if (distributionSet == null) {
return;
}
layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.name"),
distributionSet.getName()));
layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().get("label.dist.details.version"),
distributionSet.getVersion()));
distributionSet.getModules()
.forEach(module -> layout.addComponent(getSWModlabel(module.getType().getName(), module)));
}
/**
@@ -236,7 +230,7 @@ public class TargetDetails extends AbstractTableDetailsLayout<Target> {
@Override
protected Boolean hasEditPermission() {
return permissionChecker.hasUpdateTargetPermission();
return getPermissionChecker().hasUpdateTargetPermission();
}
@EventBusListenerMethod(scope = EventScope.SESSION)