use of org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader in project ovirt-engine by oVirt.
the class ColumnResizeCellTable method addColumnImpl.
private void addColumnImpl(Column<T, ?> column, Header<?> header) {
// build resizable headers, if necessary
if (columnResizingEnabled && header instanceof AbstractCheckboxHeader) {
header = createResizableCheckboxHeader(header, column);
} else if (columnResizingEnabled) {
header = createResizableHeader(column, header);
} else if (applyHeaderStyle && header instanceof SafeHtmlHeader) {
SafeHtmlHeader safeHtmlHeader = (SafeHtmlHeader) header;
// not using Resizeable header, but still want it to look that way.
// nonResizeableColumnHeader does that.
// TODO nonResizeableColumnHeader copy-pastes CSS. fix.
SafeHtml newValue = templates.nonResizeableColumnHeader(safeHtmlHeader.getValue());
header = new SafeHtmlHeader(newValue, safeHtmlHeader.getTooltip());
}
// actually add the column
super.addColumn(column, header);
// Add empty no-width column as the last column
if (columnResizingEnabled) {
if (isColumnPresent(emptyNoWidthColumn)) {
removeColumn(emptyNoWidthColumn);
}
super.addColumn(emptyNoWidthColumn, emptyNoWidthColumnHeader);
}
// Add column to header context menu
if (header instanceof AbstractHeader) {
((AbstractHeader) header).setContextMenuHandler(ensureContextMenuHandler());
contextPopup.getContextMenu().addItem(column);
}
}
use of org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader in project ovirt-engine by oVirt.
the class AbstractNetworkPopupView method initEntityModelCellTable.
void initEntityModelCellTable() {
AbstractCheckboxHeader assignAllHeader = new AbstractCheckboxHeader() {
@Override
protected void selectionChanged(Boolean value) {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
if (networkClusterModel.getIsChangable()) {
networkClusterModel.setAttached(value);
networkClusterModel.setRequired(value && networkClusterModel.isRequired());
}
}
refreshClustersTable();
}
@Override
public Boolean getValue() {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
if (networkClusterModel.getIsChangable() && !networkClusterModel.isAttached()) {
return false;
}
}
return true;
}
@Override
public boolean isEnabled() {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
if (networkClusterModel.getIsChangable()) {
return true;
}
}
return false;
}
@Override
public String getLabel() {
return constants.attachAll();
}
};
AbstractCheckboxHeader requiredAllHeader = new AbstractCheckboxHeader() {
@Override
protected void selectionChanged(Boolean value) {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
networkClusterModel.setRequired(value && networkClusterModel.isAttached());
}
refreshClustersTable();
}
@Override
public Boolean getValue() {
for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
if (!networkClusterModel.isRequired()) {
return false;
}
}
return true;
}
@Override
public boolean isEnabled() {
return isRequiredChangeable();
}
@Override
public String getLabel() {
return constants.requiredAll();
}
};
clustersTable.addColumn(new AbstractTextColumn<NetworkClusterModel>() {
@Override
public String getValue(NetworkClusterModel model) {
return model.getName();
}
}, constants.nameClusterHeader());
clustersTable.addColumn(new AbstractCheckboxColumn<NetworkClusterModel>((index, model, value) -> {
model.setAttached(value);
model.setRequired(value && model.isRequired());
refreshClustersTable();
}) {
@Override
public Boolean getValue(NetworkClusterModel model) {
return model.isAttached();
}
@Override
protected boolean canEdit(NetworkClusterModel model) {
return model.getIsChangable();
}
@Override
public void render(Context context, NetworkClusterModel object, SafeHtmlBuilder sb) {
super.render(context, object, sb);
sb.append(templates.textForCheckBox(constants.attach()));
}
}, assignAllHeader, // $NON-NLS-1$
"150px");
clustersTable.addColumn(new AbstractCheckboxColumn<NetworkClusterModel>((index, model, value) -> {
model.setRequired(value && model.isAttached());
refreshClustersTable();
}) {
@Override
public Boolean getValue(NetworkClusterModel model) {
return model.isRequired();
}
@Override
protected boolean canEdit(NetworkClusterModel model) {
return isRequiredChangeable() && model.isAttached();
}
@Override
public void render(Context context, NetworkClusterModel object, SafeHtmlBuilder sb) {
super.render(context, object, sb);
sb.append(templates.textForCheckBox(constants.required()));
}
}, requiredAllHeader, // $NON-NLS-1$
"150px");
}
use of org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader in project ovirt-engine by oVirt.
the class ImportNetworksPopupView method initEntityModelCellTables.
void initEntityModelCellTables() {
providerNetworks.addColumn(new AbstractTextColumn<ExternalNetwork>() {
@Override
public String getValue(ExternalNetwork model) {
return model.getDisplayName();
}
}, constants.nameNetworkHeader());
importedNetworks.addColumn(new AbstractEditTextColumn<ExternalNetwork>((index, model, value) -> model.setDisplayName(value)) {
@Override
public String getValue(ExternalNetwork model) {
return model.getDisplayName();
}
}, constants.nameNetworkHeader());
Column<ExternalNetwork, String> idColumn = new AbstractTextColumn<ExternalNetwork>() {
@Override
public String getValue(ExternalNetwork model) {
return model.getNetwork().getProvidedBy().getExternalId();
}
};
providerNetworks.addColumn(idColumn, constants.idNetworkHeader());
importedNetworks.addColumn(idColumn, constants.idNetworkHeader());
dcColumn = new AbstractListModelListBoxColumn<ExternalNetwork, StoragePool>(new NameRenderer<StoragePool>()) {
@Override
public ListModel<StoragePool> getValue(ExternalNetwork network) {
return network.getDataCenters();
}
};
importedNetworks.addColumn(dcColumn, constants.dcNetworkHeader());
AbstractCheckboxHeader publicAllHeader = new AbstractCheckboxHeader() {
@Override
protected void selectionChanged(Boolean value) {
for (ExternalNetwork model : getAllImportedNetworks()) {
model.setPublicUse(value);
}
refreshImportedNetworks();
}
@Override
public Boolean getValue() {
for (ExternalNetwork model : getAllImportedNetworks()) {
if (!model.isPublicUse()) {
return false;
}
}
return true;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public void render(Context context, SafeHtmlBuilder sb) {
super.render(context, sb);
sb.append(ImportNetworksPopupView.templates.tableHeaderInlineImage(SafeHtmlUtils.fromTrustedString(new InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML).toString())));
}
@Override
public SafeHtml getTooltip() {
return ImportNetworksPopupView.templates.textForCheckBoxHeader(constants.publicNetworkTooltip());
}
@Override
public String getLabel() {
return constants.publicNetwork();
}
};
importedNetworks.addColumn(new AbstractCheckboxColumn<ExternalNetwork>((index, model, value) -> {
model.setPublicUse(value);
refreshImportedNetworks();
}) {
@Override
public Boolean getValue(ExternalNetwork model) {
return model.isPublicUse();
}
@Override
protected boolean canEdit(ExternalNetwork model) {
return true;
}
@Override
public void render(Context context, ExternalNetwork object, SafeHtmlBuilder sb) {
super.render(context, object, sb);
// $NON-NLS-1$
sb.append(templates.textForCheckBox(""));
}
}, publicAllHeader, // $NON-NLS-1$
"80px");
}
Aggregations