improve code quality
Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
@@ -18,7 +18,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -90,18 +89,15 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
|
||||
@Autowired
|
||||
private ManagementViewAcceptCriteria managementViewAcceptCriteria;
|
||||
|
||||
|
||||
@Autowired
|
||||
private transient TargetManagement targetService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||
|
||||
@Autowired
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
|
||||
private String notAllowedMsg;
|
||||
|
||||
@@ -229,27 +225,26 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
|
||||
@Override
|
||||
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
||||
HorizontalLayout iconLayout = new HorizontalLayout();
|
||||
final HorizontalLayout iconLayout = new HorizontalLayout();
|
||||
final String nameVersionStr = getNameAndVerion(itemId);
|
||||
final Button manageMetaDataBtn = createManageMetadataButton(nameVersionStr);
|
||||
manageMetaDataBtn.addClickListener(event -> showMetadataDetails(itemId));
|
||||
iconLayout.addComponent((Button)getPinButton(itemId));
|
||||
iconLayout.addComponent((Button) getPinButton(itemId));
|
||||
iconLayout.addComponent(manageMetaDataBtn);
|
||||
return iconLayout;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getNameAndVerion(final Object itemId) {
|
||||
final Item item = getItem(itemId);
|
||||
final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
|
||||
final String version = (String) item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue();
|
||||
return name + "." + version;
|
||||
}
|
||||
|
||||
private Button createManageMetadataButton(String nameVersionStr) {
|
||||
|
||||
private Button createManageMetadataButton(final String nameVersionStr) {
|
||||
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
|
||||
SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
|
||||
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
||||
@@ -281,9 +276,9 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
@Override
|
||||
protected void publishEntityAfterValueChange(final DistributionSet selectedLastEntity) {
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
|
||||
if(selectedLastEntity!=null){
|
||||
managementUIState.setLastSelectedDistribution(new DistributionSetIdName(selectedLastEntity.getId(),
|
||||
selectedLastEntity.getName(),selectedLastEntity.getVersion()));
|
||||
if (selectedLastEntity != null) {
|
||||
managementUIState.setLastSelectedDistribution(new DistributionSetIdName(selectedLastEntity.getId(),
|
||||
selectedLastEntity.getName(), selectedLastEntity.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,8 +529,8 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
}
|
||||
}
|
||||
|
||||
private String getPinnedDistributionStyle(final Long installedDistItemIds, final Long assignedDistTableItemIds,
|
||||
final Object itemId) {
|
||||
private static String getPinnedDistributionStyle(final Long installedDistItemIds,
|
||||
final Long assignedDistTableItemIds, final Object itemId) {
|
||||
final Long distId = ((DistributionSetIdName) itemId).getId();
|
||||
if (distId != null && distId.equals(installedDistItemIds)) {
|
||||
return SPUIDefinitions.HIGHTLIGHT_GREEN;
|
||||
@@ -602,7 +597,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
resetPinStyle(eventBtn);
|
||||
}
|
||||
|
||||
private void resetPinStyle(final Button pinBtn) {
|
||||
private static void resetPinStyle(final Button pinBtn) {
|
||||
pinBtn.setStyleName(getPinStyle());
|
||||
}
|
||||
|
||||
@@ -638,14 +633,14 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
});
|
||||
}
|
||||
|
||||
private void applyPinStyle(final Button eventBtn) {
|
||||
private static void applyPinStyle(final Button eventBtn) {
|
||||
final StringBuilder style = new StringBuilder(SPUIComponentProvider.getPinButtonStyle());
|
||||
style.append(' ').append(SPUIStyleDefinitions.DIST_PIN).append(' ').append("tablePin").append(' ')
|
||||
.append("pin-icon-red");
|
||||
eventBtn.setStyleName(style.toString());
|
||||
}
|
||||
|
||||
private String getPinButtonId(final String distName, final String distVersion) {
|
||||
private static String getPinButtonId(final String distName, final String distVersion) {
|
||||
final StringBuilder pinBtnId = new StringBuilder(SPUIComponentIdProvider.DIST_PIN_BUTTON);
|
||||
pinBtnId.append('.');
|
||||
pinBtnId.append(distName);
|
||||
@@ -654,7 +649,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
return pinBtnId.toString();
|
||||
}
|
||||
|
||||
private Button getPinBtn(final Object itemId, final String distName, final String distVersion) {
|
||||
private static Button getPinBtn(final Object itemId, final String distName, final String distVersion) {
|
||||
final Button pinBtn = new Button();
|
||||
pinBtn.setIcon(FontAwesome.THUMB_TACK);
|
||||
pinBtn.setHeightUndefined();
|
||||
@@ -665,7 +660,7 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
return pinBtn;
|
||||
}
|
||||
|
||||
private String getPinStyle() {
|
||||
private static String getPinStyle() {
|
||||
final StringBuilder pinBtnStyle = new StringBuilder(SPUIComponentProvider.getPinButtonStyle());
|
||||
pinBtnStyle.append(' ');
|
||||
pinBtnStyle.append(SPUIStyleDefinitions.DIST_PIN);
|
||||
@@ -696,11 +691,11 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
managementUIState.setNoDataAvailableDistribution(!available);
|
||||
|
||||
}
|
||||
|
||||
private void showMetadataDetails(Object itemId) {
|
||||
|
||||
private void showMetadataDetails(final Object itemId) {
|
||||
final DistributionSetIdName distIdName = (DistributionSetIdName) getContainerDataSource().getItem(itemId)
|
||||
.getItemProperty(SPUILabelDefinitions.VAR_DIST_ID_NAME).getValue();
|
||||
DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(distIdName.getId());
|
||||
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(distIdName.getId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user