Merge pull request #118 from bsinno/Methods_only_called_by_inner_classes_should_move_to_those_classes

Methods only called by inner classes should move to those classes
This commit is contained in:
Michael Hirsch
2016-04-06 13:59:38 +02:00
8 changed files with 188 additions and 221 deletions

View File

@@ -215,13 +215,15 @@ public class UploadLayout extends VerticalLayout {
hasDirectory = Boolean.TRUE; hasDirectory = Boolean.TRUE;
} }
} }
private StreamVariable createStreamVariable(final Html5File file) {
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this, uploadInfoWindow,
spInfo.getMaxArtifactFileSize(), null, file.getType());
} }
private static boolean isDirectory(final Html5File file) { private boolean isDirectory(final Html5File file) {
if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) { return Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0;
return true;
} }
return false;
} }
private void displayCompositeMessage() { private void displayCompositeMessage() {
@@ -282,11 +284,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,7 +346,7 @@ 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)) {
@@ -359,7 +356,7 @@ public class UploadLayout extends VerticalLayout {
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 +445,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 +652,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

@@ -178,12 +178,10 @@ public abstract class AbstractTagToken implements Serializable {
} }
} }
}
private void updateTokenStyle(final Object tokenId, final Button button) { private void updateTokenStyle(final Object tokenId, final Button button) {
final String color = getColor(tokenId); final String color = getColor(tokenId);
button.setCaption("<span style=\"color:" + color + " !important;\">" + FontAwesome.CIRCLE.getHtml() + "</span>" button.setCaption("<span style=\"color:" + color + " !important;\">" + FontAwesome.CIRCLE.getHtml()
+ " " + getItemNameProperty(tokenId).getValue().toString().concat(" ×")); + "</span>" + " " + getItemNameProperty(tokenId).getValue().toString().concat(" ×"));
button.setCaptionAsHtml(true); button.setCaptionAsHtml(true);
} }
@@ -192,6 +190,15 @@ public abstract class AbstractTagToken implements Serializable {
removeTagAssignedFromCombo((Long) tokenId); 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 Property getItemNameProperty(final Object tokenId) { private Property getItemNameProperty(final Object tokenId) {
final Item item = tokenField.getContainerDataSource().getItem(tokenId); final Item item = tokenField.getContainerDataSource().getItem(tokenId);
return item.getItemProperty("name"); return item.getItemProperty("name");
@@ -211,13 +218,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,61 +228,6 @@ public class BulkUploadHandler extends CustomComponent
} }
} }
private void doAssignments() {
final StringBuilder errorMessage = new StringBuilder();
String dsAssignmentFailedMsg = null;
String tagAssignmentFailedMsg = null;
if (ifTargetsCreatedSuccessfully()) {
if (ifTagsSelected()) {
tagAssignmentFailedMsg = tagAssignment();
}
if (ifDsSelected()) {
dsAssignmentFailedMsg = saveAllAssignments();
}
}
displayValidationMessage(errorMessage, dsAssignmentFailedMsg, tagAssignmentFailedMsg);
}
private boolean ifTagsSelected() {
return targetBulkTokenTags.getTokenField().getValue() != null;
}
/**
* @return
*/
private boolean ifDsSelected() {
return comboBox.getValue() != null;
}
/**
* @return
*/
private boolean ifTargetsCreatedSuccessfully() {
return !managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().isEmpty();
}
/**
* @param errorMessage
* @param dsAssignmentFailedMsg
* @param tagAssignmentFailedMsg
*/
private void displayValidationMessage(final StringBuilder errorMessage, final String dsAssignmentFailedMsg,
final String tagAssignmentFailedMsg) {
if (dsAssignmentFailedMsg != null) {
errorMessage.append(dsAssignmentFailedMsg);
}
if (errorMessage.length() > 0) {
errorMessage.append("<br>");
}
if (tagAssignmentFailedMsg != null) {
errorMessage.append(tagAssignmentFailedMsg);
}
if (errorMessage.length() > 0) {
eventBus.publish(this, new BulkUploadValidationMessageEvent(errorMessage.toString()));
}
}
}
private double getTotalNumberOfLines() { private double getTotalNumberOfLines() {
double totalFileSize = 0; double totalFileSize = 0;
@@ -349,17 +270,109 @@ public class BulkUploadHandler extends CustomComponent
} else { } else {
failedTargetCount++; failedTargetCount++;
} }
final float current = managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue(); final float current = managementUIState.getTargetTableFilters().getBulkUpload()
.getProgressBarCurrentValue();
final float next = (float) (innerCounter / totalFileSize); final float next = (float) (innerCounter / totalFileSize);
if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05 if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05
|| Math.abs(next - 1) < 0.00001) { || Math.abs(next - 1) < 0.00001) {
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next); managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next);
managementUIState.getTargetTableFilters().getBulkUpload().setSucessfulUploadCount(successfullTargetCount); managementUIState.getTargetTableFilters().getBulkUpload()
.setSucessfulUploadCount(successfullTargetCount);
managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(failedTargetCount); managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(failedTargetCount);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED)); eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
} }
} }
private void doAssignments() {
final StringBuilder errorMessage = new StringBuilder();
String dsAssignmentFailedMsg = null;
String tagAssignmentFailedMsg = null;
if (ifTargetsCreatedSuccessfully()) {
if (ifTagsSelected()) {
tagAssignmentFailedMsg = tagAssignment();
}
if (ifDsSelected()) {
dsAssignmentFailedMsg = saveAllAssignments();
}
}
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");
}
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()) {
return null;
}
if (deletedTags.size() == 1) {
return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0));
}
return i18n.get("message.bulk.upload.tag.assignments.failed");
}
private boolean ifTagsSelected() {
return targetBulkTokenTags.getTokenField().getValue() != null;
}
/**
* @return
*/
private boolean ifDsSelected() {
return comboBox.getValue() != null;
}
/**
* @return
*/
private boolean ifTargetsCreatedSuccessfully() {
return !managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().isEmpty();
}
/**
* @param errorMessage
* @param dsAssignmentFailedMsg
* @param tagAssignmentFailedMsg
*/
private void displayValidationMessage(final StringBuilder errorMessage, final String dsAssignmentFailedMsg,
final String tagAssignmentFailedMsg) {
if (dsAssignmentFailedMsg != null) {
errorMessage.append(dsAssignmentFailedMsg);
}
if (errorMessage.length() > 0) {
errorMessage.append("<br>");
}
if (tagAssignmentFailedMsg != null) {
errorMessage.append(tagAssignmentFailedMsg);
}
if (errorMessage.length() > 0) {
eventBus.publish(this, new BulkUploadValidationMessageEvent(errorMessage.toString()));
}
}
}
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 +418,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 +438,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

@@ -356,7 +356,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()) {
@@ -366,17 +365,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) {
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);
}
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();
@@ -537,6 +525,13 @@ 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);
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID);
}
} }
/** /**
@@ -549,14 +544,16 @@ public class RolloutListGrid extends AbstractGrid {
private static final long serialVersionUID = -5794528427855153924L; private static final long serialVersionUID = -5794528427855153924L;
@Override @Override
public TotalTargetCountStatus convertToModel(final String value, final Class<? extends TotalTargetCountStatus> targetType, public TotalTargetCountStatus convertToModel(final String value,
final 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(final TotalTargetCountStatus value, final Class<? extends String> targetType, public String convertToPresentation(final TotalTargetCountStatus value,
final 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

@@ -250,18 +250,6 @@ 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) {
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_GROUP_STATUS_LABEL_ID);
}
private void createRolloutGroupStatusToFontMap() { private void createRolloutGroupStatusToFontMap() {
statusIconMap.put(RolloutGroupStatus.FINISHED, statusIconMap.put(RolloutGroupStatus.FINISHED,
new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN)); new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN));
@@ -316,14 +304,16 @@ public class RolloutGroupListGrid extends AbstractGrid {
private static final long serialVersionUID = -9205943894818450807L; private static final long serialVersionUID = -9205943894818450807L;
@Override @Override
public TotalTargetCountStatus convertToModel(final String value, final Class<? extends TotalTargetCountStatus> targetType, public TotalTargetCountStatus convertToModel(final String value,
final 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(final TotalTargetCountStatus value, final Class<? extends String> targetType, public String convertToPresentation(final TotalTargetCountStatus value,
final 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());
} }
@@ -369,5 +359,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
return String.class; return String.class;
} }
private String convertRolloutGroupStatusToString(final RolloutGroupStatus value) {
final StatusFontIcon statusFontIcon = statusIconMap.get(value);
final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(),
SPUIComponetIdProvider.ROLLOUT_GROUP_STATUS_LABEL_ID);
}
} }
} }

View File

@@ -196,11 +196,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);
@@ -216,18 +214,29 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid {
return String.class; return String.class;
} }
}
private String processActionStatus(final Status status) { private String processActionStatus(final Status status) {
final StatusFontIcon statusFontIcon = statusIconMap.get(status); final StatusFontIcon statusFontIcon = statusIconMap.get(status);
if (statusFontIcon == null) { final String codePoint = HawkbitCommonUtil.getCodePoint(statusFontIcon);
return null;
}
final String codePoint = statusFontIcon.getFontIcon() != null
? Integer.toString(statusFontIcon.getFontIcon().getCodepoint()) : null;
return HawkbitCommonUtil.getStatusLabelDetailsInString(codePoint, statusFontIcon.getStyle(), 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);
}
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.MINUS_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
return HawkbitCommonUtil.getStatusLabelDetailsInString(
Integer.toString(FontAwesome.QUESTION_CIRCLE.getCodepoint()), "statusIconBlue", null);
}
}
private void createRolloutStatusToFontMap() { private void createRolloutStatusToFontMap() {
statusIconMap.put(Status.FINISHED, statusIconMap.put(Status.FINISHED,
new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN)); new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN));
@@ -249,21 +258,6 @@ 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() {
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(final CellReference cell) { private String getDescription(final CellReference cell) {
if (!SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) { if (!SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return null; return null;
@@ -275,7 +269,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()
? rolloutUIState.getRolloutGroup().get() : null; ? rolloutUIState.getRolloutGroup().get() : null;

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;

View File

@@ -37,6 +37,7 @@ import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
import org.eclipse.hawkbit.ui.management.dstable.DistributionTable; import org.eclipse.hawkbit.ui.management.dstable.DistributionTable;
import org.eclipse.hawkbit.ui.management.targettable.TargetTable; import org.eclipse.hawkbit.ui.management.targettable.TargetTable;
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
@@ -1352,4 +1353,19 @@ public final class HawkbitCommonUtil {
return val.toString(); return val.toString();
} }
/**
* Receive the code point of a given StatusFontIcon.
*
* @param statusFontIcon
* the status font icon
* @return the code point of the StatusFontIcon
*/
public static String getCodePoint(final StatusFontIcon statusFontIcon) {
if (statusFontIcon == null) {
return null;
}
return statusFontIcon.getFontIcon() != null ? Integer.toString(statusFontIcon.getFontIcon().getCodepoint())
: null;
}
} }