Search in sources :

Example 36 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class ExistingVmModelBehavior method setImagesToModel.

@Override
protected void setImagesToModel(UnitVmModel model, List<RepoImage> images) {
    model.getCdImage().setItems(images);
    boolean hasCd = !StringHelper.isNullOrEmpty(vm.getIsoPath());
    getModel().getCdImage().setIsChangeable(hasCd);
    getModel().getCdAttached().setEntity(hasCd);
    if (hasCd) {
        RepoImage selectedImage = images.stream().filter(i -> vm.getIsoPath().equals(i.getRepoImageId())).findFirst().orElse(null);
        model.getCdImage().setSelectedItem((selectedImage != null) ? selectedImage : Linq.firstOrNull(images));
    }
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Example 37 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class ImageMapper method map.

@Mapping(from = RepoImage.class, to = Image.class)
public static Image map(RepoImage entity, Image template) {
    Image model = template != null ? template : new Image();
    model.setId(entity.getRepoImageId());
    model.setName(entity.getRepoImageName());
    model.setSize(entity.getSize());
    model.setType(mapImageType(entity.getFileType()));
    return model;
}
Also used : Image(org.ovirt.engine.api.model.Image) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage)

Example 38 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class ImportVmFromExternalProviderPopupView method initListBoxEditors.

private void initListBoxEditors() {
    destClusterEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<Cluster>() {

        @Override
        public String renderNullSafe(Cluster object) {
            return object.getName();
        }
    });
    destClusterQuotaEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<Quota>() {

        @Override
        public String renderNullSafe(Quota object) {
            return object.getQuotaName();
        }
    });
    destStorageEditor = new ListModelListBoxEditor<>(new StorageDomainFreeSpaceRenderer());
    cpuProfileEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<CpuProfile>() {

        @Override
        protected String renderNullSafe(CpuProfile object) {
            return object.getName();
        }
    });
    disksAllocationEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<VolumeType>() {

        @Override
        protected String renderNullSafe(VolumeType object) {
            return new EnumRenderer<VolumeType>().render(object);
        }
    });
    attachDriversEditor = new EntityModelCheckBoxEditor(Align.LEFT);
    cdImageEditor = new ListModelListBoxOnlyEditor<>(new NullSafeRenderer<RepoImage>() {

        @Override
        protected String renderNullSafe(RepoImage object) {
            return object.getRepoImageId();
        }
    });
}
Also used : VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Quota(org.ovirt.engine.core.common.businessentities.Quota) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) NullSafeRenderer(org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) StorageDomainFreeSpaceRenderer(org.ovirt.engine.ui.common.widget.renderer.StorageDomainFreeSpaceRenderer)

Example 39 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class VmRunOncePopupWidget method initListBoxEditors.

void initListBoxEditors() {
    vncKeyboardLayoutEditor = new ListModelListBoxEditor<>(new VncKeyMapRenderer());
    this.kernelImageEditor = new ListModelTypeAheadChangeableListBoxEditor(new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() {

        @Override
        public String getDisplayStringNullSafe(String data) {
            return typeAheadNameTemplateNullSafe(data);
        }
    }, false, new VisibilityRenderer.SimpleVisibilityRenderer(), constants.empty());
    this.initrdImageEditor = new ListModelTypeAheadChangeableListBoxEditor(new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() {

        @Override
        public String getDisplayStringNullSafe(String data) {
            return typeAheadNameTemplateNullSafe(data);
        }
    }, false, new VisibilityRenderer.SimpleVisibilityRenderer(), constants.empty());
    isoImageEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<RepoImage>() {

        @Override
        protected String renderNullSafe(RepoImage object) {
            // For old ISO images from an ISO domain the image name is empty
            if (StringHelper.isNullOrEmpty(object.getRepoImageName())) {
                return object.getRepoImageId();
            }
            return object.getRepoImageName();
        }
    });
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) NullSafeRenderer(org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer) ListModelTypeAheadChangeableListBoxEditor(org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadChangeableListBoxEditor) VncKeyMapRenderer(org.ovirt.engine.ui.common.widget.editor.VncKeyMapRenderer)

Example 40 with RepoImage

use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.

the class AbstractVmPopupWidget method initListBoxEditors.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void initListBoxEditors() {
    // General tab
    dataCenterWithClusterEditor = new GroupedListModelListBoxEditor<>(new GroupedListModelListBox<DataCenterWithCluster>(new NameRenderer<>()) {

        @Override
        public String getModelLabel(DataCenterWithCluster model) {
            return model.getCluster().getName();
        }

        @Override
        public String getGroupLabel(DataCenterWithCluster model) {
            return messages.hostDataCenter(model.getDataCenter().getName());
        }

        public Comparator<DataCenterWithCluster> getComparator() {
            return Comparator.comparing((DataCenterWithCluster d) -> d.getDataCenter().getName(), Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)).thenComparing(d -> d.getCluster().getName(), Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER));
        }
    });
    quotaEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<Quota>() {

        @Override
        public String getReplacementStringNullSafe(Quota data) {
            return data.getQuotaName();
        }

        @Override
        public String getDisplayStringNullSafe(Quota data) {
            return typeAheadNameDescriptionTemplateNullSafe(data.getQuotaName(), data.getDescription());
        }
    }, new ModeSwitchingVisibilityRenderer());
    baseTemplateEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<VmTemplate>() {

        @Override
        public String getReplacementStringNullSafe(VmTemplate data) {
            return data.getName();
        }

        @Override
        public String getDisplayStringNullSafe(VmTemplate data) {
            return typeAheadNameDescriptionTemplateNullSafe(data.getName(), data.getDescription());
        }
    }, new ModeSwitchingVisibilityRenderer());
    templateWithVersionEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<TemplateWithVersion>() {

        @Override
        public String getReplacementStringNullSafe(TemplateWithVersion templateWithVersion) {
            return getFirstColumn(templateWithVersion) + // $NON-NLS-1$
            " | " + getSecondColumn(templateWithVersion);
        }

        @Override
        public String getDisplayStringNullSafe(TemplateWithVersion templateWithVersion) {
            return typeAheadNameDescriptionTemplateNullSafe(getFirstColumn(templateWithVersion), getSecondColumn(templateWithVersion));
        }

        private String getFirstColumn(TemplateWithVersion templateWithVersion) {
            return templateWithVersion.getBaseTemplate().getName();
        }

        private String getSecondColumn(TemplateWithVersion templateWithVersion) {
            final VmTemplate versionTemplate = templateWithVersion.getTemplateVersion();
            final String versionName = versionTemplate.getTemplateVersionName() == null ? // $NON-NLS-1$
            "" : // $NON-NLS-1$
            versionTemplate.getTemplateVersionName() + " ";
            return templateWithVersion.isLatest() ? constants.latest() : // $NON-NLS-1$
            versionName + "(" + versionTemplate.getTemplateVersionNumber() + // $NON-NLS-1$
            ")";
        }
    }, new ModeSwitchingVisibilityRenderer(), new SuggestionMatcher.ContainsSuggestionMatcher());
    oSTypeEditor = new ListModelListBoxEditor<>(new AbstractRenderer<Integer>() {

        @Override
        public String render(Integer object) {
            return AsyncDataProvider.getInstance().getOsName(object);
        }
    }, new ModeSwitchingVisibilityRenderer());
    vmTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<VmType>(), new ModeSwitchingVisibilityRenderer());
    instanceTypesEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<InstanceType>() {

        @Override
        public String getReplacementStringNullSafe(InstanceType data) {
            return data.getName();
        }

        @Override
        public String getDisplayStringNullSafe(InstanceType data) {
            return typeAheadNameDescriptionTemplateNullSafe(data.getName(), data.getDescription());
        }
    }, new ModeSwitchingVisibilityRenderer());
    emulatedMachine = new ListModelTypeAheadChangeableListBoxEditor(new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() {

        @Override
        public String getDisplayStringNullSafe(String data) {
            if (data == null || data.trim().isEmpty()) {
                data = getDefaultEmulatedMachineLabel();
            }
            return typeAheadNameTemplateNullSafe(data);
        }
    }, false, new ModeSwitchingVisibilityRenderer(), constants.clusterDefaultOption());
    customCpu = new ListModelTypeAheadChangeableListBoxEditor(new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() {

        @Override
        public String getDisplayStringNullSafe(String data) {
            if (data == null || data.trim().isEmpty()) {
                data = getDefaultCpuTypeLabel();
            }
            return typeAheadNameTemplateNullSafe(data);
        }
    }, false, new ModeSwitchingVisibilityRenderer(), constants.clusterDefaultOption());
    numOfSocketsEditor = new ListModelListBoxEditor<>(new ModeSwitchingVisibilityRenderer());
    numOfSocketsEditorWithDetachable = new EntityModelDetachableWidgetWithLabel(numOfSocketsEditor);
    corePerSocketEditor = new ListModelListBoxEditor<>(new ModeSwitchingVisibilityRenderer());
    corePerSocketEditorWithDetachable = new EntityModelDetachableWidgetWithLabel(corePerSocketEditor);
    initThreadsPerCore();
    // Pools
    poolTypeEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<EntityModel<VmPoolType>>() {

        @Override
        public String renderNullSafe(EntityModel<VmPoolType> object) {
            return object.getTitle();
        }
    }, new ModeSwitchingVisibilityRenderer());
    timeZoneEditor = new ListModelListBoxOnlyEditor<>(new NullSafeRenderer<TimeZoneModel>() {

        @Override
        public String renderNullSafe(TimeZoneModel timeZone) {
            if (timeZone.isDefault()) {
                return messages.defaultTimeZoneCaption(timeZone.getDisplayValue());
            } else {
                return timeZone.getDisplayValue();
            }
        }
    }, new ModeSwitchingVisibilityRenderer());
    EnableableFormLabel label = new EnableableFormLabel();
    label.setText(constants.timeZoneVm());
    timeZoneEditorWithInfo = new EntityModelWidgetWithInfo(label, timeZoneEditor);
    timeZoneEditorWithInfo.setExplanation(templates.italicText(constants.timeZoneInfo()));
    // Console tab
    displayTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<DisplayType>(), new ModeSwitchingVisibilityRenderer());
    graphicsTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<UnitVmModel.GraphicsTypes>());
    usbSupportEditor = new ListModelListBoxEditor<>(new EnumRenderer<UsbPolicy>(), new ModeSwitchingVisibilityRenderer());
    consoleDisconnectActionEditor = new ListModelListBoxEditor<>(new EnumRenderer<ConsoleDisconnectAction>(), new ModeSwitchingVisibilityRenderer());
    numOfMonitorsEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<Integer>() {

        @Override
        public String renderNullSafe(Integer object) {
            return object.toString();
        }
    }, new ModeSwitchingVisibilityRenderer());
    numOfMonitorsEditor.hideLabel();
    vncKeyboardLayoutEditor = new ListModelListBoxEditor<>(new VncKeyMapRenderer(), new ModeSwitchingVisibilityRenderer());
    // Host Tab
    // $NON-NLS-1$
    specificHost = new EntityModelRadioButtonEditor("runVmOnHostGroup", new ModeSwitchingVisibilityRenderer());
    isAutoAssignEditor = // $NON-NLS-1$
    new EntityModelRadioButtonEditor("runVmOnHostGroup", new ModeSwitchingVisibilityRenderer());
    defaultHostEditor = new ListModelMultipleSelectListBoxEditor<>(new NameRenderer<VDS>(), new ModeSwitchingVisibilityRenderer());
    defaultHostEditor.hideLabel();
    migrationModeEditor = new ListModelListBoxEditor<>(new EnumRenderer<MigrationSupport>(), new ModeSwitchingVisibilityRenderer());
    migrationModeEditor.hideLabel();
    overrideMigrationDowntimeEditor = new EntityModelCheckBoxEditor(Align.RIGHT, new ModeSwitchingVisibilityRenderer());
    migrationDowntimeEditor = new IntegerEntityModelTextBoxOnlyEditor(new ModeSwitchingVisibilityRenderer());
    overrideMigrationPolicyEditor = new EntityModelCheckBoxEditor(Align.RIGHT, new ModeSwitchingVisibilityRenderer());
    migrationPolicyEditor = new ListModelListBoxOnlyEditor<>(new NameRenderer<MigrationPolicy>(), new ModeSwitchingVisibilityRenderer());
    autoConvergeEditor = new ListModelListBoxEditor<>(new BooleanRendererWithNullText(constants.autoConverge(), constants.dontAutoConverge(), constants.inheritFromCluster()), new ModeSwitchingVisibilityRenderer());
    migrateCompressedEditor = new ListModelListBoxEditor<>(new BooleanRendererWithNullText(constants.compress(), constants.dontCompress(), constants.inheritFromCluster()), new ModeSwitchingVisibilityRenderer());
    // Resource Allocation
    provisioningThinEditor = // $NON-NLS-1$
    new EntityModelRadioButtonEditor("provisioningGroup", new ModeSwitchingVisibilityRenderer());
    provisioningCloneEditor = // $NON-NLS-1$
    new EntityModelRadioButtonEditor("provisioningGroup", new ModeSwitchingVisibilityRenderer());
    // Boot Options Tab
    firstBootDeviceEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<EntityModel<BootSequence>>() {

        @Override
        public String renderNullSafe(EntityModel<BootSequence> object) {
            return object.getTitle();
        }
    }, new ModeSwitchingVisibilityRenderer());
    secondBootDeviceEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<EntityModel<BootSequence>>() {

        @Override
        public String renderNullSafe(EntityModel<BootSequence> object) {
            return object.getTitle();
        }
    }, new ModeSwitchingVisibilityRenderer());
    cdImageEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<RepoImage>() {

        @Override
        public String renderNullSafe(RepoImage object) {
            // For old ISO images from an ISO domain the image name is empty
            if (StringHelper.isNullOrEmpty(object.getRepoImageName())) {
                return object.getRepoImageId();
            }
            return object.getRepoImageName();
        }
    }, new ModeSwitchingVisibilityRenderer());
    cdImageEditor.hideLabel();
    cpuProfilesEditor = new ListModelListBoxEditor<>(new NameRenderer<CpuProfile>());
    cpuSharesAmountSelectionEditor = new ListModelListBoxOnlyEditor<>(new EnumRenderer<UnitVmModel.CpuSharesAmount>(), new ModeSwitchingVisibilityRenderer());
    numaTuneMode = new ListModelListBoxEditor<>(new EnumRenderer(), new ModeSwitchingVisibilityRenderer());
    providersEditor = new ListModelListBoxEditor<>(new NameRenderer<Provider<OpenstackNetworkProviderProperties>>());
    providersEditor.setLabel(constants.providerLabel());
}
Also used : ListModelTypeAheadChangeableListBoxEditor(org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadChangeableListBoxEditor) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) NullSafeRenderer(org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer) DataCenterWithCluster(org.ovirt.engine.ui.uicommonweb.models.vms.DataCenterWithCluster) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) EntityModelDetachableWidgetWithLabel(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelDetachableWidgetWithLabel) BooleanRendererWithNullText(org.ovirt.engine.ui.common.widget.renderer.BooleanRendererWithNullText) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) BootSequence(org.ovirt.engine.core.common.businessentities.BootSequence) VmPoolType(org.ovirt.engine.core.common.businessentities.VmPoolType) EnableableFormLabel(org.ovirt.engine.ui.common.widget.label.EnableableFormLabel) TimeZoneModel(org.ovirt.engine.ui.uicommonweb.models.vms.TimeZoneModel) VncKeyMapRenderer(org.ovirt.engine.ui.common.widget.editor.VncKeyMapRenderer) GroupedListModelListBox(org.ovirt.engine.ui.common.widget.editor.GroupedListModelListBox) EnumRenderer(org.ovirt.engine.ui.common.widget.renderer.EnumRenderer) EntityModelWidgetWithInfo(org.ovirt.engine.ui.common.widget.EntityModelWidgetWithInfo) Quota(org.ovirt.engine.core.common.businessentities.Quota) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) AbstractRenderer(com.google.gwt.text.shared.AbstractRenderer) IntegerEntityModelTextBoxOnlyEditor(org.ovirt.engine.ui.common.widget.editor.generic.IntegerEntityModelTextBoxOnlyEditor) EntityModelRadioButtonEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor)

Aggregations

RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)41 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)5 Guid (org.ovirt.engine.core.compat.Guid)5 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)4 InstanceType (org.ovirt.engine.core.common.businessentities.InstanceType)3 Quota (org.ovirt.engine.core.common.businessentities.Quota)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 NullSafeRenderer (org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Lock (java.util.concurrent.locks.Lock)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)2 ListModelTypeAheadChangeableListBoxEditor (org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadChangeableListBoxEditor)2 VncKeyMapRenderer (org.ovirt.engine.ui.common.widget.editor.VncKeyMapRenderer)2 EntityModelCheckBoxEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)2