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:
@@ -215,13 +215,18 @@ public class UploadLayout extends VerticalLayout {
|
||||
hasDirectory = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isDirectory(final Html5File file) {
|
||||
if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) {
|
||||
return true;
|
||||
private StreamVariable createStreamVariable(final Html5File file) {
|
||||
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this, uploadInfoWindow,
|
||||
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() {
|
||||
@@ -282,11 +287,6 @@ public class UploadLayout extends VerticalLayout {
|
||||
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) {
|
||||
final Boolean isDuplicate = checkIfFileIsDuplicate(filename);
|
||||
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
|
||||
// selected.
|
||||
if(!isFilesDropped(event)){
|
||||
if (!isFilesDropped(event)) {
|
||||
uiNotification.displayValidationError(i18n.get("message.action.not.allowed"));
|
||||
return false;
|
||||
}
|
||||
return checkIfSoftwareModuleIsSelected();
|
||||
}
|
||||
|
||||
private boolean isFilesDropped(DragAndDropEvent event) {
|
||||
private boolean isFilesDropped(final DragAndDropEvent event) {
|
||||
if (event.getTransferable() instanceof WrapperTransferable) {
|
||||
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
|
||||
// other components can also be wrapped in WrapperTransferable , so
|
||||
@@ -448,7 +448,7 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
|
||||
private String getDuplicateFileValidationMessage() {
|
||||
StringBuilder message = new StringBuilder();
|
||||
final StringBuilder message = new StringBuilder();
|
||||
if (!duplicateFileNamesList.isEmpty()) {
|
||||
final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList);
|
||||
if (duplicateFileNamesList.size() == 1) {
|
||||
@@ -655,8 +655,7 @@ public class UploadLayout extends VerticalLayout {
|
||||
return uiNotification;
|
||||
}
|
||||
|
||||
|
||||
public void setHasDirectory(Boolean hasDirectory) {
|
||||
public void setHasDirectory(final Boolean hasDirectory) {
|
||||
this.hasDirectory = hasDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
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 onTokenSearch(final Object tokenId) {
|
||||
assignTag(getItemNameProperty(tokenId).getValue().toString());
|
||||
removeTagAssignedFromCombo((Long) tokenId);
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -184,13 +191,6 @@ public abstract class AbstractTagToken implements Serializable {
|
||||
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() {
|
||||
tokensAdded.keySet().forEach(previouslyAddedToken -> tokenField.removeToken(previouslyAddedToken));
|
||||
}
|
||||
|
||||
@@ -63,14 +63,10 @@ import com.vaadin.ui.Upload.SucceededListener;
|
||||
|
||||
/**
|
||||
* Bulk target upload handler.
|
||||
*
|
||||
*/
|
||||
public class BulkUploadHandler extends CustomComponent
|
||||
implements SucceededListener, FailedListener, Receiver, StartedListener {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1273494705754674501L;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BulkUploadHandler.class);
|
||||
|
||||
@@ -149,12 +145,6 @@ public class BulkUploadHandler extends CustomComponent
|
||||
setCompositionRoot(horizontalLayout);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.vaadin.ui.Upload.Receiver#receiveUpload(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public OutputStream receiveUpload(final String filename, final String mimeType) {
|
||||
try {
|
||||
@@ -170,25 +160,11 @@ public class BulkUploadHandler extends CustomComponent
|
||||
return new NullOutputStream();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.vaadin.ui.Upload.FailedListener#uploadFailed(com.vaadin.ui.Upload.
|
||||
* FailedEvent)
|
||||
*/
|
||||
@Override
|
||||
public void uploadFailed(final FailedEvent event) {
|
||||
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
|
||||
public void uploadSucceeded(final SucceededEvent 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() {
|
||||
final StringBuilder errorMessage = new StringBuilder();
|
||||
String dsAssignmentFailedMsg = null;
|
||||
@@ -267,6 +298,43 @@ public class BulkUploadHandler extends CustomComponent
|
||||
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() {
|
||||
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) {
|
||||
final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerId);
|
||||
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 {
|
||||
/**
|
||||
* null output stream.
|
||||
@@ -462,13 +440,6 @@ public class BulkUploadHandler extends CustomComponent
|
||||
return upload;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.vaadin.ui.Upload.StartedListener#uploadStarted(com.vaadin.ui.Upload
|
||||
* .StartedEvent)
|
||||
*/
|
||||
@Override
|
||||
public void uploadStarted(final StartedEvent event) {
|
||||
if (!event.getFilename().endsWith(".csv")) {
|
||||
|
||||
@@ -245,7 +245,7 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
|
||||
@Override
|
||||
protected void setColumnProperties() {
|
||||
List<Object> columnList = new ArrayList<>();
|
||||
final List<Object> columnList = new ArrayList<>();
|
||||
columnList.add(SPUILabelDefinitions.VAR_NAME);
|
||||
columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION);
|
||||
columnList.add(SPUILabelDefinitions.VAR_STATUS);
|
||||
@@ -265,13 +265,13 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
|
||||
@Override
|
||||
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_USER);
|
||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
|
||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
|
||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
|
||||
for (Object propertyId : columnsToBeHidden) {
|
||||
for (final Object propertyId : columnsToBeHidden) {
|
||||
getColumn(propertyId).setHidden(true);
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
|
||||
@Override
|
||||
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())) {
|
||||
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());
|
||||
final String rolloutName = (String) getContainerDataSource().getItem(event.getItemId())
|
||||
.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
|
||||
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();
|
||||
rolloutUIState.setRolloutDistributionSet(ds);
|
||||
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());
|
||||
contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent());
|
||||
contextMenu.open(event.getClientX(), event.getClientY());
|
||||
@@ -377,7 +377,6 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
private void getUpdateMenuItem(final ContextMenu context, final Long rolloutId) {
|
||||
// Add 'Update' option only if user has update permission
|
||||
if (!permissionChecker.hasRolloutUpdatePermission()) {
|
||||
@@ -387,17 +386,6 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
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) {
|
||||
final ContextMenuItem item = (ContextMenuItem) event.getSource();
|
||||
final ContextMenuData contextMenuData = (ContextMenuData) item.getData();
|
||||
@@ -441,12 +429,12 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
private static final long serialVersionUID = 2544026030795375748L;
|
||||
private final FontAwesome fontIcon;
|
||||
|
||||
public FontIconGenerator(FontAwesome icon) {
|
||||
public FontIconGenerator(final FontAwesome icon) {
|
||||
this.fontIcon = icon;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@@ -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())) {
|
||||
return cell.getProperty().getValue().toString().toLowerCase();
|
||||
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
|
||||
@@ -558,6 +546,17 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
public Class<String> getPresentationType() {
|
||||
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;
|
||||
|
||||
@Override
|
||||
public TotalTargetCountStatus convertToModel(String value, Class<? extends TotalTargetCountStatus> targetType,
|
||||
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
public TotalTargetCountStatus convertToModel(final String value,
|
||||
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
|
||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToPresentation(TotalTargetCountStatus value, Class<? extends String> targetType,
|
||||
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
public String convertToPresentation(final TotalTargetCountStatus value,
|
||||
final Class<? extends String> targetType, final Locale locale)
|
||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
|
||||
}
|
||||
|
||||
|
||||
@@ -273,17 +273,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
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() {
|
||||
statusIconMap.put(RolloutGroupStatus.FINISHED,
|
||||
@@ -391,6 +381,18 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
public Class<String> getPresentationType() {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
|
||||
|
||||
@Override
|
||||
protected void setColumnProperties() {
|
||||
List<Object> columnList = new ArrayList<>();
|
||||
final List<Object> columnList = new ArrayList<>();
|
||||
columnList.add(SPUILabelDefinitions.VAR_NAME);
|
||||
columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE);
|
||||
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,
|
||||
final Locale locale) {
|
||||
if (status == null) {
|
||||
// Actions are not created for targets when
|
||||
// rollout's status
|
||||
// is READY and when duplicate assignment is done.
|
||||
// In these cases display a appropriate status with
|
||||
// description
|
||||
// Actions are not created for targets when rollout's status is
|
||||
// READY and when duplicate assignment is done. In these cases
|
||||
// display a appropriate status with description
|
||||
return getStatus();
|
||||
}
|
||||
return processActionStatus(status);
|
||||
@@ -238,16 +236,31 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String processActionStatus(final Status status) {
|
||||
StatusFontIcon statusFontIcon = statusIconMap.get(status);
|
||||
if (statusFontIcon == null) {
|
||||
return null;
|
||||
private String processActionStatus(final Status status) {
|
||||
final StatusFontIcon statusFontIcon = statusIconMap.get(status);
|
||||
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;
|
||||
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), null);
|
||||
|
||||
private String getStatus() {
|
||||
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() {
|
||||
@@ -271,22 +284,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
|
||||
new StatusFontIcon(FontAwesome.EXCLAMATION_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_RED));
|
||||
}
|
||||
|
||||
private String getStatus() {
|
||||
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) {
|
||||
private String getDescription(final CellReference cell) {
|
||||
if (!SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
|
||||
return null;
|
||||
}
|
||||
@@ -296,7 +294,6 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
|
||||
}
|
||||
return cell.getProperty().getValue().toString().toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
private String getDescriptionWhenNoAction() {
|
||||
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
|
||||
@@ -304,7 +301,7 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
|
||||
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
|
||||
return RolloutGroupStatus.READY.toString().toLowerCase();
|
||||
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
|
||||
String ds = rolloutUIState.getRolloutDistributionSet().isPresent()
|
||||
final String ds = rolloutUIState.getRolloutDistributionSet().isPresent()
|
||||
? rolloutUIState.getRolloutDistributionSet().get() : "";
|
||||
return i18n.get("message.dist.already.assigned", new Object[] { ds });
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ import java.util.List;
|
||||
|
||||
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.CheckBox;
|
||||
import com.vaadin.ui.GridLayout;
|
||||
@@ -50,8 +48,8 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem
|
||||
this.addComponent(durationField, 1, 0);
|
||||
this.setComponentAlignment(durationField, Alignment.MIDDLE_LEFT);
|
||||
|
||||
checkBox.addValueChangeListener(event->checkBoxChange());
|
||||
durationField.addValueChangeListener(event->notifyConfigurationChanged());
|
||||
checkBox.addValueChangeListener(event -> checkBoxChange());
|
||||
durationField.addValueChangeListener(event -> notifyConfigurationChanged());
|
||||
}
|
||||
|
||||
private void checkBoxChange() {
|
||||
@@ -72,16 +70,16 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem
|
||||
* @param globalDuration
|
||||
* 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.setValue(tenantDuration);
|
||||
}
|
||||
|
||||
private void setCheckBoxTooltip(final String label) {
|
||||
protected void setCheckBoxTooltip(final String 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.setMaximumDuration(maximumDuration);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user