Search in sources :

Example 1 with ImportVmData

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

the class ImportVmFromExternalProviderPopupView method initMainTable.

protected void initMainTable() {
    this.table = new ListModelObjectCellTable<>();
    AbstractCheckboxColumn<ImportVmData> cloneVMColumn = new AbstractCheckboxColumn<ImportVmData>((index, model, value) -> {
        model.getClone().setEntity(value);
        table.asEditor().edit(importModel);
    }) {

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

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

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

        @Override
        public String getValue(ImportVmData object) {
            return object.getName();
        }
    };
    // $NON-NLS-1$
    table.addColumn(nameColumn, constants.nameVm(), "150px");
    AbstractTextColumn<ImportVmData> originColumn = new AbstractEnumColumn<ImportVmData, OriginType>() {

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

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

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

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

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

        @Override
        public String getValue(ImportVmData object) {
            return String.valueOf(object.getVm().getDiskMap().size());
        }
    };
    // $NON-NLS-1$
    table.addColumn(diskColumn, constants.disksVm(), "50px");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    splitLayoutPanel.add(sp);
    table.getElement().getStyle().setPosition(Position.RELATIVE);
}
Also used : AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ImportVmData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 2 with ImportVmData

use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData 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 3 with ImportVmData

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

the class RegisterVmInfoPanel method updateTabsData.

@Override
public void updateTabsData(ImportEntityData<VM> importEntityData) {
    ImportVmData importVmData = (ImportVmData) importEntityData;
    VM vm = importVmData.getVm();
    vmImportGeneralModel.setEntity(importVmData);
    generalView.setMainSelectedItem(vm);
    disksTable.setRowData((List) Arrays.asList(vm.getDiskMap().values().toArray()));
    nicsTable.setRowData((List) Arrays.asList(vm.getInterfaces().toArray()));
    appsTable.setRowData(vm.getAppList() == null ? Collections.emptyList() : // $NON-NLS-1$
    (List) Arrays.asList(vm.getAppList().split("[,]", -1)));
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ImportVmData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData) List(java.util.List)

Aggregations

ImportVmData (org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)2 AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)2 AbstractEnumColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn)2 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)2 ImageResource (com.google.gwt.resources.client.ImageResource)1 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)1 List (java.util.List)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 AbstractImageResourceColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn)1