Sonar fix moving private methods to inner classes

- Rule: "private" methods called only by inner classes should be moved to those classes 

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
Jonathan Philip Knoblauch
2016-03-31 15:08:20 +02:00
parent 3f4788d60e
commit 1d416327d6
7 changed files with 199 additions and 231 deletions

View File

@@ -215,13 +215,18 @@ public class UploadLayout extends VerticalLayout {
hasDirectory = Boolean.TRUE; hasDirectory = Boolean.TRUE;
} }
} }
}
private static boolean isDirectory(final Html5File file) { private StreamVariable createStreamVariable(final Html5File file) {
if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) { return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this, uploadInfoWindow,
return true; spInfo.getMaxArtifactFileSize(), null, file.getType());
}
private boolean isDirectory(final Html5File file) {
if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) {
return true;
}
return false;
} }
return false;
} }
private void displayCompositeMessage() { private void displayCompositeMessage() {
@@ -282,11 +287,6 @@ public class UploadLayout extends VerticalLayout {
discardBtn.addClickListener(event -> discardUploadData(event)); discardBtn.addClickListener(event -> discardUploadData(event));
} }
private StreamVariable createStreamVariable(final Html5File file) {
return new UploadHandler(file.getFileName(), file.getFileSize(), this, uploadInfoWindow,
spInfo.getMaxArtifactFileSize(), null, file.getType());
}
boolean checkForDuplicate(final String filename) { boolean checkForDuplicate(final String filename) {
final Boolean isDuplicate = checkIfFileIsDuplicate(filename); final Boolean isDuplicate = checkIfFileIsDuplicate(filename);
if (isDuplicate) { if (isDuplicate) {
@@ -349,17 +349,17 @@ public class UploadLayout extends VerticalLayout {
} }
} }
Boolean validate(DragAndDropEvent event) { Boolean validate(final DragAndDropEvent event) {
// check if drop is valid.If valid ,check if software module is // check if drop is valid.If valid ,check if software module is
// selected. // selected.
if(!isFilesDropped(event)){ if (!isFilesDropped(event)) {
uiNotification.displayValidationError(i18n.get("message.action.not.allowed")); uiNotification.displayValidationError(i18n.get("message.action.not.allowed"));
return false; return false;
} }
return checkIfSoftwareModuleIsSelected(); return checkIfSoftwareModuleIsSelected();
} }
private boolean isFilesDropped(DragAndDropEvent event) { private boolean isFilesDropped(final DragAndDropEvent event) {
if (event.getTransferable() instanceof WrapperTransferable) { if (event.getTransferable() instanceof WrapperTransferable) {
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
// other components can also be wrapped in WrapperTransferable , so // other components can also be wrapped in WrapperTransferable , so
@@ -448,7 +448,7 @@ public class UploadLayout extends VerticalLayout {
} }
private String getDuplicateFileValidationMessage() { private String getDuplicateFileValidationMessage() {
StringBuilder message = new StringBuilder(); final StringBuilder message = new StringBuilder();
if (!duplicateFileNamesList.isEmpty()) { if (!duplicateFileNamesList.isEmpty()) {
final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList); final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList);
if (duplicateFileNamesList.size() == 1) { if (duplicateFileNamesList.size() == 1) {
@@ -655,8 +655,7 @@ public class UploadLayout extends VerticalLayout {
return uiNotification; return uiNotification;
} }
public void setHasDirectory(final Boolean hasDirectory) {
public void setHasDirectory(Boolean hasDirectory) {
this.hasDirectory = hasDirectory; this.hasDirectory = hasDirectory;
} }
} }

View File

@@ -151,18 +151,25 @@ public abstract class AbstractTagToken implements Serializable {
} }
} }
} private void updateTokenStyle(final Object tokenId, final Button button) {
final String color = getColor(tokenId);
button.setCaption("<span style=\"color:" + color + " !important;\">" + FontAwesome.CIRCLE.getHtml()
+ "</span>" + " " + getItemNameProperty(tokenId).getValue().toString().concat(" ×"));
button.setCaptionAsHtml(true);
}
private void updateTokenStyle(final Object tokenId, final Button button) { private void onTokenSearch(final Object tokenId) {
final String color = getColor(tokenId); assignTag(getItemNameProperty(tokenId).getValue().toString());
button.setCaption("<span style=\"color:" + color + " !important;\">" + FontAwesome.CIRCLE.getHtml() + "</span>" removeTagAssignedFromCombo((Long) tokenId);
+ " " + getItemNameProperty(tokenId).getValue().toString().concat(" ×")); }
button.setCaptionAsHtml(true);
} private void tokenClick(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().addItem(tokenId);
item.getItemProperty("name").setValue(tagDetails.get(tokenId).getName());
item.getItemProperty(COLOR_PROPERTY).setValue(tagDetails.get(tokenId).getColor());
unassignTag(tagDetails.get(tokenId).getName());
}
private void onTokenSearch(final Object tokenId) {
assignTag(getItemNameProperty(tokenId).getValue().toString());
removeTagAssignedFromCombo((Long) tokenId);
} }
private Property getItemNameProperty(final Object tokenId) { private Property getItemNameProperty(final Object tokenId) {
@@ -184,13 +191,6 @@ public abstract class AbstractTagToken implements Serializable {
return (String) item.getItemProperty("name").getValue(); return (String) item.getItemProperty("name").getValue();
} }
private void tokenClick(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().addItem(tokenId);
item.getItemProperty("name").setValue(tagDetails.get(tokenId).getName());
item.getItemProperty(COLOR_PROPERTY).setValue(tagDetails.get(tokenId).getColor());
unassignTag(tagDetails.get(tokenId).getName());
}
protected void removePreviouslyAddedTokens() { protected void removePreviouslyAddedTokens() {
tokensAdded.keySet().forEach(previouslyAddedToken -> tokenField.removeToken(previouslyAddedToken)); tokensAdded.keySet().forEach(previouslyAddedToken -> tokenField.removeToken(previouslyAddedToken));
} }

View File

@@ -63,14 +63,10 @@ import com.vaadin.ui.Upload.SucceededListener;
/** /**
* Bulk target upload handler. * Bulk target upload handler.
*
*/ */
public class BulkUploadHandler extends CustomComponent public class BulkUploadHandler extends CustomComponent
implements SucceededListener, FailedListener, Receiver, StartedListener { implements SucceededListener, FailedListener, Receiver, StartedListener {
/**
*
*/
private static final long serialVersionUID = -1273494705754674501L; private static final long serialVersionUID = -1273494705754674501L;
private static final Logger LOG = LoggerFactory.getLogger(BulkUploadHandler.class); private static final Logger LOG = LoggerFactory.getLogger(BulkUploadHandler.class);
@@ -149,12 +145,6 @@ public class BulkUploadHandler extends CustomComponent
setCompositionRoot(horizontalLayout); setCompositionRoot(horizontalLayout);
} }
/*
* (non-Javadoc)
*
* @see com.vaadin.ui.Upload.Receiver#receiveUpload(java.lang.String,
* java.lang.String)
*/
@Override @Override
public OutputStream receiveUpload(final String filename, final String mimeType) { public OutputStream receiveUpload(final String filename, final String mimeType) {
try { try {
@@ -170,25 +160,11 @@ public class BulkUploadHandler extends CustomComponent
return new NullOutputStream(); return new NullOutputStream();
} }
/*
* (non-Javadoc)
*
* @see
* com.vaadin.ui.Upload.FailedListener#uploadFailed(com.vaadin.ui.Upload.
* FailedEvent)
*/
@Override @Override
public void uploadFailed(final FailedEvent event) { public void uploadFailed(final FailedEvent event) {
LOG.info("Upload failed for file :{} due to {}", event.getFilename(), event.getReason()); LOG.info("Upload failed for file :{} due to {}", event.getFilename(), event.getReason());
} }
/*
* (non-Javadoc)
*
* @see
* com.vaadin.ui.Upload.SucceededListener#uploadSucceeded(com.vaadin.ui.
* Upload.SucceededEvent)
*/
@Override @Override
public void uploadSucceeded(final SucceededEvent event) { public void uploadSucceeded(final SucceededEvent event) {
executor.execute(new UploadAsync(event)); executor.execute(new UploadAsync(event));
@@ -252,6 +228,61 @@ public class BulkUploadHandler extends CustomComponent
} }
} }
private double getTotalNumberOfLines() {
double totalFileSize = 0;
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(tempFile),
Charset.defaultCharset())) {
try (BufferedReader readerForSize = new BufferedReader(inputStreamReader)) {
totalFileSize = readerForSize.lines().count();
}
} catch (final FileNotFoundException e) {
LOG.error("Error reading file {}", tempFile.getName(), e);
} catch (final IOException e) {
LOG.error("Error while closing reader of file {}", tempFile.getName(), e);
}
return totalFileSize;
}
private void resetCounts() {
successfullTargetCount = 0;
failedTargetCount = 0;
}
private void deleteFile() {
if (tempFile.exists()) {
final boolean isDeleted = tempFile.delete();
if (!isDeleted) {
LOG.info("File {} was not deleted !", tempFile.getName());
}
}
tempFile = null;
}
private void readEachLine(final String line, final double innerCounter, final double totalFileSize) {
final String csvDelimiter = ",";
final String[] targets = line.split(csvDelimiter);
if (targets.length == 2) {
final String controllerId = targets[0];
final String targetName = targets[1];
addNewTarget(controllerId, targetName);
} else {
failedTargetCount++;
}
final float current = managementUIState.getTargetTableFilters().getBulkUpload()
.getProgressBarCurrentValue();
final float next = (float) (innerCounter / totalFileSize);
if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05
|| Math.abs(next - 1) < 0.00001) {
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next);
managementUIState.getTargetTableFilters().getBulkUpload()
.setSucessfulUploadCount(successfullTargetCount);
managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(failedTargetCount);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
}
}
private void doAssignments() { private void doAssignments() {
final StringBuilder errorMessage = new StringBuilder(); final StringBuilder errorMessage = new StringBuilder();
String dsAssignmentFailedMsg = null; String dsAssignmentFailedMsg = null;
@@ -267,6 +298,43 @@ public class BulkUploadHandler extends CustomComponent
displayValidationMessage(errorMessage, dsAssignmentFailedMsg, tagAssignmentFailedMsg); displayValidationMessage(errorMessage, dsAssignmentFailedMsg, tagAssignmentFailedMsg);
} }
private String saveAllAssignments() {
final ActionType actionType = ActionType.FORCED;
final long forcedTimeStamp = new Date().getTime();
final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload();
final List<String> targetsList = targetBulkUpload.getTargetsCreated();
final DistributionSetIdName dsSelected = (DistributionSetIdName) comboBox.getValue();
if (distributionSetManagement.findDistributionSetById(dsSelected.getId()) == null) {
return i18n.get("message.bulk.upload.assignment.failed");
} else {
deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion().getId(), actionType,
forcedTimeStamp, targetsList.toArray(new String[targetsList.size()]));
return null;
}
}
private String tagAssignment() {
final Map<Long, TagData> tokensSelected = targetBulkTokenTags.getTokensAdded();
final List<String> deletedTags = new ArrayList<>();
for (final TagData tagData : tokensSelected.values()) {
if (tagManagement.findTargetTagById(tagData.getId()) == null) {
deletedTags.add(tagData.getName());
} else {
targetManagement.toggleTagAssignment(
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated(),
tagData.getName());
}
}
if (!deletedTags.isEmpty()) {
if (deletedTags.size() == 1) {
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
} else {
return i18n.get("message.bulk.upload.tag.assignments.failed");
}
}
return null;
}
private boolean ifTagsSelected() { private boolean ifTagsSelected() {
return targetBulkTokenTags.getTokenField().getValue() != null; return targetBulkTokenTags.getTokenField().getValue() != null;
} }
@@ -307,59 +375,6 @@ public class BulkUploadHandler extends CustomComponent
} }
} }
private double getTotalNumberOfLines() {
double totalFileSize = 0;
try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(tempFile),
Charset.defaultCharset())) {
try (BufferedReader readerForSize = new BufferedReader(inputStreamReader)) {
totalFileSize = readerForSize.lines().count();
}
} catch (final FileNotFoundException e) {
LOG.error("Error reading file {}", tempFile.getName(), e);
} catch (final IOException e) {
LOG.error("Error while closing reader of file {}", tempFile.getName(), e);
}
return totalFileSize;
}
private void resetCounts() {
successfullTargetCount = 0;
failedTargetCount = 0;
}
private void deleteFile() {
if (tempFile.exists()) {
final boolean isDeleted = tempFile.delete();
if (!isDeleted) {
LOG.info("File {} was not deleted !", tempFile.getName());
}
}
tempFile = null;
}
private void readEachLine(final String line, final double innerCounter, final double totalFileSize) {
final String csvDelimiter = ",";
final String[] targets = line.split(csvDelimiter);
if (targets.length == 2) {
final String controllerId = targets[0];
final String targetName = targets[1];
addNewTarget(controllerId, targetName);
} else {
failedTargetCount++;
}
final float current = managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue();
final float next = (float) (innerCounter / totalFileSize);
if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05
|| Math.abs(next - 1) < 0.00001) {
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next);
managementUIState.getTargetTableFilters().getBulkUpload().setSucessfulUploadCount(successfullTargetCount);
managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(failedTargetCount);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
}
}
private void addNewTarget(final String controllerId, final String name) { private void addNewTarget(final String controllerId, final String name) {
final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerId); final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerId);
if (mandatoryCheck(newControllerId) && duplicateCheck(newControllerId)) { if (mandatoryCheck(newControllerId) && duplicateCheck(newControllerId)) {
@@ -405,43 +420,6 @@ public class BulkUploadHandler extends CustomComponent
} }
} }
private String saveAllAssignments() {
final ActionType actionType = ActionType.FORCED;
final long forcedTimeStamp = new Date().getTime();
final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload();
final List<String> targetsList = targetBulkUpload.getTargetsCreated();
final DistributionSetIdName dsSelected = (DistributionSetIdName) comboBox.getValue();
if (distributionSetManagement.findDistributionSetById(dsSelected.getId()) == null) {
return i18n.get("message.bulk.upload.assignment.failed");
} else {
deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion().getId(), actionType,
forcedTimeStamp, targetsList.toArray(new String[targetsList.size()]));
return null;
}
}
private String tagAssignment() {
final Map<Long, TagData> tokensSelected = targetBulkTokenTags.getTokensAdded();
final List<String> deletedTags = new ArrayList<>();
for (final TagData tagData : tokensSelected.values()) {
if (tagManagement.findTargetTagById(tagData.getId()) == null) {
deletedTags.add(tagData.getName());
} else {
targetManagement.toggleTagAssignment(
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated(),
tagData.getName());
}
}
if (!deletedTags.isEmpty()) {
if (deletedTags.size() == 1) {
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
} else {
return i18n.get("message.bulk.upload.tag.assignments.failed");
}
}
return null;
}
private static class NullOutputStream extends OutputStream { private static class NullOutputStream extends OutputStream {
/** /**
* null output stream. * null output stream.
@@ -462,13 +440,6 @@ public class BulkUploadHandler extends CustomComponent
return upload; return upload;
} }
/*
* (non-Javadoc)
*
* @see
* com.vaadin.ui.Upload.StartedListener#uploadStarted(com.vaadin.ui.Upload
* .StartedEvent)
*/
@Override @Override
public void uploadStarted(final StartedEvent event) { public void uploadStarted(final StartedEvent event) {
if (!event.getFilename().endsWith(".csv")) { if (!event.getFilename().endsWith(".csv")) {

View File

@@ -245,7 +245,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
protected void setColumnProperties() { protected void setColumnProperties() {
List<Object> columnList = new ArrayList<>(); final List<Object> columnList = new ArrayList<>();
columnList.add(SPUILabelDefinitions.VAR_NAME); columnList.add(SPUILabelDefinitions.VAR_NAME);
columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION); columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION);
columnList.add(SPUILabelDefinitions.VAR_STATUS); columnList.add(SPUILabelDefinitions.VAR_STATUS);
@@ -265,13 +265,13 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
protected void setHiddenColumns() { protected void setHiddenColumns() {
List<Object> columnsToBeHidden = new ArrayList<>(); final List<Object> columnsToBeHidden = new ArrayList<>();
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE); columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER); columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY); columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC); columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
for (Object propertyId : columnsToBeHidden) { for (final Object propertyId : columnsToBeHidden) {
getColumn(propertyId).setHidden(true); getColumn(propertyId).setHidden(true);
} }
@@ -318,7 +318,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
public String getStyle(final CellReference cellReference) { public String getStyle(final CellReference cellReference) {
String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION }; final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION };
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) { if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
return "centeralign"; return "centeralign";
} }
@@ -327,18 +327,18 @@ public class RolloutListGrid extends AbstractGrid {
}); });
} }
private void onClickOfRolloutName(RendererClickEvent event) { private void onClickOfRolloutName(final RendererClickEvent event) {
rolloutUIState.setRolloutId((long) event.getItemId()); rolloutUIState.setRolloutId((long) event.getItemId());
final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId()) final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId())
.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); .getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
rolloutUIState.setRolloutName(rolloutName); rolloutUIState.setRolloutName(rolloutName);
String ds = (String) getContainerDataSource().getItem(event.getItemId()) final String ds = (String) getContainerDataSource().getItem(event.getItemId())
.getItemProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).getValue(); .getItemProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).getValue();
rolloutUIState.setRolloutDistributionSet(ds); rolloutUIState.setRolloutDistributionSet(ds);
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS); eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS);
} }
private void onClickOfActionBtn(RendererClickEvent event) { private void onClickOfActionBtn(final RendererClickEvent event) {
final ContextMenu contextMenu = createContextMenu((Long) event.getItemId()); final ContextMenu contextMenu = createContextMenu((Long) event.getItemId());
contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent()); contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent());
contextMenu.open(event.getClientX(), event.getClientY()); contextMenu.open(event.getClientX(), event.getClientY());
@@ -377,7 +377,6 @@ public class RolloutListGrid extends AbstractGrid {
return context; return context;
} }
private void getUpdateMenuItem(final ContextMenu context, final Long rolloutId) { private void getUpdateMenuItem(final ContextMenu context, final Long rolloutId) {
// Add 'Update' option only if user has update permission // Add 'Update' option only if user has update permission
if (!permissionChecker.hasRolloutUpdatePermission()) { if (!permissionChecker.hasRolloutUpdatePermission()) {
@@ -387,17 +386,6 @@ public class RolloutListGrid extends AbstractGrid {
cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE)); cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE));
} }
private String convertRolloutStatusToString(final RolloutStatus value) {
StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
}
private void menuItemClicked(final ContextMenuItemClickEvent event) { private void menuItemClicked(final ContextMenuItemClickEvent event) {
final ContextMenuItem item = (ContextMenuItem) event.getSource(); final ContextMenuItem item = (ContextMenuItem) event.getSource();
final ContextMenuData contextMenuData = (ContextMenuData) item.getData(); final ContextMenuData contextMenuData = (ContextMenuData) item.getData();
@@ -441,12 +429,12 @@ public class RolloutListGrid extends AbstractGrid {
private static final long serialVersionUID = 2544026030795375748L; private static final long serialVersionUID = 2544026030795375748L;
private final FontAwesome fontIcon; private final FontAwesome fontIcon;
public FontIconGenerator(FontAwesome icon) { public FontIconGenerator(final FontAwesome icon) {
this.fontIcon = icon; this.fontIcon = icon;
} }
@Override @Override
public String getValue(Item item, Object itemId, Object propertyId) { public String getValue(final Item item, final Object itemId, final Object propertyId) {
return fontIcon.getHtml(); return fontIcon.getHtml();
} }
@@ -456,7 +444,7 @@ public class RolloutListGrid extends AbstractGrid {
} }
} }
private String getDescription(CellReference cell) { private String getDescription(final CellReference cell) {
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) { if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString().toLowerCase(); return cell.getProperty().getValue().toString().toLowerCase();
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) { } else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
@@ -558,6 +546,17 @@ public class RolloutListGrid extends AbstractGrid {
public Class<String> getPresentationType() { public Class<String> getPresentationType() {
return String.class; return String.class;
} }
private String convertRolloutStatusToString(final RolloutStatus value) {
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
final String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
}
} }
/** /**
@@ -570,14 +569,16 @@ public class RolloutListGrid extends AbstractGrid {
private static final long serialVersionUID = -5794528427855153924L; private static final long serialVersionUID = -5794528427855153924L;
@Override @Override
public TotalTargetCountStatus convertToModel(String value, Class<? extends TotalTargetCountStatus> targetType, public TotalTargetCountStatus convertToModel(final String value,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return null; return null;
} }
@Override @Override
public String convertToPresentation(TotalTargetCountStatus value, Class<? extends String> targetType, public String convertToPresentation(final TotalTargetCountStatus value,
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { final Class<? extends String> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap()); return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
} }

View File

@@ -273,17 +273,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS); eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
} }
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
}
private void createRolloutGroupStatusToFontMap() { private void createRolloutGroupStatusToFontMap() {
statusIconMap.put(RolloutGroupStatus.FINISHED, statusIconMap.put(RolloutGroupStatus.FINISHED,
@@ -391,6 +381,18 @@ public class RolloutGroupListGrid extends AbstractGrid {
public Class<String> getPresentationType() { public Class<String> getPresentationType() {
return String.class; return String.class;
} }
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
StatusFontIcon statusFontIcon = statusIconMap.get(value);
if (statusFontIcon == null) {
return null;
}
String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
}
} }
} }

View File

@@ -158,7 +158,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
@Override @Override
protected void setColumnProperties() { protected void setColumnProperties() {
List<Object> columnList = new ArrayList<>(); final List<Object> columnList = new ArrayList<>();
columnList.add(SPUILabelDefinitions.VAR_NAME); columnList.add(SPUILabelDefinitions.VAR_NAME);
columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE); columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnList.add(SPUILabelDefinitions.VAR_CREATED_BY); columnList.add(SPUILabelDefinitions.VAR_CREATED_BY);
@@ -218,11 +218,9 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
public String convertToPresentation(final Status status, final Class<? extends String> targetType, public String convertToPresentation(final Status status, final Class<? extends String> targetType,
final Locale locale) { final Locale locale) {
if (status == null) { if (status == null) {
// Actions are not created for targets when // Actions are not created for targets when rollout's status is
// rollout's status // READY and when duplicate assignment is done. In these cases
// is READY and when duplicate assignment is done. // display a appropriate status with description
// In these cases display a appropriate status with
// description
return getStatus(); return getStatus();
} }
return processActionStatus(status); return processActionStatus(status);
@@ -238,16 +236,31 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
return String.class; return String.class;
} }
} private String processActionStatus(final Status status) {
final StatusFontIcon statusFontIcon = statusIconMap.get(status);
private String processActionStatus(final Status status) { if (statusFontIcon == null) {
StatusFontIcon statusFontIcon = statusIconMap.get(status); return null;
if (statusFontIcon == null) { }
return null; final String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null);
} }
String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null; private String getStatus() {
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null); final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
? rolloutUIState.getRolloutGroup().get() : null;
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.DOT_CIRCLE_O.getCodepoint()), "statusIconLightBlue", null);
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.MINUS_CIRCLE.getCodepoint()), "statusIconBlue", null);
} else {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.QUESTION_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
}
} }
private void createRolloutStatusToFontMap() { private void createRolloutStatusToFontMap() {
@@ -271,22 +284,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED)); new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED));
} }
private String getStatus() { private String getDescription(final CellReference cell) {
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
? rolloutUIState.getRolloutGroup().get() : null;
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.DOT_CIRCLE_O.getCodepoint()), "statusIconLightBlue", null);
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.MINUS_CIRCLE.getCodepoint()), "statusIconBlue", null);
} else {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.QUESTION_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
}
private String getDescription(CellReference cell) {
if (!SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) { if (!SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return null; return null;
} }
@@ -296,7 +294,6 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
} }
return cell.getProperty().getValue().toString().toLowerCase(); return cell.getProperty().getValue().toString().toLowerCase();
} }
private String getDescriptionWhenNoAction() { private String getDescriptionWhenNoAction() {
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent() final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
@@ -304,7 +301,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) { if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
return RolloutGroupStatus.READY.toString().toLowerCase(); return RolloutGroupStatus.READY.toString().toLowerCase();
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) { } else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
String ds = rolloutUIState.getRolloutDistributionSet().isPresent() final String ds = rolloutUIState.getRolloutDistributionSet().isPresent()
? rolloutUIState.getRolloutDistributionSet().get() : ""; ? rolloutUIState.getRolloutDistributionSet().get() : "";
return i18n.get("message.dist.already.assigned", new Object[] { ds }); return i18n.get("message.dist.already.assigned", new Object[] { ds });
} }

View File

@@ -14,8 +14,6 @@ import java.util.List;
import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem; import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox; import com.vaadin.ui.CheckBox;
import com.vaadin.ui.GridLayout; import com.vaadin.ui.GridLayout;
@@ -50,8 +48,8 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem
this.addComponent(durationField, 1, 0); this.addComponent(durationField, 1, 0);
this.setComponentAlignment(durationField, Alignment.MIDDLE_LEFT); this.setComponentAlignment(durationField, Alignment.MIDDLE_LEFT);
checkBox.addValueChangeListener(event->checkBoxChange()); checkBox.addValueChangeListener(event -> checkBoxChange());
durationField.addValueChangeListener(event->notifyConfigurationChanged()); durationField.addValueChangeListener(event -> notifyConfigurationChanged());
} }
private void checkBoxChange() { private void checkBoxChange() {
@@ -72,16 +70,16 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem
* @param globalDuration * @param globalDuration
* duration value which is stored in the global configuration * duration value which is stored in the global configuration
*/ */
private void init(final Duration globalDuration, final Duration tenantDuration) { protected void init(final Duration globalDuration, final Duration tenantDuration) {
this.globalDuration = globalDuration; this.globalDuration = globalDuration;
this.setValue(tenantDuration); this.setValue(tenantDuration);
} }
private void setCheckBoxTooltip(final String label) { protected void setCheckBoxTooltip(final String label) {
checkBox.setDescription(label); checkBox.setDescription(label);
} }
private void setAllowedRange(final Duration minimumDuration, final Duration maximumDuration) { protected void setAllowedRange(final Duration minimumDuration, final Duration maximumDuration) {
durationField.setMinimumDuration(minimumDuration); durationField.setMinimumDuration(minimumDuration);
durationField.setMaximumDuration(maximumDuration); durationField.setMaximumDuration(maximumDuration);
} }