custom render changes
Signed-off-by: asharani-murugesh <asharani.murugesh@in.bosch.com>
This commit is contained in:
@@ -13,5 +13,5 @@
|
||||
|
||||
<inherits name="org.vaadin.hene.flexibleoptiongroup.widgetset.FlexibleOptionGroupWidgetset" />
|
||||
|
||||
<inherits name="org.eclipse.hawkbit.ui.distributionbar2.CustomRenderersWidgetSet" />
|
||||
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.eclipse.hawkbit.ui.distributionbar.client;
|
||||
|
||||
import com.vaadin.client.connectors.ButtonRendererConnector;
|
||||
import com.vaadin.shared.ui.Connect;
|
||||
|
||||
@Connect(org.eclipse.hawkbit.ui.distributionbar.renderers.HtmlButtonRenderer.class)
|
||||
public class HtmlButtonRendererConnector extends ButtonRendererConnector {
|
||||
private static final long serialVersionUID = 7987417436367399331L;
|
||||
|
||||
@Override
|
||||
public org.eclipse.hawkbit.ui.distributionbar.client.renderers.HtmlButtonRenderer getRenderer() {
|
||||
return (org.eclipse.hawkbit.ui.distributionbar.client.renderers.HtmlButtonRenderer) super.getRenderer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.eclipse.hawkbit.ui.distributionbar.client;
|
||||
|
||||
import com.vaadin.client.connectors.ButtonRendererConnector;
|
||||
import com.vaadin.shared.ui.Connect;
|
||||
|
||||
@Connect(org.eclipse.hawkbit.ui.distributionbar.renderers.LinkRenderer.class)
|
||||
public class LinkRendererConnector extends ButtonRendererConnector {
|
||||
private static final long serialVersionUID = 7987417436367399331L;
|
||||
|
||||
@Override
|
||||
public org.eclipse.hawkbit.ui.distributionbar.client.renderers.LinkRenderer getRenderer() {
|
||||
return (org.eclipse.hawkbit.ui.distributionbar.client.renderers.LinkRenderer) super.getRenderer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.eclipse.hawkbit.ui.distributionbar.client.renderers;
|
||||
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.vaadin.client.renderers.ButtonRenderer;
|
||||
import com.vaadin.client.widget.grid.RendererCellReference;
|
||||
|
||||
public class HtmlButtonRenderer extends ButtonRenderer {
|
||||
@Override
|
||||
public void render(RendererCellReference cell, String text, Button button) {
|
||||
if (text != null) {
|
||||
button.setHTML(text);
|
||||
}
|
||||
button.setStylePrimaryName("v-button");
|
||||
button.addStyleName(
|
||||
"tiny v-button-tiny borderless v-button-borderless icon-only v-button-icon-only button-no-border v-button-button-no-border");
|
||||
// this is to allow the button to disappear, if the text is null
|
||||
button.setVisible(text != null);
|
||||
button.getElement().setId("rollout.action.button.id");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.eclipse.hawkbit.ui.distributionbar.client.renderers;
|
||||
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.vaadin.client.renderers.ButtonRenderer;
|
||||
import com.vaadin.client.widget.grid.RendererCellReference;
|
||||
|
||||
public class LinkRenderer extends ButtonRenderer {
|
||||
@Override
|
||||
public void render(RendererCellReference cell, String text, Button button) {
|
||||
button.setText(text);
|
||||
button.setStylePrimaryName("v-button");
|
||||
button.addStyleName(
|
||||
"borderless v-button-borderless small v-button-small on-focus-no-border v-button-on-focus-no-border link v-button-link");
|
||||
// this is to allow the button to disappear, if the text is null
|
||||
button.setVisible(text != null);
|
||||
button.getElement().setId("rollout.action.button.id");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.eclipse.hawkbit.ui.distributionbar.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;
|
||||
|
||||
@@ -20,27 +22,23 @@ public class StringDistributionBarRenderer extends WidgetRenderer<String, GwtDis
|
||||
public void render(RendererCellReference cell, String input, GwtDistributionBar widget) {
|
||||
if (null != input) {
|
||||
widget.setNumberOfParts(2);
|
||||
widget.addStyleName("progress-bar");
|
||||
Map<String, Long> map = formatData(input);
|
||||
if (!map.isEmpty()) {
|
||||
final Long notStartedTargetsCount = map.keySet().contains("NOTSTARTED") ? map.get("NOTSTARTED") : 0L;
|
||||
final Long runningTargetsCount = map.keySet().contains("RUNNING") ? map.get("RUNNING") : 0L;
|
||||
final Long scheduledTargetsCount = map.keySet().contains("SCHEDULED") ? map.get("SCHEDULED") : 0L;
|
||||
final Long errorTargetsCount = map.keySet().contains("ERROR") ? map.get("ERROR") : 0L;
|
||||
final Long finishedTargetsCount = map.keySet().contains("FINISHED") ? map.get("FINISHED") : 0L;
|
||||
final Long cancelledTargetsCount = map.keySet().contains("CANCELLED") ? map.get("CANCELLED") : 0L;
|
||||
if (isNoTargets(errorTargetsCount, notStartedTargetsCount, runningTargetsCount, scheduledTargetsCount,
|
||||
finishedTargetsCount, cancelledTargetsCount)) {
|
||||
if (isNoTargets(map.values())) {
|
||||
setBarPartSize(widget, "SCHEDULED".toLowerCase(), 0, 0);
|
||||
setBarPartSize(widget, "FINISHED".toString().toLowerCase(), 0, 1);
|
||||
setBarPartSize(widget, "FINISHED".toLowerCase(), 0, 1);
|
||||
|
||||
} else {
|
||||
widget.setNumberOfParts(6);
|
||||
setBarPartSize(widget, "NOTSTARTED".toString().toLowerCase(), notStartedTargetsCount.intValue(), 0);
|
||||
setBarPartSize(widget, "SCHEDULED".toString().toLowerCase(), scheduledTargetsCount.intValue(), 1);
|
||||
setBarPartSize(widget, "RUNNING".toLowerCase(), scheduledTargetsCount.intValue(), 2);
|
||||
setBarPartSize(widget, "ERROR".toLowerCase(), errorTargetsCount.intValue(), 3);
|
||||
setBarPartSize(widget, "FINISHED".toLowerCase(), finishedTargetsCount.intValue(), 4);
|
||||
setBarPartSize(widget, "CANCELLED".toLowerCase(), cancelledTargetsCount.intValue(), 5);
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
widget.updateParts();
|
||||
@@ -57,20 +55,30 @@ public class StringDistributionBarRenderer extends WidgetRenderer<String, GwtDis
|
||||
return details;
|
||||
}
|
||||
|
||||
private static boolean isNoTargets(Long errorTargetsCount, Long notStartedTargetsCount, Long runningTargetsCount,
|
||||
Long scheduledTargetsCount, Long finishedTargetsCount, Long cancelledTargetsCount) {
|
||||
if (errorTargetsCount == 0 && notStartedTargetsCount == 0 && runningTargetsCount == 0
|
||||
&& scheduledTargetsCount == 0 && finishedTargetsCount == 0 && cancelledTargetsCount == 0) {
|
||||
return true;
|
||||
private int getNumberOfParts(Collection<Long> values) {
|
||||
int count = 0;
|
||||
for (Long val : values) {
|
||||
if (val != 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setBarPartSize(final GwtDistributionBar bar, final String statusName, final int 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);
|
||||
// check thi:::
|
||||
bar.setPartStyleName(index, index, "status-bar-part-" + statusName);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.eclipse.hawkbit.ui.distributionbar.renderers;
|
||||
|
||||
import com.vaadin.ui.renderers.ButtonRenderer;
|
||||
|
||||
public class HtmlButtonRenderer extends ButtonRenderer {
|
||||
private static final long serialVersionUID = -1242995370043404892L;
|
||||
public HtmlButtonRenderer() {
|
||||
super();
|
||||
}
|
||||
public HtmlButtonRenderer(RendererClickListener listener) {
|
||||
super(listener);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.eclipse.hawkbit.ui.distributionbar.renderers;
|
||||
|
||||
import com.vaadin.ui.renderers.ButtonRenderer;
|
||||
|
||||
public class LinkRenderer extends ButtonRenderer {
|
||||
private static final long serialVersionUID = -1242995370043404892L;
|
||||
public LinkRenderer() {
|
||||
super();
|
||||
}
|
||||
public LinkRenderer(RendererClickListener listener) {
|
||||
super(listener);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
package org.eclipse.hawkbit.ui.rollout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
|
||||
import org.eclipse.hawkbit.ui.distributionbar.renderers.HtmlButtonRenderer;
|
||||
import org.eclipse.hawkbit.ui.distributionbar.renderers.LinkRenderer;
|
||||
import org.eclipse.hawkbit.ui.rollout.RolloutListTable.ACTION;
|
||||
import org.eclipse.hawkbit.ui.rollout.RolloutListTable.ContextMenuData;
|
||||
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.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.peter.contextmenu.ContextMenu;
|
||||
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItem;
|
||||
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItemClickEvent;
|
||||
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.data.util.GeneratedPropertyContainer;
|
||||
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.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
|
||||
import com.vaadin.ui.renderers.HtmlRenderer;
|
||||
|
||||
@SpringComponent
|
||||
@ViewScope
|
||||
public class RolloutListGrid extends AbstractSimpleGrid {
|
||||
private static final long serialVersionUID = 4060904914954370524L;
|
||||
|
||||
@Autowired
|
||||
private I18N i18n;
|
||||
|
||||
@Autowired
|
||||
private transient SpPermissionChecker permissionChecker;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
protected void init() {
|
||||
super.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTableId() {
|
||||
return SPUIComponetIdProvider.ROLLOUT_LIST_TABLE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Container createContainer() {
|
||||
final BeanQueryFactory<RolloutBeanQuery> rolloutQf = new BeanQueryFactory<>(RolloutBeanQuery.class);
|
||||
LazyQueryContainer lqc = new LazyQueryContainer(
|
||||
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), rolloutQf);
|
||||
|
||||
final LazyQueryContainer rolloutGridContainer = lqc;
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_ID, String.class, null, false, false);
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false);
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false);
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false,
|
||||
false);
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null, false,
|
||||
false);
|
||||
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TARGETFILTERQUERY, String.class, null, false,
|
||||
false);
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false,
|
||||
false);
|
||||
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_DATE, String.class, null, false,
|
||||
false);
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_USER, String.class, null, false,
|
||||
false);
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false,
|
||||
false);
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, Integer.class, 0, false,
|
||||
false);
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false,
|
||||
false);
|
||||
|
||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS,
|
||||
TotalTargetCountStatus.class, null, false, false);
|
||||
return new GeneratedPropertyContainer(lqc);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContainerProperties() {
|
||||
GeneratedPropertyContainer gpc = (GeneratedPropertyContainer) getContainerDataSource();
|
||||
gpc.addGeneratedProperty(SPUILabelDefinitions.ACTION, new FontIconGenerator(FontAwesome.CIRCLE_O));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setColumnProperties() {
|
||||
List<Object> columnList = new ArrayList<>();
|
||||
columnList.add(SPUILabelDefinitions.VAR_NAME);
|
||||
columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION);
|
||||
columnList.add(SPUILabelDefinitions.VAR_STATUS);
|
||||
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
|
||||
columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS);
|
||||
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS);
|
||||
columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE);
|
||||
columnList.add(SPUILabelDefinitions.VAR_CREATED_USER);
|
||||
columnList.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
|
||||
columnList.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
|
||||
columnList.add(SPUILabelDefinitions.VAR_DESC);
|
||||
columnList.add(SPUILabelDefinitions.ACTION);
|
||||
// columnList.add("statusTotalCountMap");
|
||||
setColumnOrder(columnList.toArray());
|
||||
}
|
||||
|
||||
@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);
|
||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_ID);
|
||||
columnsToBeHidden.add(SPUILabelDefinitions.VAR_TARGETFILTERQUERY);
|
||||
for (Object propertyId : columnsToBeHidden) {
|
||||
getColumn(propertyId).setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setColumnHeaderNames() {
|
||||
getColumn(SPUILabelDefinitions.VAR_NAME).setHeaderCaption(i18n.get("header.name"));
|
||||
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset"));
|
||||
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups"));
|
||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets"));
|
||||
getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setHeaderCaption(i18n.get("header.createdDate"));
|
||||
getColumn(SPUILabelDefinitions.VAR_CREATED_USER).setHeaderCaption(i18n.get("header.createdBy"));
|
||||
getColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE).setHeaderCaption(i18n.get("header.modifiedDate"));
|
||||
getColumn(SPUILabelDefinitions.VAR_MODIFIED_BY).setHeaderCaption(i18n.get("header.modifiedBy"));
|
||||
getColumn(SPUILabelDefinitions.VAR_DESC).setHeaderCaption(i18n.get("header.description"));
|
||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS)
|
||||
.setHeaderCaption(i18n.get("header.detail.status"));
|
||||
getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status"));
|
||||
getColumn(SPUILabelDefinitions.ACTION).setHeaderCaption(i18n.get("upload.action"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setColumnExpandRatio() {
|
||||
getColumn(SPUILabelDefinitions.VAR_NAME).setExpandRatio(1);
|
||||
getColumn(SPUILabelDefinitions.VAR_NAME).setMaximumWidth(300);
|
||||
|
||||
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setExpandRatio(1);
|
||||
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMaximumWidth(300);
|
||||
|
||||
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setExpandRatio(0);
|
||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setExpandRatio(0);
|
||||
getColumn(SPUILabelDefinitions.VAR_CREATED_DATE).setExpandRatio(0);
|
||||
getColumn(SPUILabelDefinitions.VAR_CREATED_USER).setExpandRatio(0);
|
||||
getColumn(SPUILabelDefinitions.VAR_MODIFIED_DATE).setExpandRatio(0);
|
||||
getColumn(SPUILabelDefinitions.VAR_MODIFIED_BY).setExpandRatio(0);
|
||||
getColumn(SPUILabelDefinitions.VAR_DESC).setExpandRatio(0);
|
||||
getColumn(SPUILabelDefinitions.VAR_STATUS).setExpandRatio(0);
|
||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setExpandRatio(2);
|
||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(600);
|
||||
|
||||
getColumn(SPUILabelDefinitions.ACTION).setExpandRatio(0);
|
||||
getColumn(SPUILabelDefinitions.ACTION).setMinimumWidth(90);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addColumnRenderes() {
|
||||
setEditorEnabled(true);
|
||||
addDetailStatusColumn();
|
||||
addStatusCoulmn();
|
||||
getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(event -> OnClickOfActionBtn(event)));
|
||||
getColumn(SPUILabelDefinitions.VAR_NAME).setRenderer(new LinkRenderer(event -> onClickOfRolloutName(event)));
|
||||
}
|
||||
|
||||
private void onClickOfRolloutName(RendererClickEvent event) {
|
||||
}
|
||||
|
||||
private void OnClickOfActionBtn(RendererClickEvent event) {
|
||||
final ContextMenu contextMenu = createContextMenu((Long) event.getItemId());
|
||||
contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent());
|
||||
contextMenu.open(event.getClientX(), event.getClientY());
|
||||
}
|
||||
|
||||
private ContextMenu createContextMenu(final Long rolloutId) {
|
||||
final Item row = getContainerDataSource().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) {
|
||||
}
|
||||
|
||||
private void addDetailStatusColumn() {
|
||||
|
||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(
|
||||
new org.eclipse.hawkbit.ui.distributionbar.renderers.StringDistributionBarRenderer(),
|
||||
new Converter<String, TotalTargetCountStatus>() {
|
||||
private static final long serialVersionUID = 2660476405836705932L;
|
||||
|
||||
@Override
|
||||
public TotalTargetCountStatus convertToModel(String value,
|
||||
Class<? extends TotalTargetCountStatus> targetType, Locale locale)
|
||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToPresentation(TotalTargetCountStatus value,
|
||||
Class<? extends String> targetType, Locale locale)
|
||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
return getFormattedString(value.getStatusTotalCountMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<TotalTargetCountStatus> getModelType() {
|
||||
return TotalTargetCountStatus.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getPresentationType() {
|
||||
return String.class;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void addStatusCoulmn() {
|
||||
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlRenderer(),
|
||||
new Converter<String, RolloutStatus>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public RolloutStatus convertToModel(final String value,
|
||||
final Class<? extends RolloutStatus> targetType, final Locale locale) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToPresentation(final RolloutStatus value,
|
||||
final Class<? extends String> targetType, final Locale locale) {
|
||||
String result = null;
|
||||
switch (value) {
|
||||
case FINISHED:
|
||||
result = "<div class=\"statusIconGreen\">" + FontAwesome.CHECK_CIRCLE.getHtml() + "</div>";
|
||||
break;
|
||||
case PAUSED:
|
||||
result = "<div class=\"statusIconBlue\">" + FontAwesome.PAUSE.getHtml() + "</div>";
|
||||
break;
|
||||
case RUNNING:
|
||||
result = "<div class=\"yellowSpinner\"></div>";
|
||||
break;
|
||||
case READY:
|
||||
result = "<div class=\"statusIconLightBlue\"> <span title=\"xxx\">"
|
||||
+ FontAwesome.DOT_CIRCLE_O.getHtml() + "</span></div>";
|
||||
break;
|
||||
case STOPPED:
|
||||
result = "<div class=\"statusIconRed\">" + FontAwesome.STOP.getHtml() + "</div>";
|
||||
break;
|
||||
case CREATING:
|
||||
result = "<div class=\"greySpinner\"></div>";
|
||||
break;
|
||||
case STARTING:
|
||||
result = "<div class=\"blueSpinner\"></div>";
|
||||
break;
|
||||
case ERROR_CREATING:
|
||||
result = "<div class=\"statusIconRed\">" + FontAwesome.EXCLAMATION_CIRCLE.getHtml()
|
||||
+ "</div>";
|
||||
break;
|
||||
case ERROR_STARTING:
|
||||
result = "<div class=\"statusIconRed\">" + FontAwesome.EXCLAMATION_CIRCLE.getHtml()
|
||||
+ "</div>";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<RolloutStatus> getModelType() {
|
||||
return RolloutStatus.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getPresentationType() {
|
||||
return String.class;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getFormattedString(Map<Status, Long> details) {
|
||||
StringBuilder val = new StringBuilder();
|
||||
String finalVal = null;
|
||||
if (null != details && !details.isEmpty()) {
|
||||
for (Entry<Status, Long> entry : details.entrySet()) {
|
||||
val.append(entry.getKey()).append(":").append(entry.getValue()).append(",");
|
||||
}
|
||||
finalVal = val.substring(0, val.length() - 1);
|
||||
}
|
||||
return finalVal;
|
||||
}
|
||||
|
||||
public final class FontIconGenerator extends PropertyValueGenerator<String> {
|
||||
|
||||
private static final long serialVersionUID = 2544026030795375748L;
|
||||
private final FontAwesome fontIcon;
|
||||
|
||||
public FontIconGenerator(FontAwesome icon) {
|
||||
this.fontIcon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(Item item, Object itemId, Object propertyId) {
|
||||
return fontIcon.getHtml();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getType() {
|
||||
return String.class;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user