Search in sources :

Example 1 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class VmListModel method getAttachedTagsToSelectedVMs.

private void getAttachedTagsToSelectedVMs(final TagListModel model) {
    ArrayList<Guid> vmIds = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VM vm = (VM) item;
        vmIds.add(vm.getId());
    }
    attachedTagsToEntities = new HashMap<>();
    allAttachedTags = new ArrayList<>();
    selectedItemsCounter = 0;
    for (Guid id : vmIds) {
        AsyncDataProvider.getInstance().getAttachedTagsToVm(new AsyncQuery<>(returnValue -> {
            allAttachedTags.addAll(returnValue);
            selectedItemsCounter++;
            if (selectedItemsCounter == getSelectedItems().size()) {
                postGetAttachedTags(model);
            }
        }), id);
    }
}
Also used : Arrays(java.util.Arrays) Event(org.ovirt.engine.ui.uicompat.Event) ImagesDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.ImagesDataProvider) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ICancelable(org.ovirt.engine.ui.uicompat.ICancelable) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) VmBaseToVmBaseForTemplateCompositeBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.VmBaseToVmBaseForTemplateCompositeBaseBuilder) ChangeDiskCommandParameters(org.ovirt.engine.core.common.action.ChangeDiskCommandParameters) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ShutdownVmParameters(org.ovirt.engine.core.common.action.ShutdownVmParameters) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VmConsoles(org.ovirt.engine.ui.uicommonweb.models.VmConsoles) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) VmWithStatusForExclusiveLock(org.ovirt.engine.core.common.businessentities.VmWithStatusForExclusiveLock) QueryType(org.ovirt.engine.core.common.queries.QueryType) ChangeVMClusterParameters(org.ovirt.engine.core.common.action.ChangeVMClusterParameters) VmBaseListModel(org.ovirt.engine.ui.uicommonweb.models.templates.VmBaseListModel) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) MigrateVmParameters(org.ovirt.engine.core.common.action.MigrateVmParameters) StopVmTypeEnum(org.ovirt.engine.core.common.action.StopVmTypeEnum) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ConsoleContext(org.ovirt.engine.ui.uicommonweb.ConsoleOptionsFrontendPersister.ConsoleContext) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) Pair(org.ovirt.engine.core.common.utils.Pair) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) ConsolePopupModel(org.ovirt.engine.ui.uicommonweb.models.ConsolePopupModel) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) VmHostDeviceListModel(org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.VmHostDeviceListModel) ConsolesFactory(org.ovirt.engine.ui.uicommonweb.models.ConsolesFactory) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VmCommonUtils(org.ovirt.engine.core.common.utils.VmCommonUtils) VM(org.ovirt.engine.core.common.businessentities.VM) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) StopVmParameters(org.ovirt.engine.core.common.action.StopVmParameters) MigrationSupport(org.ovirt.engine.core.common.businessentities.MigrationSupport) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) UnitToAddVmTemplateParametersBuilder(org.ovirt.engine.ui.uicommonweb.builders.template.UnitToAddVmTemplateParametersBuilder) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) VmType(org.ovirt.engine.core.common.businessentities.VmType) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) VmIconUnitAndVmToParameterBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.VmIconUnitAndVmToParameterBuilder) Inject(com.google.inject.Inject) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmAffinityGroupListModel(org.ovirt.engine.ui.uicommonweb.models.configure.scheduling.affinity_groups.list.VmAffinityGroupListModel) VmErrataCountModel(org.ovirt.engine.ui.uicommonweb.models.VmErrataCountModel) RemoveVmParameters(org.ovirt.engine.core.common.action.RemoveVmParameters) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AddVmTemplateParameters(org.ovirt.engine.core.common.action.AddVmTemplateParameters) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) ChangeCDModel(org.ovirt.engine.ui.uicommonweb.models.configure.ChangeCDModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Collectors(java.util.stream.Collectors) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) Objects(java.util.Objects) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) Entry(java.util.Map.Entry) ObservableCollection(org.ovirt.engine.ui.uicompat.ObservableCollection) CommonUnitToVmBaseBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonUnitToVmBaseBuilder) UnitToGraphicsDeviceParamsBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.UnitToGraphicsDeviceParamsBuilder) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) MigrateVmToServerParameters(org.ovirt.engine.core.common.action.MigrateVmToServerParameters) VmAffinityLabelListModel(org.ovirt.engine.ui.uicommonweb.models.configure.labels.list.VmAffinityLabelListModel) HashMap(java.util.HashMap) VmEntityType(org.ovirt.engine.core.common.businessentities.VmEntityType) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) MoveOrCopyParameters(org.ovirt.engine.core.common.action.MoveOrCopyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) ExportOvaParameters(org.ovirt.engine.core.common.action.ExportOvaParameters) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) Provider(com.google.inject.Provider) VmOperationParameterBase(org.ovirt.engine.core.common.action.VmOperationParameterBase) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class VmListModel method assignTags.

private void assignTags() {
    if (getWindow() != null) {
        return;
    }
    TagListModel model = new TagListModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().assignTagsTitle());
    model.setHelpTag(HelpTag.assign_tags_vms);
    // $NON-NLS-1$
    model.setHashName("assign_tags_vms");
    getAttachedTagsToSelectedVMs(model);
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnAssignTags", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)

Example 3 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class AssignTagsPopupView method edit.

@Override
public void edit(TagListModel object) {
    driver.edit(object);
    // Listen to Properties
    object.getPropertyChangedEvent().addListener((ev, sender, args) -> {
        TagListModel model = (TagListModel) sender;
        String propertyName = args.propertyName;
        if ("SelectionNodeList".equals(propertyName)) {
            // $NON-NLS-1$
            updateTree(model);
        }
    });
}
Also used : TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)

Example 4 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class HostListModel method assignTags.

public void assignTags() {
    if (getWindow() != null) {
        return;
    }
    TagListModel model = new TagListModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().assignTagsTitle());
    model.setHelpTag(HelpTag.assign_tags_hosts);
    // $NON-NLS-1$
    model.setHashName("assign_tags_hosts");
    getAttachedTagsToSelectedHosts(model);
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnAssignTags", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)

Example 5 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class HostListModel method postOnAssignTags.

@Override
public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
    TagListModel model = (TagListModel) getWindow();
    ArrayList<Guid> hostIds = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VDS vds = (VDS) item;
        hostIds.add(vds.getId());
    }
    // prepare attach/detach lists
    ArrayList<Guid> tagsToAttach = new ArrayList<>();
    ArrayList<Guid> tagsToDetach = new ArrayList<>();
    if (model.getItems() != null && model.getItems().size() > 0) {
        ArrayList<TagModel> tags = (ArrayList<TagModel>) model.getItems();
        TagModel rootTag = tags.get(0);
        TagModel.recursiveEditAttachDetachLists(rootTag, attachedTags, tagsToAttach, tagsToDetach);
    }
    ArrayList<ActionParametersBase> prmsToAttach = new ArrayList<>();
    for (Guid tag_id : tagsToAttach) {
        prmsToAttach.add(new AttachEntityToTagParameters(tag_id, hostIds));
    }
    Frontend.getInstance().runMultipleAction(ActionType.AttachVdsToTag, prmsToAttach);
    ArrayList<ActionParametersBase> prmsToDetach = new ArrayList<>();
    for (Guid tag_id : tagsToDetach) {
        prmsToDetach.add(new AttachEntityToTagParameters(tag_id, hostIds));
    }
    Frontend.getInstance().runMultipleAction(ActionType.DetachVdsFromTag, prmsToDetach);
    cancel();
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) Guid(org.ovirt.engine.core.compat.Guid) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

TagListModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)13 ArrayList (java.util.ArrayList)6 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)6 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)6 Guid (org.ovirt.engine.core.compat.Guid)6 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)6 TagModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagModel)6 Inject (com.google.inject.Inject)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 ActionUtils (org.ovirt.engine.core.common.ActionUtils)3 ActionType (org.ovirt.engine.core.common.action.ActionType)3 Tags (org.ovirt.engine.core.common.businessentities.Tags)3 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)3 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)3 QueryType (org.ovirt.engine.core.common.queries.QueryType)3 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)3 SearchObjects (org.ovirt.engine.core.searchbackend.SearchObjects)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3