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);
}
}
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);
}
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);
}
});
}
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);
}
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();
}
Aggregations