Rollout progress bar custom render changed to html renderer

Packages refactored

Signed-off-by: asharani-murugesh <asharani.murugesh@in.bosch.com>
This commit is contained in:
asharani-murugesh
2016-03-01 13:59:57 +01:00
parent bb873e88a7
commit 7937c16c9b
31 changed files with 314 additions and 1605 deletions

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.common.grid;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -20,7 +20,7 @@ import com.vaadin.ui.themes.ValoTheme;
* Abstract table class.
*
*/
public abstract class AbstractSimpleGrid extends Grid {
public abstract class AbstractGrid extends Grid {
private static final long serialVersionUID = 4856562746502217630L;

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.common.grid;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -26,10 +26,10 @@ import com.vaadin.ui.VerticalLayout;
/**
*
* Abstract table header.
* Abstract grid header.
*
*/
public abstract class AbstractSimpleTableHeader extends VerticalLayout {
public abstract class AbstractGridHeader extends VerticalLayout {
private static final long serialVersionUID = -24429876573255519L;

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.common.grid;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
@@ -17,22 +17,21 @@ import com.vaadin.ui.VerticalLayout;
/**
*
* Abstract table layout class which builds layout with table
* {@link AbstractSimpleTable} and table header
* {@link AbstractSimpleTableHeader}.
* Abstract grid layout class which builds layout with grid
* {@link AbstractGrid} and table header
* {@link AbstractGridHeader}.
*
*/
public abstract class AbstractSimpleTableLayout extends VerticalLayout {
public abstract class AbstractGridLayout extends VerticalLayout {
private static final long serialVersionUID = 8611248179949245460L;
private AbstractSimpleTableHeader tableHeader;
private AbstractGridHeader tableHeader;
private AbstractSimpleGrid grid;
private AbstractGrid grid;
protected void init(final AbstractSimpleTableHeader tableHeader,final AbstractSimpleGrid grid) {
protected void init(final AbstractGridHeader tableHeader,final AbstractGrid grid) {
this.tableHeader = tableHeader;
this.grid = grid;
buildLayout();
@@ -52,7 +51,6 @@ public abstract class AbstractSimpleTableLayout extends VerticalLayout {
tableHeaderLayout.addComponent(tableHeader);
tableHeaderLayout.setComponentAlignment(tableHeader, Alignment.TOP_CENTER);
// grid.setSizeFull();
tableHeaderLayout.addComponent(grid);
tableHeaderLayout.setComponentAlignment(grid, Alignment.TOP_CENTER);
tableHeaderLayout.setExpandRatio(grid, 1.0f);
@@ -83,9 +81,14 @@ public abstract class AbstractSimpleTableLayout extends VerticalLayout {
/**
* Only in rollout group targets view count message is displayed.
*
* @return
* @return true if count message has to be displayed
*/
protected abstract boolean hasCountMessage();
/**
* Get the count message label.
*
* @return count message
*/
protected abstract Label getCountMessageLabel();
}

View File

@@ -1,18 +0,0 @@
package org.eclipse.hawkbit.ui.customrenderers.client;
import com.vaadin.client.connectors.AbstractRendererConnector;
import com.vaadin.shared.ui.Connect;
@Connect(org.eclipse.hawkbit.ui.customrenderers.renderers.StringDistributionBarRenderer.class)
public class StringDistributionBarRendererConnector extends AbstractRendererConnector<String> {
private static final long serialVersionUID = 7697966991925490786L;
@Override
public org.eclipse.hawkbit.ui.customrenderers.client.renderers.StringDistributionBarRenderer getRenderer() {
org.eclipse.hawkbit.ui.customrenderers.client.renderers.StringDistributionBarRenderer renderer = (org.eclipse.hawkbit.ui.customrenderers.client.renderers.StringDistributionBarRenderer) super.getRenderer();
renderer.setUiWidgetClassName(StringDistributionBarRendererConnector.this.getConnection().getUIConnector().getWidget().getParent().getStyleName());
return renderer;
}
}

View File

@@ -2,6 +2,7 @@ package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
import com.google.gwt.user.client.ui.Button;
import com.vaadin.client.renderers.ButtonRenderer;
import com.vaadin.client.ui.VButton;
import com.vaadin.client.widget.grid.RendererCellReference;
public class HtmlButtonRenderer extends ButtonRenderer {
@@ -17,8 +18,8 @@ public class HtmlButtonRenderer extends ButtonRenderer {
}
private void applystyles(Button button) {
button.setStylePrimaryName("v-button");
button.setStyleName("tiny v-button-tiny");
button.setStyleName(VButton.CLASSNAME);
button.addStyleName("tiny v-button-tiny");
button.addStyleName("borderless v-button-borderless");
button.addStyleName("icon-only v-button-icon-only");
button.addStyleName("button-no-border v-button-button-no-border");

View File

@@ -1,114 +0,0 @@
package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.vaadin.alump.distributionbar.gwt.client.GwtDistributionBar;
import org.vaadin.alump.distributionbar.gwt.client.dom.ToolTipPresenter.TooltipClassNameProvider;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.vaadin.client.renderers.WidgetRenderer;
import com.vaadin.client.widget.grid.RendererCellReference;
public class StringDistributionBarRenderer extends WidgetRenderer<String, GwtDistributionBar> {
private static final String STATUS_BAR_PART = "status-bar-part-";
private static final String FINISHED = "FINISHED";
private static final String SCHEDULED = "SCHEDULED";
private static final String ROLLOUT_STATUS_PROGRESS_BAR_ID = "rollout.status.progress.bar.id";
private String uiWidgetClassName;
@Override
public GwtDistributionBar createWidget() {
GwtDistributionBar gwt = GWT.create(GwtDistributionBar.class);
gwt.setTooltipClassNameProvider(new TooltipClassNameProvider() {
@Override
public String getClassNames() {
return getUiWidgetClassName();
}
});
return gwt;
}
@Override
public void render(RendererCellReference cell, String input, GwtDistributionBar widget) {
if (null != input) {
widget.setNumberOfParts(2);
Map<String, Long> map = formatData(input);
if (!map.isEmpty()) {
if (isNoTargets(map.values())) {
setBarPartSize(widget, SCHEDULED.toLowerCase(), 0, 0);
setBarPartSize(widget, FINISHED.toLowerCase(), 0, 1);
} else {
setThePartDetails(widget, map);
}
}
widget.getElement().setId(ROLLOUT_STATUS_PROGRESS_BAR_ID);
widget.getElement().getStyle().setWidth(100, Unit.PCT);
widget.getElement().getStyle().setHeight(100, Unit.PCT);
}
widget.updateParts();
}
private void setThePartDetails(GwtDistributionBar widget, Map<String, Long> map) {
widget.setNumberOfParts(getNumberOfParts(map.values()));
int index = 0;
for (Entry<String, Long> entryVal : map.entrySet()) {
Long count = entryVal.getValue();
if (count > 0) {
setBarPartSize(widget, entryVal.getKey().toLowerCase(), count.intValue(), index);
index++;
}
}
}
private Map<String, Long> formatData(String input) {
Map<String, Long> details = new HashMap<>();
String[] tempData = input.split(",");
for (String statusWithCount : tempData) {
String[] statusWithCountList = statusWithCount.split(":");
details.put(statusWithCountList[0], new Long(statusWithCountList[1]));
}
return details;
}
private int getNumberOfParts(Collection<Long> values) {
int count = 0;
for (Long val : values) {
if (val != 0) {
count++;
}
}
return count;
}
private boolean isNoTargets(Collection<Long> values) {
for (Long count : values) {
if (count != 0) {
return false;
}
}
return true;
}
private void setBarPartSize(final GwtDistributionBar bar, final String statusName, final int count,
final int index) {
bar.setPartSize(index, count);
bar.setPartTooltip(index, statusName);
bar.setPartStyleName(index, index, STATUS_BAR_PART + statusName);
}
public String getUiWidgetClassName() {
return uiWidgetClassName;
}
public void setUiWidgetClassName(String uiWidgetClassName) {
this.uiWidgetClassName = uiWidgetClassName;
}
}

View File

@@ -1,18 +0,0 @@
package org.eclipse.hawkbit.ui.customrenderers.renderers;
import com.vaadin.ui.Grid.AbstractRenderer;
public class StringDistributionBarRenderer extends AbstractRenderer<String> {
private static final long serialVersionUID = -4543220859821576209L;
/**
* Creates a new text renderer
*/
public StringDistributionBarRenderer() {
super(String.class, null);
}
}

View File

@@ -1,116 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import com.vaadin.data.Container;
import com.vaadin.ui.Table;
import com.vaadin.ui.themes.ValoTheme;
/**
* Abstract table class.
*
*/
public abstract class AbstractSimpleTable extends Table {
private static final long serialVersionUID = 4856562746502217630L;
/**
* Initialize the components.
*/
protected void init() {
addStyleName("sp-table rollout-table");
setSizeFull();
setImmediate(true);
setHeight(100.0f, Unit.PERCENTAGE);
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
addStyleName(ValoTheme.TABLE_SMALL);
setSortEnabled(false);
setId(getTableId());
addCustomGeneratedColumns();
addNewContainerDS();
setColumnProperties();
addValueChangeListener(event -> onValueChange());
setPageLength(SPUIDefinitions.PAGE_SIZE);
setSelectable(false);
setColumnCollapsingAllowed(true);
setCollapsiblecolumns();
}
private void setColumnProperties() {
final List<TableColumn> columnList = getTableVisibleColumns();
final List<Object> columnIds = new ArrayList<>();
for (final TableColumn column : columnList) {
setColumnHeader(column.getColumnPropertyId(), column.getColumnHeader());
setColumnExpandRatio(column.getColumnPropertyId(), column.getExpandRatio());
columnIds.add(column.getColumnPropertyId());
}
setVisibleColumns(columnIds.toArray());
}
private void addNewContainerDS() {
final Container container = createContainer();
addContainerProperties(container);
setContainerDataSource(container);
int size = 0;
if (container != null) {
size = container.size();
}
if (size == 0) {
setData(SPUIDefinitions.NO_DATA);
}
}
/**
* Based on table state (max/min) columns to be shown are returned.
*
* @return List<TableColumn> list of visible columns
*/
protected abstract List<TableColumn> getTableVisibleColumns();
/**
* Create container of the data to be displayed by the table.
*/
protected abstract Container createContainer();
/**
* Add container properties to the container passed in the reference.
*
* @param container
* reference of {@link Container}
*/
protected abstract void addContainerProperties(Container container);
/**
* Get Id of the table.
*
* @return Id.
*/
protected abstract String getTableId();
/**
* On select of row.
*/
protected abstract void onValueChange();
/**
* Add any generated columns if required.
*/
protected abstract void addCustomGeneratedColumns();
/**
* Set list of columns collapsible.
*/
protected abstract void setCollapsiblecolumns();
}

View File

@@ -1,23 +0,0 @@
package org.eclipse.hawkbit.ui.rollout;
import java.util.HashMap;
import java.util.Map;
public class DistributionBarDetails {
private Map<String,Long> details = new HashMap<>();
public DistributionBarDetails( Map<String,Long> details){
this.details = details;
}
public Map<String, Long> getDetails() {
return details;
}
public void setDetails(Map<String, Long> details) {
this.details = details;
}
}

View File

@@ -0,0 +1,126 @@
package org.eclipse.hawkbit.ui.rollout;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
import org.vaadin.alump.distributionbar.gwt.client.GwtDistributionBar;
/**
* Distribution bar helper to render distribution bar in grid.
*
*/
public final class DistributionBarHelper {
private static final int PARENT_SIZE_IN_PCT = 100;
private static final double MINIMUM_PART_SIZE = 10;
private static final String DISTRIBUTION_BAR_PART_MAIN_STYLE = GwtDistributionBar.CLASSNAME + "-part";
private static final String DISTRIBUTION_BAR_PART_CLASSNAME_PREFIX = GwtDistributionBar.CLASSNAME + "-part-";
private static final String DISTRIBUTION_BAR_PART_VALUE_CLASSNAME = GwtDistributionBar.CLASSNAME + "-value";
private static final String UNINITIALIZED_VALUE_CLASSNAME = GwtDistributionBar.CLASSNAME + "-uninitizalized";
private DistributionBarHelper() {
}
private static String getPartStyle(int partIndex, int noOfParts, String customStyle) {
StringBuilder mainStyle = new StringBuilder();
StringBuilder styleName = new StringBuilder(GwtDistributionBar.CLASSNAME);
if (noOfParts == 1) {
styleName.append("-only");
} else if (partIndex == 1) {
styleName.append("-left");
} else if (partIndex == noOfParts) {
styleName.append("-right");
} else {
styleName.append("-middle");
}
mainStyle.append(styleName).append(" ");
mainStyle.append(DISTRIBUTION_BAR_PART_MAIN_STYLE).append(" ");
mainStyle.append(DISTRIBUTION_BAR_PART_CLASSNAME_PREFIX + partIndex);
if (customStyle != null) {
mainStyle.append(" ").append("status-bar-part-" + customStyle);
}
return mainStyle.toString();
}
private static String getPartWidth(Long value, Long totalValue, int noOfParts) {
final double minTotalSize = MINIMUM_PART_SIZE * noOfParts;
final double availableSize = PARENT_SIZE_IN_PCT - minTotalSize;
double val = MINIMUM_PART_SIZE + (double) value / totalValue * availableSize;
return String.format("%.3f", val) + "%";
}
private static String getPart(int partIndex, Status status, Long value, Long totalValue, int noOfParts) {
String partValue = status.toString().toLowerCase();
// return "<div class=\"" + getPartStyle(partIndex, noOfParts,
// partValue) + "\" style=\"width: "
// + getPartWidth(value, totalValue, noOfParts) + ";\" title = \"" +
// partValue + "\"><span class=\""
// + DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">" + value +
// "</span></div>";
return "<div class=\"" + getPartStyle(partIndex, noOfParts, partValue) + "\" style=\"width: "
+ getPartWidth(value, totalValue, noOfParts) + ";\"><span class=\""
+ DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">" + value + "</span></div>";
}
public static String getDistributionBarAsHTMLString(Map<Status, Long> statusTotalCountMap) {
StringBuilder htmlString = new StringBuilder();
htmlString.append(getParentDivStart());
Long totalValue = getTotalSizes(statusTotalCountMap);
Map<Status, Long> statusMapWithNonZeroValues = getNonZeroStatusList(statusTotalCountMap);
if (statusMapWithNonZeroValues.size() > 0) {
int partIndex = 1;
for (Map.Entry<Status, Long> entry : statusMapWithNonZeroValues.entrySet()) {
if (entry.getValue() > 0) {
htmlString.append(getPart(partIndex, entry.getKey(), entry.getValue(), totalValue,
statusMapWithNonZeroValues.size()));
partIndex++;
}
}
} else {
return getUnintialisedBar();
}
htmlString.append(getParentDivEnd());
return htmlString.toString();
}
public static Map<Status, Long> getNonZeroStatusList(Map<Status, Long> statusTotalCountMap) {
return statusTotalCountMap.entrySet().stream().filter(p -> p.getValue() > 0)
.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue()));
}
public static String getTooltip(Map<Status, Long> statusCountMap) {
Map<Status, Long> nonZeroStatusCountMap = DistributionBarHelper.getNonZeroStatusList(statusCountMap);
StringBuilder tooltip = new StringBuilder();
for (Entry<Status, Long> entry : nonZeroStatusCountMap.entrySet()) {
tooltip.append(entry.getKey().toString().toLowerCase()).append(" : ").append(entry.getValue())
.append("<br>");
}
return tooltip.toString();
}
private static String getUnintialisedBar() {
return "<div class=\"" + UNINITIALIZED_VALUE_CLASSNAME + "\" style=\"width: 100%;\"><span class=\""
+ DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">uninitialized</span></div>";
}
private static Long getTotalSizes(Map<Status, Long> statusTotalCountMap) {
Long total = 0L;
for (Long value : statusTotalCountMap.values()) {
total = total + value;
}
return total;
}
private static String getParentDivStart() {
return "<div class=\"" + GwtDistributionBar.CLASSNAME
+ "\" style=\"width: 100%; height: 100%;\" id=\"rollout.status.progress.bar.id\">";
}
private static String getParentDivEnd() {
return "</div>";
}
}

View File

@@ -1,364 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.RolloutGroupChangeEvent;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.alump.distributionbar.DistributionBar;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.themes.ValoTheme;
/**
* Rollout Group Table in List view.
*
*/
@SpringComponent
@ViewScope
public class RolloutGroupListTable extends AbstractSimpleTable {
private static final String IS_ACTION_RECIEVED = "isActionRecieved";
private static final long serialVersionUID = 1182656768844867443L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient RolloutGroupManagement rolloutGroupManagement;
@Autowired
private transient RolloutManagement rolloutManagement;
@Autowired
private transient RolloutUIState rolloutUIState;
@Autowired
private transient SpPermissionChecker permissionChecker;
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) {
if (event == RolloutEvent.SHOW_ROLLOUT_GROUPS) {
((LazyQueryContainer) getContainerDataSource()).refresh();
}
}
/**
*
* Handles the RolloutGroupChangeEvent to refresh the item in the table.
*
*
* @param rolloutGroupChangeEvent
* the event which contains the rollout group which has been
* change
*/
@EventBusListenerMethod(scope = EventScope.SESSION)
public void onEvent(final RolloutGroupChangeEvent rolloutGroupChangeEvent) {
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
if (visibleItemIds.contains(rolloutGroupChangeEvent.getRolloutGroupId())) {
final RolloutGroup rolloutGroup = rolloutGroupManagement
.findRolloutGroupWithDetailedStatus(rolloutGroupChangeEvent.getRolloutGroupId());
final TotalTargetCountStatus totalTargetCountStatus = rolloutGroup.getTotalTargetCountStatus();
final LazyQueryContainer rolloutContainer = (LazyQueryContainer) getContainerDataSource();
final Item item = rolloutContainer.getItem(rolloutGroup.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rolloutGroup.getStatus());
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_RUNNING).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.RUNNING));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_ERROR)
.setValue(totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.ERROR));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_FINISHED).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.FINISHED));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_NOT_STARTED).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.NOTSTARTED));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_CANCELLED).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.CANCELLED));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_SCHEDULED).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.SCHEDULED));
item.getItemProperty(IS_ACTION_RECIEVED)
.setValue(!(Boolean) item.getItemProperty(IS_ACTION_RECIEVED).getValue());
}
}
@Override
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = new ArrayList<>();
columnList.add(new TableColumn(SPUIDefinitions.ROLLOUT_GROUP_NAME, i18n.get("header.name"), 0.1f));
columnList.add(new TableColumn(SPUIDefinitions.ROLLOUT_GROUP_STATUS, i18n.get("header.status"), 0.1f));
columnList.add(new TableColumn(SPUIDefinitions.DETAIL_STATUS, i18n.get("header.detail.status"), 0.42f));
columnList
.add(new TableColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS, i18n.get("header.total.targets"), 0.08f));
columnList.add(new TableColumn(SPUILabelDefinitions.ROLLOUT_GROUP_INSTALLED_PERCENTAGE,
i18n.get("header.rolloutgroup.installed.percentage"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.ROLLOUT_GROUP_ERROR_THRESHOLD,
i18n.get("header.rolloutgroup.threshold.error"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.ROLLOUT_GROUP_THRESHOLD,
i18n.get("header.rolloutgroup.threshold"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.15f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_USER, i18n.get("header.createdBy"), 0.15f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.15f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.15f));
return columnList;
}
@Override
protected Container createContainer() {
final BeanQueryFactory<RolloutGroupBeanQuery> rolloutQf = new BeanQueryFactory<>(RolloutGroupBeanQuery.class);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), rolloutQf);
}
@Override
protected void addContainerProperties(final Container container) {
final LazyQueryContainer rolloutGroupGridContainer = (LazyQueryContainer) container;
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_ID, String.class, null, false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutGroupStatus.class, null,
false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.ROLLOUT_GROUP_INSTALLED_PERCENTAGE, String.class,
null, false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.ROLLOUT_GROUP_ERROR_THRESHOLD, String.class, null,
false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.ROLLOUT_GROUP_THRESHOLD, String.class, null, false,
false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false,
false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_DATE, String.class, null, false,
false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_USER, String.class, null, false,
false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false,
false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_NOT_STARTED, Long.class, 0L,
false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_RUNNING, Long.class, 0L,
false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_SCHEDULED, Long.class, 0L,
false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_ERROR, Long.class, 0L, false,
false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_FINISHED, Long.class, 0L,
false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_CANCELLED, Long.class, 0L,
false, false);
rolloutGroupGridContainer.addContainerProperty(IS_ACTION_RECIEVED, Boolean.class, false, false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false,
false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS,
TotalTargetCountStatus.class, null, false, false);
}
@Override
protected String getTableId() {
return SPUIComponetIdProvider.ROLLOUT_GROUP_LIST_TABLE_ID;
}
@Override
protected void onValueChange() {
/**
* No implementation required.
*/
}
@Override
protected void addCustomGeneratedColumns() {
addGeneratedColumn(SPUIDefinitions.ROLLOUT_GROUP_NAME,
(source, itemId, columnId) -> getRolloutNameLink(itemId));
addGeneratedColumn(SPUIDefinitions.ROLLOUT_GROUP_STATUS, (source, itemId, columnId) -> getStatusLabel(itemId));
addGeneratedColumn(SPUIDefinitions.DETAIL_STATUS, (source, itemId, columnId) -> getProgressBar(itemId));
setColumnAlignment(SPUIDefinitions.ROLLOUT_GROUP_STATUS, Align.CENTER);
}
private Label getStatusLabel(final Object itemId) {
final Label statusLabel = new Label();
statusLabel.setHeightUndefined();
statusLabel.setContentMode(ContentMode.HTML);
setStatusIcon(itemId, statusLabel);
statusLabel.setDescription(getDescription(itemId));
statusLabel.setSizeUndefined();
addPropertyChangeListener(itemId, statusLabel);
return statusLabel;
}
private void addPropertyChangeListener(final Object itemId, final Label statusLabel) {
final Property status = getContainerProperty(itemId, SPUILabelDefinitions.VAR_STATUS);
final Property.ValueChangeNotifier notifier = (Property.ValueChangeNotifier) status;
notifier.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {
setStatusIcon(itemId, statusLabel);
}
});
}
private String getDescription(final Object itemId) {
final Item item = getItem(itemId);
if (item != null) {
final RolloutGroupStatus rolloutGroupStatus = (RolloutGroupStatus) item
.getItemProperty(SPUILabelDefinitions.VAR_STATUS).getValue();
return rolloutGroupStatus.toString().toLowerCase();
}
return null;
}
private void setStatusIcon(final Object itemId, final Label statusLabel) {
final Item item = getItem(itemId);
if (item != null) {
final RolloutGroupStatus rolloutGroupStatus = (RolloutGroupStatus) item
.getItemProperty(SPUILabelDefinitions.VAR_STATUS).getValue();
setRolloutStatusIcon(rolloutGroupStatus, statusLabel);
}
}
private void setRolloutStatusIcon(final RolloutGroupStatus rolloutGroupStatus, final Label statusLabel) {
switch (rolloutGroupStatus) {
case FINISHED:
statusLabel.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
statusLabel.setStyleName("statusIconGreen");
break;
case SCHEDULED:
statusLabel.setValue(FontAwesome.BULLSEYE.getHtml());
statusLabel.setStyleName("statusIconBlue");
break;
case RUNNING:
statusLabel.setValue(FontAwesome.ADJUST.getHtml());
statusLabel.setStyleName("statusIconYellow");
break;
case READY:
statusLabel.setValue(FontAwesome.DOT_CIRCLE_O.getHtml());
statusLabel.setStyleName("statusIconLightBlue");
break;
case ERROR:
statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
statusLabel.setStyleName("statusIconRed");
break;
default:
break;
}
statusLabel.addStyleName(ValoTheme.LABEL_SMALL);
}
private Component getRolloutNameLink(final Object itemId) {
final Item row = getItem(itemId);
final String rolloutGroupName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
if (permissionChecker.hasRolloutTargetsReadPermission()) {
final Button rolloutGroupNameLink = SPUIComponentProvider.getButton(getDetailLinkId(rolloutGroupName),
rolloutGroupName, SPUILabelDefinitions.SHOW_ROLLOUT_GROUP_DETAILS, null, false, null,
SPUIButtonStyleSmallNoBorder.class);
rolloutGroupNameLink.setData(rolloutGroupName);
rolloutGroupNameLink.addStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link");
rolloutGroupNameLink.addClickListener(event -> showRolloutGroups(itemId));
return rolloutGroupNameLink;
} else {
final Label rolloutGroupNameLabel = new Label();
rolloutGroupNameLabel.setHeightUndefined();
rolloutGroupNameLabel.addStyleName(ValoTheme.LABEL_SMALL);
rolloutGroupNameLabel.setValue(rolloutGroupName);
return rolloutGroupNameLabel;
}
}
private void showRolloutGroups(final Object itemId) {
rolloutUIState.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) itemId));
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
}
private DistributionBar getProgressBar(final Object itemId) {
final DistributionBar bar = new DistributionBar(2);
bar.setSizeFull();
bar.setZeroSizedVisible(false);
HawkbitCommonUtil.initialiseProgressBar(bar, getItem(itemId));
addPropertyChangeListenerOnActionRecieved(itemId, bar);
return bar;
}
private void addPropertyChangeListenerOnActionRecieved(final Object itemId, final DistributionBar bar) {
final Property status = getContainerProperty(itemId, IS_ACTION_RECIEVED);
final Property.ValueChangeNotifier notifier = (Property.ValueChangeNotifier) status;
notifier.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {
HawkbitCommonUtil.initialiseProgressBar(bar, getItem(itemId));
}
});
}
private static String getDetailLinkId(final String rolloutGroupName) {
return new StringBuilder(SPUIComponetIdProvider.ROLLOUT_GROUP_NAME_LINK_ID).append('.').append(rolloutGroupName)
.toString();
}
@Override
protected void setCollapsiblecolumns() {
setColumnCollapsed(SPUILabelDefinitions.VAR_CREATED_DATE, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_MODIFIED_DATE, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_CREATED_USER, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_MODIFIED_BY, true);
}
}

View File

@@ -1,231 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Label;
import com.vaadin.ui.themes.ValoTheme;
/**
* Rollout Group Targets Table in List view.
*
*/
@SpringComponent
@ViewScope
public class RolloutGroupTargetsListTable extends AbstractSimpleTable {
private static final long serialVersionUID = 7984314603271801746L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient RolloutUIState rolloutUIState;
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) {
if (event == RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS) {
((LazyQueryContainer) getContainerDataSource()).refresh();
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS_COUNT);
}
}
@Override
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = new ArrayList<>();
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.15f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.15f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.15f));
columnList
.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.15f));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.15f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.15f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_TARGET_STATUS, i18n.get("header.status"), 0.1f));
return columnList;
}
@Override
protected Container createContainer() {
final BeanQueryFactory<RolloutGroupTargetsBeanQuery> rolloutgrouBeanQueryFactory = new BeanQueryFactory<>(
RolloutGroupTargetsBeanQuery.class);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID),
rolloutgrouBeanQueryFactory);
}
@Override
protected void addContainerProperties(final Container container) {
final LazyQueryContainer rolloutGroupTargetTableContainer = (LazyQueryContainer) container;
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CONT_ID, String.class, "", false,
false);
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false,
true);
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, Status.class,
Status.RETRIEVED, false, false);
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS,
TargetUpdateStatus.class, TargetUpdateStatus.UNKNOWN, false, false);
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
String.class, "", false, true);
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null,
false, true);
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class,
null, false, true);
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null,
false, true);
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class,
null, false, true);
rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false,
true);
}
@Override
protected String getTableId() {
return SPUIComponetIdProvider.ROLLOUT_GROUP_TARGETS_LIST_TABLE_ID;
}
@Override
protected void onValueChange() {
// No implementation required.
}
@Override
protected void addCustomGeneratedColumns() {
addGeneratedColumn(SPUILabelDefinitions.VAR_TARGET_STATUS,
(source, itemId, columnId) -> getStatusLabel(itemId));
setColumnAlignment(SPUILabelDefinitions.VAR_TARGET_STATUS, Align.CENTER);
}
@Override
protected void setCollapsiblecolumns() {
// No implementation required.
}
private Label getStatusLabel(final Object itemId) {
final Label statusLabel = new Label();
statusLabel.addStyleName(ValoTheme.LABEL_SMALL);
statusLabel.setHeightUndefined();
statusLabel.setContentMode(ContentMode.HTML);
setStatusIcon(itemId, statusLabel);
statusLabel.setSizeUndefined();
return statusLabel;
}
private void setStatusIcon(final Object itemId, final Label statusLabel) {
final Item item = getItem(itemId);
final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent()
? rolloutUIState.getRolloutGroup().get() : null;
if (item != null) {
final Status status = (Status) item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).getValue();
if (status == null) {
if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.READY) {
statusLabel.setValue(FontAwesome.DOT_CIRCLE_O.getHtml());
statusLabel.addStyleName("statusIconLightBlue");
statusLabel.setDescription(RolloutGroupStatus.READY.toString().toLowerCase());
} else if (rolloutGroup != null && rolloutGroup.getStatus() == RolloutGroupStatus.FINISHED) {
statusLabel.setValue(FontAwesome.MINUS_CIRCLE.getHtml());
statusLabel.addStyleName("statusIconBlue");
final String dsNameVersion = (String) item
.getItemProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER).getValue();
statusLabel
.setDescription(i18n.get("message.dist.already.assigned", new Object[] { dsNameVersion }));
}
} else {
setRolloutStatusIcon(status, statusLabel);
statusLabel.setDescription(status.toString().toLowerCase());
}
}
}
private void setRolloutStatusIcon(final Status targetUpdateStatus, final Label statusLabel) {
switch (targetUpdateStatus) {
case ERROR:
statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
statusLabel.addStyleName("statusIconRed");
break;
case SCHEDULED:
statusLabel.setValue(FontAwesome.BULLSEYE.getHtml());
statusLabel.addStyleName("statusIconBlue");
break;
case FINISHED:
statusLabel.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
statusLabel.addStyleName("statusIconGreen");
break;
case RUNNING:
case RETRIEVED:
case WARNING:
case DOWNLOAD:
statusLabel.setValue(FontAwesome.ADJUST.getHtml());
statusLabel.addStyleName("statusIconYellow");
break;
case CANCELED:
statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
statusLabel.addStyleName("statusIconGreen");
break;
case CANCELING:
statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml());
statusLabel.addStyleName("statusIconPending");
break;
default:
break;
}
}
}

View File

@@ -1,552 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.TableColumn;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
import org.vaadin.alump.distributionbar.DistributionBar;
import org.vaadin.peter.contextmenu.ContextMenu;
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItem;
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItemClickEvent;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.ValoTheme;
/**
*
* Rollout table in list view.
*
*/
@SpringComponent
@ViewScope
public class RolloutListTable extends AbstractSimpleTable {
private static final String IS_ACTION_RECIEVED = "isActionRecieved";
private static final long serialVersionUID = 8141874975649180139L;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@Autowired
private transient RolloutManagement rolloutManagement;
@Autowired
private AddUpdateRolloutWindowLayout addUpdateRolloutWindow;
@Autowired
private UINotification uiNotification;
@Autowired
private transient RolloutUIState rolloutUIState;
@Autowired
private transient SpPermissionChecker permissionChecker;
@Override
@PostConstruct
protected void init() {
super.init();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) {
if (event == RolloutEvent.FILTER_BY_TEXT || event == RolloutEvent.CREATE_ROLLOUT
|| event == RolloutEvent.UPDATE_ROLLOUT || event == RolloutEvent.SHOW_ROLLOUTS) {
refreshTable();
}
}
/**
* Handles the RolloutChangeEvent to refresh the item in the table.
*
* @param rolloutChangeEvent
* the event which contains the rollout which has been changed
*/
@EventBusListenerMethod(scope = EventScope.SESSION)
public void onEvent(final RolloutChangeEvent rolloutChangeEvent) {
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
if (visibleItemIds.contains(rolloutChangeEvent.getRolloutId())) {
final Rollout rollout = rolloutManagement.findRolloutWithDetailedStatus(rolloutChangeEvent.getRolloutId());
final TotalTargetCountStatus totalTargetCountStatus = rollout.getTotalTargetCountStatus();
final LazyQueryContainer rolloutContainer = (LazyQueryContainer) getContainerDataSource();
final Item item = rolloutContainer.getItem(rolloutChangeEvent.getRolloutId());
item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rollout.getStatus());
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_RUNNING).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.RUNNING));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_ERROR).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.ERROR));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_FINISHED).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.FINISHED));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_NOT_STARTED).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.NOTSTARTED));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_CANCELLED).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.CANCELLED));
item.getItemProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_SCHEDULED).setValue(
totalTargetCountStatus.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.SCHEDULED));
item.getItemProperty(IS_ACTION_RECIEVED).setValue(
!(Boolean) item.getItemProperty(IS_ACTION_RECIEVED).getValue());
final Long groupCount = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).getValue();
if (null != rollout.getRolloutGroups() && groupCount != rollout.getRolloutGroups().size()) {
item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setValue(
Long.valueOf(rollout.getRolloutGroups().size()));
}
}
}
@Override
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = new ArrayList<>();
columnList.add(new TableColumn(SPUIDefinitions.ROLLOUT_NAME, i18n.get("header.name"), 0.225f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, i18n.get("header.distributionset"),
0.225f));
columnList.add(new TableColumn(SPUIDefinitions.ROLLOUT_STATUS, i18n.get("header.status"), 0.07f));
columnList.add(new TableColumn(SPUIDefinitions.DETAIL_STATUS, i18n.get("header.detail.status"), 0.58f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, i18n.get("header.numberofgroups"),
0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS, i18n.get("header.total.targets"), 0.1f));
columnList.add(new TableColumn(SPUIDefinitions.ROLLOUT_ACTION, i18n.get("upload.action"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_USER, i18n.get("header.createdBy"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1f));
return columnList;
}
@Override
protected Container createContainer() {
final BeanQueryFactory<RolloutBeanQuery> rolloutQf = new BeanQueryFactory<>(RolloutBeanQuery.class);
return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE,
SPUILabelDefinitions.VAR_ID), rolloutQf);
}
@Override
protected void addContainerProperties(final Container container) {
final LazyQueryContainer rolloutTableContainer = (LazyQueryContainer) container;
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_ID, String.class, null, false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false,
false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null,
false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_TARGETFILTERQUERY, String.class, null,
false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false,
false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_DATE, String.class, null, false,
false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_USER, String.class, null, false,
false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false,
false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, Integer.class, 0, false,
false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_NOT_STARTED, Long.class, 0L,
false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_RUNNING, Long.class, 0L,
false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_SCHEDULED, Long.class, 0L,
false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_ERROR, Long.class, 0L, false,
false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_FINISHED, Long.class, 0L,
false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_COUNT_TARGETS_CANCELLED, Long.class, 0L,
false, false);
rolloutTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false,
false);
}
@Override
protected String getTableId() {
return SPUIComponetIdProvider.ROLLOUT_LIST_TABLE_ID;
}
@Override
protected void onValueChange() {
/**
* No implementation required.
*/
}
@Override
protected void addCustomGeneratedColumns() {
addGeneratedColumn(SPUIDefinitions.ROLLOUT_NAME, (source, itemId, columnId) -> getRolloutNameLink(itemId));
addGeneratedColumn(SPUIDefinitions.ROLLOUT_STATUS, (source, itemId, columnId) -> getStatusLabel(itemId));
addGeneratedColumn(SPUIDefinitions.DETAIL_STATUS, (source, itemId, columnId) -> getProgressBar(itemId));
addGeneratedColumn(SPUIDefinitions.ROLLOUT_ACTION, (source, itemId, columnId) -> getActionButton(itemId));
setColumnAlignment(SPUIDefinitions.ROLLOUT_STATUS, Align.CENTER);
setColumnAlignment(SPUIDefinitions.DETAIL_STATUS, Align.CENTER);
setColumnAlignment(SPUIDefinitions.ROLLOUT_ACTION, Align.CENTER);
}
@Override
protected void setCollapsiblecolumns() {
setColumnCollapsed(SPUILabelDefinitions.VAR_CREATED_DATE, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_MODIFIED_DATE, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_CREATED_USER, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_MODIFIED_BY, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_DESC, true);
}
private Button getActionButton(final Object itemId) {
final Item row = getItem(itemId);
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
final Button actionButton = SPUIComponentProvider.getButton(getActionButtonId(rolloutName), "",
SPUILabelDefinitions.ACTION, ValoTheme.BUTTON_TINY + " ", true, FontAwesome.CIRCLE_O,
SPUIButtonStyleSmallNoBorder.class);
actionButton.setData(itemId);
actionButton.setHtmlContentAllowed(true);
actionButton.addClickListener(event -> onAction(event));
addStatusPropertyChangeListener(itemId, actionButton);
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
.getValue();
enableDisableActions(rolloutStatus, actionButton);
return actionButton;
}
private void enableDisableActions(final RolloutStatus rolloutStatus, final Button actionButton) {
final RolloutStatus[] statusList = new RolloutStatus[] { RolloutStatus.FINISHED, RolloutStatus.STARTING,
RolloutStatus.CREATING, RolloutStatus.ERROR_CREATING, RolloutStatus.ERROR_STARTING };
if (Arrays.asList(statusList).contains(rolloutStatus)) {
actionButton.setEnabled(false);
} else {
actionButton.setEnabled(true);
}
}
private void addStatusPropertyChangeListener(final Object itemId, final Button actionButton) {
final Property status = getContainerProperty(itemId, SPUILabelDefinitions.VAR_STATUS);
final Property.ValueChangeNotifier notifier = (Property.ValueChangeNotifier) status;
notifier.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {
final Item row = getItem(itemId);
final RolloutStatus rolloutStatus = (RolloutStatus) row
.getItemProperty(SPUILabelDefinitions.VAR_STATUS).getValue();
enableDisableActions(rolloutStatus, actionButton);
}
});
}
private ContextMenu createContextMenu(final Long rolloutId) {
final Item row = getItem(rolloutId);
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
.getValue();
final ContextMenu context = new ContextMenu();
context.addItemClickListener(event -> menuItemClicked(event));
if (rolloutStatus == RolloutStatus.READY) {
final ContextMenuItem startItem = context.addItem("Start");
startItem.setData(new ContextMenuData(rolloutId, ACTION.START));
} else if (rolloutStatus == RolloutStatus.RUNNING) {
final ContextMenuItem pauseItem = context.addItem("Pause");
pauseItem.setData(new ContextMenuData(rolloutId, ACTION.PAUSE));
} else if (rolloutStatus == RolloutStatus.PAUSED) {
final ContextMenuItem resumeItem = context.addItem("Resume");
resumeItem.setData(new ContextMenuData(rolloutId, ACTION.RESUME));
} else if (rolloutStatus == RolloutStatus.STARTING || rolloutStatus == RolloutStatus.CREATING) {
return context;
}
if (permissionChecker.hasRolloutUpdatePermission()) {
final ContextMenuItem cancelItem = context.addItem("Update");
cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE));
}
return context;
}
private void menuItemClicked(final ContextMenuItemClickEvent event) {
final ContextMenuItem item = (ContextMenuItem) event.getSource();
final ContextMenuData contextMenuData = (ContextMenuData) item.getData();
final Item row = getItem(contextMenuData.getRolloutId());
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
if (contextMenuData.getAction() == ACTION.PAUSE) {
rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId()));
uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName));
} else if (contextMenuData.getAction() == ACTION.RESUME) {
rolloutManagement.resumeRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId()));
uiNotification.displaySuccess(i18n.get("message.rollout.resumed", rolloutName));
} else if (contextMenuData.getAction() == ACTION.START) {
rolloutManagement.startRolloutAsync(rolloutManagement.findRolloutByName(rolloutName));
uiNotification.displaySuccess(i18n.get("message.rollout.started", rolloutName));
} else if (contextMenuData.getAction() == ACTION.UPDATE) {
addUpdateRolloutWindow.populateData(contextMenuData.getRolloutId());
final Window addTargetWindow = addUpdateRolloutWindow.getWindow();
addTargetWindow.setCaption(i18n.get("caption.update.rollout"));
UI.getCurrent().addWindow(addTargetWindow);
addTargetWindow.setVisible(Boolean.TRUE);
}
}
private void onAction(final ClickEvent event) {
final ContextMenu contextMenu = createContextMenu((Long) event.getButton().getData());
contextMenu.setAsContextMenuOf(event.getButton());
contextMenu.open(event.getClientX(), event.getClientY());
}
private Button getRolloutNameLink(final Object itemId) {
final Item row = getItem(itemId);
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
final Button updateIcon = SPUIComponentProvider.getButton(getDetailLinkId(rolloutName), rolloutName,
SPUILabelDefinitions.SHOW_ROLLOUT_GROUP_DETAILS, null, false, null, SPUIButtonStyleSmallNoBorder.class);
updateIcon.setData(rolloutName);
updateIcon.addStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link");
updateIcon.addClickListener(event -> showRolloutGroups(itemId));
return updateIcon;
}
private void showRolloutGroups(final Object itemId) {
rolloutUIState.setRolloutId((long) itemId);
final String rolloutName = (String) getItem(itemId).getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
rolloutUIState.setRolloutName(rolloutName);
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS);
}
private static String getActionButtonId(final String rollOutName) {
return new StringBuilder(SPUIComponetIdProvider.ROLLOUT_ACTION_BUTTON_ID).append('.').append(rollOutName)
.toString();
}
private static String getDetailLinkId(final String rollOutName) {
return new StringBuilder(SPUIComponetIdProvider.ROLLOUT_NAME_LINK_ID).append('.').append(rollOutName)
.toString();
}
private DistributionBar getProgressBar(final Object itemId) {
final DistributionBar bar = new DistributionBar(2);
bar.setId(SPUIComponetIdProvider.ROLLOUT_PROGRESS_BAR);
bar.setSizeFull();
bar.setZeroSizedVisible(false);
HawkbitCommonUtil.initialiseProgressBar(bar, getItem(itemId));
addPropertyChangeListenerOnActionRecieved(itemId, bar);
return bar;
}
private void addPropertyChangeListenerOnActionRecieved(final Object itemId, final DistributionBar bar) {
final Property status = getContainerProperty(itemId, IS_ACTION_RECIEVED);
final Property.ValueChangeNotifier notifier = (Property.ValueChangeNotifier) status;
notifier.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {
HawkbitCommonUtil.initialiseProgressBar(bar, getItem(itemId));
}
});
}
private Label getStatusLabel(final Object itemId) {
final Label statusLabel = new Label();
statusLabel.setHeightUndefined();
statusLabel.setContentMode(ContentMode.HTML);
statusLabel.setId(getRolloutStatusId(itemId));
setStatusIcon(itemId, statusLabel);
statusLabel.setSizeUndefined();
addPropertyChangeListener(itemId, statusLabel);
return statusLabel;
}
private void addPropertyChangeListener(final Object itemId, final Label statusLabel) {
final Property status = getContainerProperty(itemId, SPUILabelDefinitions.VAR_STATUS);
final Property.ValueChangeNotifier notifier = (Property.ValueChangeNotifier) status;
notifier.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {
setStatusIcon(itemId, statusLabel);
}
});
}
private String getRolloutStatusId(final Object itemId) {
final String rolloutName = (String) getItem(itemId).getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
return new StringBuilder(SPUIComponetIdProvider.ROLLOUT_STATUS_LABEL_ID).append(".").append(rolloutName)
.toString();
}
private void setStatusIcon(final Object itemId, final Label statusLabel) {
final Item item = getItem(itemId);
if (item != null) {
final RolloutStatus rolloutStatus = (RolloutStatus) item.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
.getValue();
setRolloutStatusIcon(rolloutStatus, statusLabel);
}
}
private void setRolloutStatusIcon(final RolloutStatus rolloutStatus, final Label statusLabel) {
statusLabel.setDescription(rolloutStatus.toString().toLowerCase());
switch (rolloutStatus) {
case FINISHED:
statusLabel.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
statusLabel.setStyleName("statusIconGreen");
break;
case PAUSED:
statusLabel.setValue(FontAwesome.PAUSE.getHtml());
statusLabel.setStyleName("statusIconBlue");
break;
case RUNNING:
statusLabel.setValue(null);
statusLabel.setStyleName("yellowSpinner");
break;
case READY:
statusLabel.setValue(FontAwesome.DOT_CIRCLE_O.getHtml());
statusLabel.setStyleName("statusIconLightBlue");
break;
case STOPPED:
statusLabel.setValue(FontAwesome.STOP.getHtml());
statusLabel.setStyleName("statusIconRed");
break;
case CREATING:
statusLabel.setValue(null);
statusLabel.setStyleName("greySpinner");
break;
case STARTING:
statusLabel.setValue(null);
statusLabel.setStyleName("blueSpinner");
break;
case ERROR_CREATING:
statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
statusLabel.setStyleName("statusIconRed");
statusLabel.setDescription(i18n.get("message.error.creating.rollout"));
break;
case ERROR_STARTING:
statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
statusLabel.setStyleName("statusIconRed");
statusLabel.setDescription(i18n.get("message.error.starting.rollout"));
break;
default:
break;
}
statusLabel.addStyleName(ValoTheme.LABEL_SMALL);
}
private void refreshTable() {
final LazyQueryContainer container = (LazyQueryContainer) getContainerDataSource();
container.refresh();
}
enum ACTION {
PAUSE, RESUME, START, UPDATE
}
/**
* Represents data of context menu item.
*
*/
public static class ContextMenuData {
private Long rolloutId;
private ACTION action;
/**
* Set rollout if and action.
*
* @param rolloutId
* id of rollout
* @param action
* user action {@link ACTION}
*/
public ContextMenuData(final Long rolloutId, final ACTION action) {
this.action = action;
this.rolloutId = rolloutId;
}
/**
* @return the rolloutId
*/
public Long getRolloutId() {
return rolloutId;
}
/**
* @param rolloutId
* the rolloutId to set
*/
public void setRolloutId(final Long rolloutId) {
this.rolloutId = rolloutId;
}
/**
* @return the action
*/
public ACTION getAction() {
return action;
}
/**
* @param action
* the action to set
*/
public void setAction(final ACTION action) {
this.action = action;
}
}
}

View File

@@ -13,6 +13,9 @@ import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.rollout.RolloutListView;
import org.eclipse.hawkbit.ui.rollout.rolloutgroup.RolloutGroupsListView;
import org.eclipse.hawkbit.ui.rollout.rolloutgrouptargets.RolloutGroupTargetsListView;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rollout;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -646,7 +646,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
}
private Container createDsComboContainer() {
final BeanQueryFactory<DistBeanQuery> distributionQF = new BeanQueryFactory<>(DistBeanQuery.class);
final BeanQueryFactory<DistributionBeanQuery> distributionQF = new BeanQueryFactory<>(DistributionBeanQuery.class);
return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE,
SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF);

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rollout;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -34,7 +34,7 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
* Bean query for distribution set combo.
*
*/
public class DistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
private static final long serialVersionUID = 5176481314404662215L;
private Sort sort = new Sort(Direction.ASC, "name", "version");
@@ -53,7 +53,7 @@ public class DistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
* @param sortStates
* as Sort status
*/
public DistBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
public DistributionBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortPropertyIds, final boolean[] sortStates) {
super(definition, queryConfig, sortPropertyIds, sortStates);

View File

@@ -6,10 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
import java.util.HashMap;
import java.util.Map;
package org.eclipse.hawkbit.ui.rollout.rollout;
import org.eclipse.hawkbit.repository.model.Rollout;
@@ -35,13 +32,6 @@ public class ProxyRollout extends Rollout {
private String totalTargetsCount;
//TODO remove this
private DistributionBarDetails distributionBarDetails ;
//TODO remove this
private Map<String,Long> statusTotalCountMap = new HashMap<>();
/**
* @return the distributionSetNameVersion
*/
@@ -132,26 +122,9 @@ public class ProxyRollout extends Rollout {
this.totalTargetsCount = totalTargetsCount;
}
public Map<String, Long> getStatusTotalCountMap() {
return statusTotalCountMap;
}
public void setStatusTotalCountMap(Map<String, Long> statusTotalCountMap) {
this.statusTotalCountMap = statusTotalCountMap;
}
public DistributionBarDetails getDistributionBarDetails() {
return distributionBarDetails;
}
public void setDistributionBarDetails(DistributionBarDetails distributionBarDetails) {
this.distributionBarDetails = distributionBarDetails;
}
public String getAction() {
return FontAwesome.CIRCLE_O.getHtml();
}
}

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rollout;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rollout;
import java.util.ArrayList;
import java.util.Arrays;
@@ -14,11 +14,11 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.LinkRenderer;
import org.eclipse.hawkbit.ui.rollout.RolloutListTable.ACTION;
import org.eclipse.hawkbit.ui.rollout.RolloutListTable.ContextMenuData;
import org.eclipse.hawkbit.ui.rollout.DistributionBarHelper;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -44,18 +44,19 @@ import com.vaadin.data.util.PropertyValueGenerator;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.server.AbstractClientConnector;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.Page;
import com.vaadin.server.Page.BrowserWindowResizeEvent;
import com.vaadin.server.Page.BrowserWindowResizeListener;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Grid.CellDescriptionGenerator;
import com.vaadin.ui.Grid.CellReference;
import com.vaadin.ui.Grid.CellStyleGenerator;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
import com.vaadin.ui.renderers.HtmlRenderer;
@SpringComponent
@ViewScope
public class RolloutListGrid extends AbstractSimpleGrid implements BrowserWindowResizeListener {
public class RolloutListGrid extends AbstractGrid {
private static final long serialVersionUID = 4060904914954370524L;
@Autowired
@@ -84,8 +85,6 @@ public class RolloutListGrid extends AbstractSimpleGrid implements BrowserWindow
protected void init() {
super.init();
eventBus.subscribe(this);
Page.getCurrent().addBrowserWindowResizeListener(this);
}
@PreDestroy
@@ -186,6 +185,8 @@ public class RolloutListGrid extends AbstractSimpleGrid implements BrowserWindow
getColumn(SPUILabelDefinitions.ACTION).setMinimumWidth(75);
getColumn(SPUILabelDefinitions.ACTION).setMaximumWidth(75);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280);
setFrozenColumnCount(getColumns().size());
}
@@ -231,6 +232,25 @@ public class RolloutListGrid extends AbstractSimpleGrid implements BrowserWindow
alignColumns();
}
@Override
protected void setHiddenColumns() {
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) {
getColumn(propertyId).setHidden(true);
}
}
@Override
protected CellDescriptionGenerator getDescriptionGenerator() {
return cell -> getDescription(cell);
}
private void alignColumns() {
setCellStyleGenerator(new CellStyleGenerator() {
private static final long serialVersionUID = 5573570647129792429L;
@@ -238,7 +258,9 @@ public class RolloutListGrid extends AbstractSimpleGrid implements BrowserWindow
@Override
public String getStyle(final CellReference cellReference) {
String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS,
SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS, SPUILabelDefinitions.ACTION };
/*
* SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS,
*/ SPUILabelDefinitions.ACTION };
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
return "centeralign";
}
@@ -298,8 +320,7 @@ public class RolloutListGrid extends AbstractSimpleGrid implements BrowserWindow
}
private void addDetailStatusColumn() {
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(
new org.eclipse.hawkbit.ui.customrenderers.renderers.StringDistributionBarRenderer(),
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
new Converter<String, TotalTargetCountStatus>() {
private static final long serialVersionUID = 2660476405836705932L;
@@ -314,7 +335,7 @@ public class RolloutListGrid extends AbstractSimpleGrid implements BrowserWindow
public String convertToPresentation(TotalTargetCountStatus value,
Class<? extends String> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return HawkbitCommonUtil.getFormattedString(value.getStatusTotalCountMap());
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
}
@Override
@@ -454,39 +475,6 @@ public class RolloutListGrid extends AbstractSimpleGrid implements BrowserWindow
}
}
@Override
public void browserWindowResized(BrowserWindowResizeEvent event) {
// Intermediate solution for the column width problem for
// SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS column
// Readding the column
recalculateColumnWidths();
removeColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
addColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS)
.setHeaderCaption(i18n.get("header.detail.status"));
setColumnProperties();
addDetailStatusColumn();
}
@Override
protected void setHiddenColumns() {
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) {
getColumn(propertyId).setHidden(true);
}
}
@Override
protected CellDescriptionGenerator getDescriptionGenerator() {
return cell -> getDescription(cell);
}
private String getDescription(CellReference cell) {
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString().toLowerCase();
@@ -494,9 +482,71 @@ public class RolloutListGrid extends AbstractSimpleGrid implements BrowserWindow
return SPUILabelDefinitions.ACTION.toLowerCase();
} else if (SPUILabelDefinitions.VAR_NAME.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString();
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
return DistributionBarHelper
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
} else {
return null;
}
}
enum ACTION {
PAUSE, RESUME, START, UPDATE
}
/**
* Represents data of context menu item.
*
*/
public static class ContextMenuData {
private Long rolloutId;
private ACTION action;
/**
* Set rollout if and action.
*
* @param rolloutId
* id of rollout
* @param action
* user action {@link ACTION}
*/
public ContextMenuData(final Long rolloutId, final ACTION action) {
this.action = action;
this.rolloutId = rolloutId;
}
/**
* @return the rolloutId
*/
public Long getRolloutId() {
return rolloutId;
}
/**
* @param rolloutId
* the rolloutId to set
*/
public void setRolloutId(final Long rolloutId) {
this.rolloutId = rolloutId;
}
/**
* @return the action
*/
public ACTION getAction() {
return action;
}
/**
* @param action
* the action to set
*/
public void setAction(final ACTION action) {
this.action = action;
}
}
}

View File

@@ -6,11 +6,12 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rollout;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
@@ -35,7 +36,7 @@ import com.vaadin.ui.Window;
*/
@SpringComponent
@ViewScope
public class RolloutListHeader extends AbstractSimpleTableHeader {
public class RolloutListHeader extends AbstractGridHeader {
private static final long serialVersionUID = 2365400733081333174L;
@Autowired

View File

@@ -6,10 +6,11 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rollout;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.common.grid.AbstractGridLayout;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -23,7 +24,7 @@ import com.vaadin.ui.Label;
*/
@SpringComponent
@ViewScope
public class RolloutListView extends AbstractSimpleTableLayout {
public class RolloutListView extends AbstractGridLayout {
private static final long serialVersionUID = -2703552177439393208L;
@@ -40,7 +41,6 @@ public class RolloutListView extends AbstractSimpleTableLayout {
@Override
protected boolean hasCountMessage() {
return false;
}

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup;

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
import java.util.ArrayList;
import java.util.List;
@@ -28,7 +28,8 @@ import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
/**
* @author gah6kor
* Simple implementation of generics bean query which dynamically loads a batch
* of {@link ProxyRolloutGroup} beans.
*
*/
public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup> {

View File

@@ -1,4 +1,4 @@
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
import java.util.ArrayList;
import java.util.Arrays;
@@ -14,9 +14,10 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.LinkRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.StringDistributionBarRenderer;
import org.eclipse.hawkbit.ui.rollout.DistributionBarHelper;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -36,18 +37,14 @@ import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.Page;
import com.vaadin.server.Page.BrowserWindowResizeEvent;
import com.vaadin.server.Page.BrowserWindowResizeListener;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Grid.CellDescriptionGenerator;
import com.vaadin.ui.Grid.CellReference;
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
import com.vaadin.ui.renderers.HtmlRenderer;
@SpringComponent
@ViewScope
public class RolloutGroupListGrid extends AbstractSimpleGrid implements BrowserWindowResizeListener {
public class RolloutGroupListGrid extends AbstractGrid {
private static final long serialVersionUID = 4060904914954370524L;
@Autowired
@@ -69,7 +66,6 @@ public class RolloutGroupListGrid extends AbstractSimpleGrid implements BrowserW
@PostConstruct
protected void init() {
super.init();
Page.getCurrent().addBrowserWindowResizeListener(this);
eventBus.subscribe(this);
}
@@ -169,6 +165,8 @@ public class RolloutGroupListGrid extends AbstractSimpleGrid implements BrowserW
getColumn(SPUILabelDefinitions.ROLLOUT_GROUP_THRESHOLD).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.ROLLOUT_GROUP_THRESHOLD).setMaximumWidth(100);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280);
setFrozenColumnCount(7);
}
@@ -242,6 +240,24 @@ public class RolloutGroupListGrid extends AbstractSimpleGrid implements BrowserW
}
}
@Override
protected void setHiddenColumns() {
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) {
getColumn(propertyId).setHidden(true);
}
}
@Override
protected CellDescriptionGenerator getDescriptionGenerator() {
return cell -> getDescription(cell);
};
private void onClickOfRolloutGroupName(RendererClickEvent event) {
rolloutUIState
.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
@@ -313,7 +329,7 @@ public class RolloutGroupListGrid extends AbstractSimpleGrid implements BrowserW
}
private void addDetailStatusColumn() {
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new StringDistributionBarRenderer(),
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
new Converter<String, TotalTargetCountStatus>() {
private static final long serialVersionUID = 2660476405836705932L;
@@ -328,7 +344,7 @@ public class RolloutGroupListGrid extends AbstractSimpleGrid implements BrowserW
public String convertToPresentation(TotalTargetCountStatus value,
Class<? extends String> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return HawkbitCommonUtil.getFormattedString(value.getStatusTotalCountMap());
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
}
@Override
@@ -343,38 +359,6 @@ public class RolloutGroupListGrid extends AbstractSimpleGrid implements BrowserW
});
}
@Override
protected void setHiddenColumns() {
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) {
getColumn(propertyId).setHidden(true);
}
}
@Override
public void browserWindowResized(BrowserWindowResizeEvent event) {
// Intermediate solution for the column width problem for
// SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS column
// Readding the column
recalculateColumnWidths();
removeColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
addColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS)
.setHeaderCaption(i18n.get("header.detail.status"));
setColumnProperties();
addDetailStatusColumn();
}
@Override
protected CellDescriptionGenerator getDescriptionGenerator() {
return cell -> getDescription(cell);
};
private String getDescription(CellReference cell) {
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString().toLowerCase();
@@ -382,6 +366,9 @@ public class RolloutGroupListGrid extends AbstractSimpleGrid implements BrowserW
return SPUILabelDefinitions.ACTION.toLowerCase();
} else if (SPUILabelDefinitions.VAR_NAME.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString();
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
return DistributionBarHelper
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
} else {
return null;
}

View File

@@ -6,11 +6,12 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
@@ -37,7 +38,7 @@ import com.vaadin.ui.themes.ValoTheme;
*/
@SpringComponent
@ViewScope
public class RolloutGroupsListHeader extends AbstractSimpleTableHeader {
public class RolloutGroupsListHeader extends AbstractGridHeader {
private static final long serialVersionUID = 5077741997839715209L;

View File

@@ -6,10 +6,11 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.common.grid.AbstractGridLayout;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -22,7 +23,7 @@ import com.vaadin.ui.Label;
*/
@SpringComponent
@ViewScope
public class RolloutGroupsListView extends AbstractSimpleTableLayout {
public class RolloutGroupsListView extends AbstractGridLayout {
private static final long serialVersionUID = 7252345838154270259L;

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgrouptargets;
import java.util.ArrayList;
import java.util.List;

View File

@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgrouptargets;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@@ -37,16 +37,13 @@ import com.vaadin.ui.Label;
@ViewScope
public class RolloutGroupTargetsCountLabelMessage extends Label {
/**
*
*/
private static final long serialVersionUID = -3876685878918411453L;
@Autowired
private transient RolloutUIState rolloutUIState;
@Autowired
private transient RolloutGroupTargetsListTable rolloutGroupTargetsListTable;
private transient RolloutGroupTargetsListGrid rolloutGroupTargetsListGrid;
@Autowired
private I18N i18n;
@@ -93,7 +90,7 @@ public class RolloutGroupTargetsCountLabelMessage extends Label {
}
private void displayRolloutGroupTargetMessage() {
long totalTargetTableEnteries = rolloutGroupTargetsListTable.size();
long totalTargetTableEnteries = rolloutGroupTargetsListGrid.getContainerDataSource().size();
if (rolloutUIState.getRolloutGroupTargetsTruncated() != null) {
// set the icon
setIcon(FontAwesome.INFO_CIRCLE);
@@ -113,7 +110,7 @@ public class RolloutGroupTargetsCountLabelMessage extends Label {
message.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
} else {
message.append(i18n.get("label.filter.shown"));
message.append(rolloutGroupTargetsListTable.size());
message.append(rolloutGroupTargetsListGrid.getContainerDataSource().size());
}
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
setCaption(message.toString());

View File

@@ -1,4 +1,4 @@
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgrouptargets;
import java.util.ArrayList;
import java.util.List;
@@ -10,6 +10,7 @@ import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
@@ -31,12 +32,10 @@ import com.vaadin.data.util.converter.Converter;
import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Grid.CellDescriptionGenerator;
import com.vaadin.ui.Grid.CellReference;
@SpringComponent
@ViewScope
public class RolloutGroupTargetsListGrid extends AbstractSimpleGrid {
public class RolloutGroupTargetsListGrid extends AbstractGrid {
private static final long serialVersionUID = -2244756637458984597L;

View File

@@ -6,12 +6,13 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgrouptargets;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
@@ -38,7 +39,7 @@ import com.vaadin.ui.themes.ValoTheme;
*/
@SpringComponent
@ViewScope
public class RolloutGroupTargetsListHeader extends AbstractSimpleTableHeader {
public class RolloutGroupTargetsListHeader extends AbstractGridHeader {
private static final long serialVersionUID = 5613986489156507581L;
@Autowired

View File

@@ -6,10 +6,11 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.rollout;
package org.eclipse.hawkbit.ui.rollout.rolloutgrouptargets;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.common.grid.AbstractGridLayout;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -21,7 +22,7 @@ import com.vaadin.ui.Label;
*/
@SpringComponent
@ViewScope
public class RolloutGroupTargetsListView extends AbstractSimpleTableLayout {
public class RolloutGroupTargetsListView extends AbstractGridLayout {
private static final long serialVersionUID = 26089134783467012L;