use of org.ovirt.engine.ui.common.widget.table.column.AbstractIconTypeColumn in project ovirt-engine by oVirt.
the class ErrataTableView method initErrataGrid.
/**
* Setup the columns in the errata grid. This configuration is also used in MainEngineErrataView.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void initErrataGrid(HasColumns grid, boolean isEngineErrataView, final PlaceTransitionHandler transitionHandler) {
grid.enableColumnResizing();
AbstractIconTypeColumn<Erratum> errataTypeColumn = new AbstractIconTypeColumn<Erratum>() {
@Override
public IconType getValue(Erratum erratum) {
if (erratum.getType() == ErrataType.BUGFIX) {
getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.BUGFIX.getColor()));
return IconType.BUG;
} else if (erratum.getType() == ErrataType.ENHANCEMENT) {
getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.ENHANCEMENT.getColor()));
return IconType.PLUS_SQUARE;
} else if (erratum.getType() == ErrataType.SECURITY) {
getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.SECURITY.getColor()));
return IconType.WARNING;
}
return null;
}
};
errataTypeColumn.makeSortable(new ErrataTypeComparator());
// $NON-NLS-1$ //$NON-NLS-2$
grid.addColumn(errataTypeColumn, "", "30px");
AbstractTextColumn errataTypeTextColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
if (erratum.getType() == ErrataType.BUGFIX) {
return constants.bug();
} else if (erratum.getType() == ErrataType.ENHANCEMENT) {
return constants.enhancement();
} else if (erratum.getType() == ErrataType.SECURITY) {
return constants.security();
}
return constants.unknown();
}
};
errataTypeTextColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(errataTypeTextColumn, constants.errataType(), "150px");
AbstractTextColumn<Erratum> errataSeverityColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
if (erratum.getSeverity() == ErrataSeverity.CRITICAL) {
return constants.critical();
} else if (erratum.getSeverity() == ErrataSeverity.IMPORTANT) {
return constants.important();
} else if (erratum.getSeverity() == ErrataSeverity.MODERATE) {
return constants.moderate();
}
return constants.unknown();
}
};
errataSeverityColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(errataSeverityColumn, constants.errataSeverity(), "150px");
AbstractFullDateTimeColumn<Erratum> dateIssuedColumn = new AbstractFullDateTimeColumn<Erratum>(false) {
@Override
protected Date getRawValue(Erratum erratum) {
return erratum.getIssued();
}
};
dateIssuedColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(dateIssuedColumn, constants.errataDateIssued(), "100px");
AbstractTextColumn<Erratum> errataIdColumn;
if (!isEngineErrataView) {
errataIdColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
return erratum.getId();
}
};
} else {
errataIdColumn = new AbstractLinkColumn<Erratum>(new FieldUpdater<Erratum, String>() {
@Override
public void update(int index, Erratum erratum, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), erratum.getName());
// The link was clicked, now fire an event to switch to details.
transitionHandler.handlePlaceTransition(WebAdminApplicationPlaces.errataDetailsSubTabPlace, parameters);
}
}) {
@Override
public String getValue(Erratum erratum) {
return erratum.getId();
}
};
}
errataIdColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(errataIdColumn, constants.errataId(), "115px");
AbstractTextColumn<Erratum> titleColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
return erratum.getTitle();
}
};
titleColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(titleColumn, constants.errataTitle(), "290px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractIconTypeColumn in project ovirt-engine by oVirt.
the class HostNetworkInterfaceListViewItem method createLogicalNetworkContainer.
private Container createLogicalNetworkContainer() {
List<HostVLan> logicalNetworks = calculateLogicalNetworks(getEntity());
Row content = new Row();
Column gridColumn = new Column(ColumnSize.SM_12);
content.add(gridColumn);
Container container = createItemContainerPanel(content);
CellTable<HostVLan> logicalNetworkTable = new CellTable<>(MAX_LOGICAL_NETWORKS, (Resources) GWT.create(CellTablePopupTableResources.class));
logicalNetworkTable.getElement().addClassName(Styles.TABLE);
logicalNetworkTable.getElement().addClassName(PatternflyConstants.PF_TABLE_STRIPED);
logicalNetworkTable.getElement().addClassName(PatternflyConstants.PF_TABLE_BORDERED);
ListDataProvider<HostVLan> logicalNetworkDataProvider = new ListDataProvider<>();
logicalNetworkDataProvider.addDataDisplay(logicalNetworkTable);
logicalNetworkDataProvider.setList(logicalNetworks);
final HostVLanNameRenderer renderer = new HostVLanNameRenderer();
// Setup columns
AbstractIconTypeColumn<HostVLan> management = new AbstractIconTypeColumn<HostVLan>() {
@Override
public IconType getValue(HostVLan logicalNetwork) {
if (logicalNetwork.getInterface() != null && logicalNetwork.getInterface().getIsManagement()) {
return IconType.INSTITUTION;
}
return null;
}
@Override
public SafeHtml getTooltip(HostVLan logicalNetwork) {
return SafeHtmlUtils.fromSafeConstant(constants.managementNetworkLabel());
}
};
IconTypeHeader managementHeader = new IconTypeHeader(IconType.INSTITUTION, ICON_COLOR, SafeHtmlUtils.fromSafeConstant(constants.managementNetworkLabel()));
management.getCell().setColor(SafeHtmlUtils.fromSafeConstant(ICON_COLOR));
logicalNetworkTable.addColumn(management, managementHeader);
// $NON-NLS-1$
logicalNetworkTable.setColumnWidth(management, "40px");
AbstractIconTypeColumn<HostVLan> sync = new AbstractIconTypeColumn<HostVLan>() {
@Override
public IconType getValue(HostVLan logicalNetwork) {
if (logicalNetwork != null && logicalNetwork.getInterface() != null && isOutOfSync(logicalNetwork.getInterface().getNetworkImplementationDetails())) {
return IconType.CHAIN_BROKEN;
}
return null;
}
@Override
public SafeHtml getTooltip(HostVLan logicalNetwork) {
return SafeHtmlUtils.fromSafeConstant(constants.hostOutOfSync());
}
};
IconTypeHeader syncHeader = new IconTypeHeader(IconType.CHAIN_BROKEN, ICON_COLOR, SafeHtmlUtils.fromSafeConstant(constants.hostOutOfSync()));
sync.getCell().setColor(SafeHtmlUtils.fromSafeConstant(RED));
logicalNetworkTable.addColumn(sync, syncHeader);
// $NON-NLS-1$
logicalNetworkTable.setColumnWidth(sync, "40px");
TextColumn<HostVLan> vlan = new TextColumn<HostVLan>() {
@Override
public String getValue(HostVLan logicalNetwork) {
if (logicalNetwork == null || logicalNetwork.getName() == null || logicalNetwork.getName().isEmpty()) {
return "";
}
return renderer.render(logicalNetwork);
}
};
// $NON-NLS-1$
logicalNetworkTable.setColumnWidth(vlan, "175px");
logicalNetworkTable.addColumn(vlan, constants.vlanInterface());
TextColumn<HostVLan> networkName = new TextColumn<HostVLan>() {
@Override
public String getValue(HostVLan logicalNetwork) {
return logicalNetwork.getNetworkName();
}
};
// $NON-NLS-1$
logicalNetworkTable.setColumnWidth(networkName, "175px");
logicalNetworkTable.addColumn(networkName, constants.networkNameInterface());
TextColumn<HostVLan> ipv4 = new TextColumn<HostVLan>() {
@Override
public String getValue(HostVLan logicalNetwork) {
return logicalNetwork.getIpv4Address() != null ? logicalNetwork.getIpv4Address() : "";
}
};
// $NON-NLS-1$
logicalNetworkTable.setColumnWidth(ipv4, "175px");
logicalNetworkTable.addColumn(ipv4, constants.ipv4AddressInterface());
TextColumn<HostVLan> ipv6 = new TextColumn<HostVLan>() {
@Override
public String getValue(HostVLan logicalNetwork) {
return logicalNetwork.getIpv6Address() != null ? logicalNetwork.getIpv6Address() : "";
}
};
// $NON-NLS-1$
logicalNetworkTable.setColumnWidth(ipv6, "175px");
logicalNetworkTable.addColumn(ipv6, constants.ipv6AddressInterface());
TextColumn<HostVLan> emptyTail = new TextColumn<HostVLan>() {
@Override
public String getValue(HostVLan logicalNetwork) {
return "";
}
};
logicalNetworkTable.addColumn(emptyTail, "");
gridColumn.add(logicalNetworkTable);
return container;
}
Aggregations