use of org.ovirt.engine.ui.uicommonweb.models.tags.TagModel in project ovirt-engine by oVirt.
the class SearchPanelPresenterWidget method setTags.
public void setTags(List<TagModel> tags) {
List<String> tagString = new ArrayList<>();
for (TagModel tagModel : tags) {
tagString.add(tagModel.getName().getEntity());
}
model.setTagStrings(tagString);
if (isVisible()) {
model.executeCommand(model.getSearchCommand());
}
}
use of org.ovirt.engine.ui.uicommonweb.models.tags.TagModel in project ovirt-engine by oVirt.
the class TagObject method from.
private static TagObject from(TagModel model, boolean includeChildren) {
TagObject result = JavaScriptObject.createObject().cast();
// $NON-NLS-1$
result.setValueAsString("description", model.getDescription().getEntity());
// $NON-NLS-1$
result.setValueAsString("name", model.getName().getEntity());
// $NON-NLS-1$
result.setValueAsBoolean("selected", model.getSelection());
if (includeChildren) {
JsArray<TagObject> children = JavaScriptObject.createArray().cast();
for (TagModel child : model.getChildren()) {
children.push(TagObject.from(child, true));
}
// $NON-NLS-1$
result.setValueAsJavaScriptObject("children", children);
}
return result;
}
use of org.ovirt.engine.ui.uicommonweb.models.tags.TagModel 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();
}
use of org.ovirt.engine.ui.uicommonweb.models.tags.TagModel in project ovirt-engine by oVirt.
the class UserListModel method postOnAssignTags.
@Override
public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
TagListModel model = (TagListModel) getWindow();
ArrayList<Guid> userIds = new ArrayList<>();
ArrayList<Guid> grpIds = new ArrayList<>();
for (Object item : getSelectedItems()) {
DbUser user = (DbUser) item;
if (user.isGroup()) {
grpIds.add(user.getId());
} else {
userIds.add(user.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> usersToAttach = new ArrayList<>();
ArrayList<ActionParametersBase> grpsToAttach = new ArrayList<>();
for (Guid tag_id : tagsToAttach) {
if (userIds.size() > 0) {
usersToAttach.add(new AttachEntityToTagParameters(tag_id, userIds));
}
if (grpIds.size() > 0) {
grpsToAttach.add(new AttachEntityToTagParameters(tag_id, grpIds));
}
}
if (usersToAttach.size() > 0) {
Frontend.getInstance().runMultipleAction(ActionType.AttachUserToTag, usersToAttach);
}
if (grpsToAttach.size() > 0) {
Frontend.getInstance().runMultipleAction(ActionType.AttachUserGroupToTag, grpsToAttach);
}
ArrayList<ActionParametersBase> usersToDetach = new ArrayList<>();
ArrayList<ActionParametersBase> grpsToDetach = new ArrayList<>();
for (Guid tag_id : tagsToDetach) {
if (userIds.size() > 0) {
usersToDetach.add(new AttachEntityToTagParameters(tag_id, userIds));
}
if (grpIds.size() > 0) {
grpsToDetach.add(new AttachEntityToTagParameters(tag_id, grpIds));
}
}
if (usersToDetach.size() > 0) {
Frontend.getInstance().runMultipleAction(ActionType.DetachUserFromTag, usersToDetach);
}
if (grpsToDetach.size() > 0) {
Frontend.getInstance().runMultipleAction(ActionType.DetachUserGroupFromTag, grpsToDetach);
}
cancel();
}
use of org.ovirt.engine.ui.uicommonweb.models.tags.TagModel in project ovirt-engine by oVirt.
the class TagsView method updateTags.
@Override
public void updateTags(Collection<TagModel> tags) {
emptyTagsColumn.setVisible(tags.isEmpty());
rootListGroup.clear();
for (TagModel model : tags) {
addChildTags(model.getChildren(), rootListGroup, 0);
}
}
Aggregations