Search in sources :

Example 1 with ImportNetworkData

use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportNetworkData in project ovirt-engine by oVirt.

the class ImportVmFromExternalProviderPopupView method addNetworkColumn.

private void addNetworkColumn() {
    customSelectionCellNetwork = new CustomSelectionCell(new ArrayList<String>());
    customSelectionCellNetwork.setStyle(style.cellSelectBox());
    Column<VmNetworkInterface, String> networkColumn = new Column<VmNetworkInterface, String>(customSelectionCellNetwork) {

        @Override
        public String getValue(VmNetworkInterface iface) {
            ImportNetworkData importNetworkData = importModel.getNetworkImportData(iface);
            List<String> networkNames = importNetworkData.getNetworkNames();
            ((CustomSelectionCell) getCell()).setOptions(networkNames);
            if (networkNames.isEmpty()) {
                // $NON-NLS-1$
                return "";
            }
            String selectedNetworkName = importNetworkData.getSelectedNetworkName();
            return selectedNetworkName != null ? selectedNetworkName : networkNames.get(0);
        }
    };
    networkColumn.setFieldUpdater((index, iface, value) -> {
        importModel.getNetworkImportData(iface).setSelectedNetworkName(value);
        nicTable.asEditor().edit(importModel.getImportNetworkInterfaceListModel());
    });
    // $NON-NLS-1$
    nicTable.addColumn(networkColumn, constants.networkNameInterface(), "150px");
}
Also used : ImportNetworkData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportNetworkData) CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) AbstractSafeHtmlColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ArrayList(java.util.ArrayList)

Example 2 with ImportNetworkData

use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportNetworkData in project ovirt-engine by oVirt.

the class ImportVmFromExternalProviderPopupView method addNetworkProfileColumn.

private void addNetworkProfileColumn() {
    customSelectionCellNetwork = new CustomSelectionCell(new ArrayList<String>());
    customSelectionCellNetwork.setStyle(style.cellSelectBox());
    Column<VmNetworkInterface, String> profileColumn = new Column<VmNetworkInterface, String>(customSelectionCellNetwork) {

        @Override
        public String getValue(VmNetworkInterface iface) {
            ImportNetworkData importNetworkData = importModel.getNetworkImportData(iface);
            List<String> networkProfileNames = new ArrayList<>();
            for (VnicProfileView networkProfile : importNetworkData.getFilteredNetworkProfiles()) {
                networkProfileNames.add(networkProfile.getName());
            }
            ((CustomSelectionCell) getCell()).setOptions(networkProfileNames);
            if (networkProfileNames.isEmpty()) {
                // $NON-NLS-1$
                return "";
            }
            VnicProfileView selectedNetworkProfile = importModel.getNetworkImportData(iface).getSelectedNetworkProfile();
            return selectedNetworkProfile != null ? selectedNetworkProfile.getName() : networkProfileNames.get(0);
        }
    };
    profileColumn.setFieldUpdater((index, iface, value) -> importModel.getNetworkImportData(iface).setSelectedNetworkProfile(value));
    // $NON-NLS-1$
    nicTable.addColumn(profileColumn, constants.profileNameInterface(), "150px");
}
Also used : ImportNetworkData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportNetworkData) CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) AbstractSafeHtmlColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ArrayList(java.util.ArrayList) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView)

Aggregations

Column (com.google.gwt.user.cellview.client.Column)2 ArrayList (java.util.ArrayList)2 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)2 AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)2 AbstractDiskSizeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn)2 AbstractEnumColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn)2 AbstractImageResourceColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn)2 AbstractSafeHtmlColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn)2 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)2 ImportNetworkData (org.ovirt.engine.ui.uicommonweb.models.vms.ImportNetworkData)2 CustomSelectionCell (org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell)2 VmTypeColumn (org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn)2 VnicProfileView (org.ovirt.engine.core.common.businessentities.network.VnicProfileView)1