Search in sources :

Example 36 with AbstractTextColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.

the class MainClusterView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    AbstractTextColumn<Cluster> nameColumn = new AbstractLinkColumn<Cluster>(new FieldUpdater<Cluster, String>() {

        @Override
        public void update(int index, Cluster cluster, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), cluster.getName());
            // The link was clicked, now fire an event to switch to details.
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(Cluster object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable(ClusterConditionFieldAutoCompleter.NAME);
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameCluster(), "150px");
    ClusterAdditionalStatusColumn additionalStatusColumn = new ClusterAdditionalStatusColumn();
    additionalStatusColumn.setContextMenuTitle(constants.additionalStatusCluster());
    // $NON-NLS-1$
    getTable().addColumn(additionalStatusColumn, constants.empty(), "30px");
    CommentColumn<Cluster> commentColumn = new CommentColumn<>();
    getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
    "75px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        AbstractTextColumn<Cluster> dataCenterColumn = new AbstractTextColumn<Cluster>() {

            @Override
            public String getValue(Cluster object) {
                return object.getStoragePoolName();
            }
        };
        // $NON-NLS-1$
        getTable().addColumn(dataCenterColumn, constants.dcCluster(), "150px");
    }
    AbstractTextColumn<Cluster> versionColumn = new AbstractTextColumn<Cluster>() {

        @Override
        public String getValue(Cluster object) {
            return object.getCompatibilityVersion().getValue();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(versionColumn, constants.comptVersCluster(), "150px");
    AbstractTextColumn<Cluster> descColumn = new AbstractTextColumn<Cluster>() {

        @Override
        public String getValue(Cluster object) {
            return object.getDescription();
        }
    };
    descColumn.makeSortable(ClusterConditionFieldAutoCompleter.DESCRIPTION);
    // $NON-NLS-1$
    getTable().addColumn(descColumn, constants.descriptionCluster(), "300px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        AbstractTextColumn<Cluster> cpuTypeColumn = new AbstractTextColumn<Cluster>() {

            @Override
            public String getValue(Cluster object) {
                return object.getCpuName();
            }
        };
        // $NON-NLS-1$
        getTable().addColumn(cpuTypeColumn, constants.cpuTypeCluster(), "150px");
    }
    AbstractTextColumn<Cluster> hostCountColumn = new AbstractTextColumn<Cluster>() {

        @Override
        public String getValue(Cluster object) {
            if (object.getClusterHostsAndVms() == null) {
                // $NON-NLS-1$
                return "";
            }
            // $NON-NLS-1$
            return object.getClusterHostsAndVms().getHosts() + "";
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(hostCountColumn, constants.hostCount(), "150px");
    AbstractTextColumn<Cluster> vmCountColumn = new AbstractTextColumn<Cluster>() {

        @Override
        public String getValue(Cluster object) {
            if (object.getClusterHostsAndVms() == null) {
                // $NON-NLS-1$
                return "";
            }
            // $NON-NLS-1$
            return object.getClusterHostsAndVms().getVms() + "";
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(vmCountColumn, constants.vmCount(), "150px");
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ClusterAdditionalStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.ClusterAdditionalStatusColumn) CommentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 37 with AbstractTextColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn 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");
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) EntityModelCellTable(org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) Inject(com.google.inject.Inject) Provider(org.ovirt.engine.core.common.businessentities.Provider) AbstractModelBoundPopupView(org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView) GWT(com.google.gwt.core.client.GWT) ImportNetworksPopupPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.popup.provider.ImportNetworksPopupPresenterWidget) ListModelListBoxEditor(org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor) ArrayList(java.util.ArrayList) UiBinder(com.google.gwt.uibinder.client.UiBinder) ApplicationConstants(org.ovirt.engine.ui.webadmin.ApplicationConstants) BaseImportNetworksModel(org.ovirt.engine.ui.uicommonweb.models.networks.BaseImportNetworksModel) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork) Context(com.google.gwt.cell.client.Cell.Context) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) HorizontalSplitTable(org.ovirt.engine.ui.common.widget.HorizontalSplitTable) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) InfoIcon(org.ovirt.engine.ui.common.widget.dialog.InfoIcon) ApplicationResources(org.ovirt.engine.ui.webadmin.ApplicationResources) AbstractEditTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEditTextColumn) EventBus(com.google.gwt.event.shared.EventBus) UiCommonEditorDriver(org.ovirt.engine.ui.common.editor.UiCommonEditorDriver) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) AbstractCheckboxHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) AbstractListModelListBoxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractListModelListBoxColumn) WithElementId(org.ovirt.engine.ui.common.idhandler.WithElementId) ApplicationTemplates(org.ovirt.engine.ui.webadmin.ApplicationTemplates) List(java.util.List) SimpleDialogPanel(org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel) Column(com.google.gwt.user.cellview.client.Column) UiField(com.google.gwt.uibinder.client.UiField) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Context(com.google.gwt.cell.client.Cell.Context) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) InfoIcon(org.ovirt.engine.ui.common.widget.dialog.InfoIcon) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork) AbstractCheckboxHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader)

Example 38 with AbstractTextColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.

the class ImportVmFromExportDomainPopupView method initMainTable.

protected void initMainTable() {
    this.table = new ListModelObjectCellTable<>();
    table.enableColumnResizing();
    AbstractImageResourceColumn<Object> isProblematicImportVmColumn = new AbstractImageResourceColumn<Object>() {

        @Override
        public ImageResource getValue(Object object) {
            ImportVmData importVmData = (ImportVmData) object;
            if (importVmData.getError() != null || importVmData.isNameExistsInTheSystem()) {
                return resources.errorImage();
            }
            if (importVmData.getWarning() != null) {
                return resources.alertImage();
            }
            return null;
        }

        @Override
        public SafeHtml getTooltip(Object object) {
            ImportVmData importVmData = (ImportVmData) object;
            String problem = null;
            if (importVmData.getError() != null) {
                problem = importVmData.getError();
            } else {
                problem = importVmData.isNameExistsInTheSystem() ? ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason() : importVmData.getWarning();
            }
            return problem != null ? SafeHtmlUtils.fromSafeConstant(problem) : null;
        }
    };
    // $NON-NLS-1$
    table.addColumn(isProblematicImportVmColumn, constants.empty(), "30px");
    AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            String originalName = ((ImportVmData) object).getName();
            String givenName = ((ImportVmData) object).getVm().getName();
            return originalName.equals(givenName) ? givenName : // $NON-NLS-1$ //$NON-NLS-2$
            givenName + " (" + originalName + ")";
        }
    };
    // $NON-NLS-1$
    table.addColumn(nameColumn, constants.nameVm(), "150px");
    AbstractCheckboxColumn<Object> collapseSnapshotsColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
        ((ImportVmData) model).getCollapseSnapshots().setEntity(value);
        customSelectionCellFormatType.setEnabled(value);
        diskTable.asEditor().edit(importModel.getImportDiskListModel());
    }) {

        @Override
        public Boolean getValue(Object model) {
            return ((ImportVmData) model).getCollapseSnapshots().getEntity();
        }

        @Override
        protected boolean canEdit(Object model) {
            return ((ImportVmData) model).getCollapseSnapshots().getIsChangable();
        }

        @Override
        protected String getDisabledMessage(Object model) {
            return ((ImportVmData) model).getCollapseSnapshots().getChangeProhibitionReason();
        }

        @Override
        public SafeHtml getTooltip(Object object) {
            SafeHtml superTooltip = super.getTooltip(object);
            if (superTooltip == null) {
                return SafeHtmlUtils.fromSafeConstant(constants.importAllocationModifiedCollapse());
            }
            return superTooltip;
        }
    };
    // $NON-NLS-1$
    table.addColumn(collapseSnapshotsColumn, constants.collapseSnapshots(), "130px");
    AbstractCheckboxColumn<Object> cloneVMColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
        ((ImportVmData) model).getClone().setEntity(value);
        table.asEditor().edit(importModel);
    }) {

        @Override
        public Boolean getValue(Object model) {
            return ((ImportVmData) model).getClone().getEntity();
        }

        @Override
        protected boolean canEdit(Object model) {
            return ((ImportVmData) model).getClone().getIsChangable();
        }

        @Override
        protected String getDisabledMessage(Object model) {
            return ((ImportVmData) model).getClone().getChangeProhibitionReason();
        }
    };
    // $NON-NLS-1$
    table.addColumn(cloneVMColumn, constants.cloneVM(), "50px");
    AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {

        @Override
        protected OriginType getRawValue(Object object) {
            return ((ImportVmData) object).getVm().getOrigin();
        }
    };
    // $NON-NLS-1$
    table.addColumn(originColumn, constants.originVm(), "100px");
    table.addColumn(new AbstractSafeHtmlColumn<Object>() {

        @Override
        public SafeHtml getValue(Object object) {
            return VmTypeColumn.getRenderedValue(((ImportVmData) object).getVm());
        }
    }, constants.empty(), // $NON-NLS-1$
    "30px");
    AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return messages.megabytes(String.valueOf(((ImportVmData) object).getVm().getVmMemSizeMb()));
        }
    };
    // $NON-NLS-1$
    table.addColumn(memoryColumn, constants.memoryVm(), "90px");
    AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportVmData) object).getVm().getNumOfCpus());
        }
    };
    // $NON-NLS-1$
    table.addColumn(cpuColumn, constants.cpusVm(), "50px");
    AbstractTextColumn<Object> archColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportVmData) object).getVm().getClusterArch());
        }
    };
    // $NON-NLS-1$
    table.addColumn(archColumn, constants.architectureVm(), "100px");
    AbstractTextColumn<Object> diskColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportVmData) object).getVm().getDiskMap().size());
        }
    };
    // $NON-NLS-1$
    table.addColumn(diskColumn, constants.disksVm(), "55px");
    isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {

        @Override
        public ImageResource getValue(Object object) {
            return ((ImportVmData) object).isExistsInSystem() ? resources.logNormalImage() : null;
        }
    };
    // $NON-NLS-1$
    table.addColumn(isObjectInSystemColumn, constants.vmInSetup(), "100px");
    table.getSelectionModel().addSelectionChangeHandler(event -> {
        ImportVmData selectedObject = ((SingleSelectionModel<ImportVmData>) event.getSource()).getSelectedObject();
        customSelectionCellFormatType.setEnabled(selectedObject.getCollapseSnapshots().getEntity());
    });
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    splitLayoutPanel.add(sp);
    table.getElement().getStyle().setPosition(Position.RELATIVE);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ImportVmData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) ImageResource(com.google.gwt.resources.client.ImageResource) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 39 with AbstractTextColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.

the class MainDataCenterView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    DcStatusColumn statusIconColumn = new DcStatusColumn();
    statusIconColumn.setContextMenuTitle(constants.statusIconDc());
    // $NON-NLS-1$
    getTable().addColumn(statusIconColumn, constants.empty(), "30px");
    DcAdditionalStatusColumn additionalStatusColumn = new DcAdditionalStatusColumn();
    additionalStatusColumn.setContextMenuTitle(constants.additionalStatusDataCenter());
    // $NON-NLS-1$
    getTable().addColumn(additionalStatusColumn, constants.empty(), "30px");
    AbstractTextColumn<StoragePool> nameColumn = new AbstractLinkColumn<StoragePool>(new FieldUpdater<StoragePool, String>() {

        @Override
        public void update(int index, StoragePool storagePool, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), storagePool.getName());
            // The link was clicked, now fire an event to switch to details.
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.dataCenterStorageSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(StoragePool object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable(StoragePoolFieldAutoCompleter.NAME);
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameDc(), "150px");
    CommentColumn<StoragePool> commentColumn = new CommentColumn<>();
    getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
    "75px");
    AbstractTextColumn<StoragePool> storageTypeColumn = new AbstractBooleanColumn<StoragePool>(constants.storageTypeLocal(), constants.storageTypeShared()) {

        @Override
        protected Boolean getRawValue(StoragePool object) {
            return object.isLocal();
        }
    };
    storageTypeColumn.makeSortable(StoragePoolFieldAutoCompleter.LOCAL);
    // $NON-NLS-1$
    getTable().addColumn(storageTypeColumn, constants.storgeTypeDc(), "150px");
    AbstractTextColumn<StoragePool> statusColumn = new AbstractEnumColumn<StoragePool, StoragePoolStatus>() {

        @Override
        public StoragePoolStatus getRawValue(StoragePool object) {
            return object.getStatus();
        }
    };
    statusColumn.makeSortable(StoragePoolFieldAutoCompleter.STATUS);
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.statusDc(), "150px");
    AbstractTextColumn<StoragePool> versionColumn = new AbstractTextColumn<StoragePool>() {

        @Override
        public String getValue(StoragePool object) {
            return object.getCompatibilityVersion().getValue();
        }
    };
    versionColumn.makeSortable(StoragePoolFieldAutoCompleter.COMPATIBILITY_VERSION);
    // $NON-NLS-1$
    getTable().addColumn(versionColumn, constants.comptVersDc(), "150px");
    AbstractTextColumn<StoragePool> descColumn = new AbstractTextColumn<StoragePool>() {

        @Override
        public String getValue(StoragePool object) {
            return object.getdescription();
        }
    };
    descColumn.makeSortable(StoragePoolFieldAutoCompleter.DESCRIPTION);
    // $NON-NLS-1$
    getTable().addColumn(descColumn, constants.descriptionDc(), "300px");
}
Also used : DcAdditionalStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.DcAdditionalStatusColumn) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) AbstractBooleanColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractBooleanColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) DcStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.DcStatusColumn) CommentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 40 with AbstractTextColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.

the class MainHostView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    HostStatusColumn<VDS> statusIconColumn = new HostStatusColumn<>();
    statusIconColumn.setContextMenuTitle(constants.statusIconHost());
    // $NON-NLS-1$
    getTable().addColumn(statusIconColumn, constants.empty(), "35px");
    HostAdditionalStatusColumn additionalStatusColumn = new HostAdditionalStatusColumn();
    additionalStatusColumn.setContextMenuTitle(constants.additionalStatusHost());
    // $NON-NLS-1$
    getTable().addColumn(additionalStatusColumn, constants.empty(), "60px");
    AbstractTextColumn<VDS> nameColumn = new AbstractLinkColumn<VDS>(new FieldUpdater<VDS, String>() {

        @Override
        public void update(int index, VDS host, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), host.getName());
            // The link was clicked, now fire an event to switch to details.
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.hostGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VDS object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable(VdsConditionFieldAutoCompleter.NAME);
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameHost(), "150px");
    CommentColumn<VDS> commentColumn = new CommentColumn<>();
    getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
    "75px");
    AbstractTextColumn<VDS> hostColumn = new AbstractTextColumn<VDS>() {

        @Override
        public String getValue(VDS object) {
            return object.getHostName();
        }
    };
    hostColumn.makeSortable(VdsConditionFieldAutoCompleter.ADDRESS);
    // $NON-NLS-1$
    getTable().addColumn(hostColumn, constants.ipHost(), "150px");
    AbstractTextColumn<VDS> clusterColumn = new AbstractLinkColumn<VDS>(new FieldUpdater<VDS, String>() {

        @Override
        public void update(int index, VDS host, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), host.getClusterName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VDS object) {
            return object.getClusterName();
        }
    };
    clusterColumn.makeSortable(VdsConditionFieldAutoCompleter.CLUSTER);
    // $NON-NLS-1$
    getTable().addColumn(clusterColumn, constants.clusterHost(), "150px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        AbstractTextColumn<VDS> dcColumn = new AbstractLinkColumn<VDS>(new FieldUpdater<VDS, String>() {

            @Override
            public void update(int index, VDS host, String value) {
                Map<String, String> parameters = new HashMap<>();
                parameters.put(FragmentParams.NAME.getName(), host.getStoragePoolName());
                getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.dataCenterStorageSubTabPlace, parameters);
            }
        }) {

            @Override
            public String getValue(VDS object) {
                return object.getStoragePoolName();
            }
        };
        dcColumn.makeSortable(VdsConditionFieldAutoCompleter.DATACENTER);
        // $NON-NLS-1$
        getTable().addColumn(dcColumn, constants.dcHost(), "150px");
    }
    AbstractTextColumn<VDS> statusColumn = new AbstractEnumColumn<VDS, VDSStatus>() {

        @Override
        public VDSStatus getRawValue(VDS object) {
            return object.getStatus();
        }
    };
    ReasonColumn<VDS> reasonColumn = new ReasonColumn<VDS>() {

        @Override
        protected String getReason(VDS value) {
            return value.getMaintenanceReason();
        }
    };
    List<HasCell<VDS, ?>> list = new ArrayList<>();
    list.add(statusColumn);
    list.add(reasonColumn);
    Cell<VDS> compositeCell = new StatusCompositeCell<>(list);
    AbstractColumn<VDS, VDS> statusTextColumn = new AbstractColumn<VDS, VDS>(compositeCell) {

        @Override
        public VDS getValue(VDS object) {
            return object;
        }

        @Override
        public SafeHtml getTooltip(VDS value) {
            String maintenanceReason = value.getMaintenanceReason();
            if (maintenanceReason != null && !maintenanceReason.trim().isEmpty()) {
                return SafeHtmlUtils.fromString(maintenanceReason);
            }
            return null;
        }
    };
    statusTextColumn.makeSortable(VdsConditionFieldAutoCompleter.STATUS);
    // $NON-NLS-1$
    getTable().addColumn(statusTextColumn, constants.statusHost(), "100px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        VmCountColumn vmCountColumn = new VmCountColumn();
        vmCountColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        vmCountColumn.makeSortable(VdsConditionFieldAutoCompleter.ACTIVE_VMS);
        // $NON-NLS-1$
        getTable().addColumn(vmCountColumn, constants.vmsCount(), "110px");
    }
    AbstractPercentColumn<VDS> memColumn = new AbstractPercentColumn<VDS>() {

        @Override
        public Integer getProgressValue(VDS object) {
            return object.getUsageMemPercent();
        }
    };
    memColumn.makeSortable(VdsConditionFieldAutoCompleter.MEM_USAGE);
    // $NON-NLS-1$
    getTable().addColumn(memColumn, constants.memoryHost(), "80px");
    AbstractPercentColumn<VDS> cpuColumn = new AbstractPercentColumn<VDS>() {

        @Override
        public Integer getProgressValue(VDS object) {
            return object.getUsageCpuPercent();
        }
    };
    cpuColumn.makeSortable(VdsConditionFieldAutoCompleter.CPU_USAGE);
    // $NON-NLS-1$
    getTable().addColumn(cpuColumn, constants.cpuHost(), "80px");
    AbstractPercentColumn<VDS> netColumn = new AbstractPercentColumn<VDS>() {

        @Override
        public Integer getProgressValue(VDS object) {
            return object.getUsageNetworkPercent();
        }
    };
    netColumn.makeSortable(VdsConditionFieldAutoCompleter.NETWORK_USAGE);
    // $NON-NLS-1$
    getTable().addColumn(netColumn, constants.networkHost(), "80px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        AbstractTextColumn<VDS> spmColumn = new AbstractTextColumn<VDS>() {

            @Override
            public String getValue(VDS object) {
                int value = object.getVdsSpmPriority();
                int lowValue = defaultSpmPriority / 2;
                int highValue = defaultSpmPriority + (maxSpmPriority - defaultSpmPriority) / 2;
                if (object.getSpmStatus() != VdsSpmStatus.None) {
                    return object.getSpmStatus().name();
                }
                if (value == -1) {
                    return constants.spmNeverText();
                } else if (value == lowValue) {
                    return constants.spmLowText();
                } else if (value == defaultSpmPriority) {
                    return constants.spmNormalText();
                } else if (value == highValue) {
                    return constants.spmHighText();
                }
                return constants.spmCustomText();
            }
        };
        // $NON-NLS-1$
        getTable().addColumn(spmColumn, constants.spmPriorityHost(), "100px");
    }
}
Also used : HasCell(com.google.gwt.cell.client.HasCell) ArrayList(java.util.ArrayList) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) CommentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn) HostStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.HostStatusColumn) VDS(org.ovirt.engine.core.common.businessentities.VDS) HostAdditionalStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.HostAdditionalStatusColumn) AbstractPercentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.AbstractPercentColumn) AbstractColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractColumn) VmCountColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmCountColumn) StatusCompositeCell(org.ovirt.engine.ui.common.widget.table.cell.StatusCompositeCell) ReasonColumn(org.ovirt.engine.ui.webadmin.widget.table.column.ReasonColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)57 AbstractEnumColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn)23 HashMap (java.util.HashMap)15 Map (java.util.Map)14 AbstractLinkColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn)14 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)10 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)9 AbstractDiskSizeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn)9 ImageResource (com.google.gwt.resources.client.ImageResource)8 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)7 AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)7 Column (com.google.gwt.user.cellview.client.Column)6 ArrayList (java.util.ArrayList)6 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)6 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 NoItemsLabel (org.ovirt.engine.ui.common.widget.label.NoItemsLabel)6 AbstractFullDateTimeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn)6 List (java.util.List)5 GWT (com.google.gwt.core.client.GWT)4 VM (org.ovirt.engine.core.common.businessentities.VM)4