use of org.ovirt.engine.core.common.businessentities.Nameable in project ovirt-engine by oVirt.
the class RemoveQosModel method handleSetMessageQueryResult.
protected void handleSetMessageQueryResult(FrontendMultipleQueryAsyncResult result) {
Map<String, String> entitiesAndQos = new HashMap<>();
setHelpTag(getRemoveQosHelpTag());
setHashName(getRemoveQosHashName());
int index = 0;
for (QueryReturnValue returnValue : result.getReturnValues()) {
for (Nameable entity : (List<Nameable>) returnValue.getReturnValue()) {
entitiesAndQos.put(entity.getName(), sourceListModel.getSelectedItems().get(index).getName());
}
index++;
}
if (entitiesAndQos.isEmpty()) {
ArrayList<String> list = new ArrayList<>();
for (T item : sourceListModel.getSelectedItems()) {
list.add(item.getName());
}
setItems(list);
} else {
setMessage(getRemoveQosMessage(entitiesAndQos.size()));
ArrayList<String> list = new ArrayList<>();
for (Entry<String, String> item : entitiesAndQos.entrySet()) {
// $NON-NLS-1$ //$NON-NLS-2$
list.add(item.getKey() + " (" + item.getValue() + ")");
}
setItems(list);
}
}
use of org.ovirt.engine.core.common.businessentities.Nameable in project ovirt-engine by oVirt.
the class RemoveStorageQosModel method handleSetMessageQueryResult.
protected void handleSetMessageQueryResult(FrontendMultipleQueryAsyncResult result) {
setHelpTag(getRemoveQosHelpTag());
setHashName(getRemoveQosHashName());
int index = 0;
int numberOfTimesUsedByDiskProfiles = 0;
ArrayList<String> list = new ArrayList<>();
for (QueryReturnValue returnValue : result.getReturnValues()) {
List<Nameable> diskProfileEntities = returnValue.getReturnValue();
String qosName = sourceListModel.getSelectedItems().get(index).getName();
if (diskProfileEntities.size() == 0) {
list.add(qosName);
} else {
numberOfTimesUsedByDiskProfiles += diskProfileEntities.size();
List<String> diskProfileNames = new ArrayList<>();
for (Nameable diskProfileEntity : diskProfileEntities) {
String diskProfileName = diskProfileEntity.getName();
diskProfileNames.add(diskProfileName);
}
// $NON-NLS-1$
String diskProfileNamesAsString = String.join(", ", diskProfileNames);
list.add(ConstantsManager.getInstance().getMessages().removeStorageQoSItem(qosName, diskProfileNamesAsString));
}
index++;
}
setMessage(getRemoveQosMessage(numberOfTimesUsedByDiskProfiles));
setItems(list);
}
use of org.ovirt.engine.core.common.businessentities.Nameable in project ovirt-engine by oVirt.
the class ListModelSearchBox method setInternalRowData.
private void setInternalRowData(int start, List<? extends T> values) {
final int oldCount = menu.getWidgetCount();
clearMenu();
emptyMenuHandlers();
for (T model : values) {
if (model instanceof Nameable) {
final String text = getName(model).asString();
final AnchorListItem item = new SearchBoxAnchorListItem(this);
item.setText(text);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (StringHelper.isNotNullOrEmpty(currentSearch)) {
String newText = text.replaceAll(currentSearch, // $NON-NLS-1$
"<strong>" + currentSearch + // $NON-NLS-1$
"</strong>");
item.getWidget(0).getElement().setInnerHTML(newText);
}
}
});
menuHandlers.add(item.addClickHandler(this));
menu.add(item);
}
}
if (oldCount != menu.getWidgetCount()) {
currentFocusIndex = 0;
}
if (currentFocusIndex >= menu.getWidgetCount() - 1) {
currentFocusIndex = menu.getWidgetCount() - 1;
}
if (currentFocusIndex >= 0) {
((AnchorListItem) menu.getWidget(currentFocusIndex)).setFocus(true);
}
}
use of org.ovirt.engine.core.common.businessentities.Nameable in project ovirt-engine by oVirt.
the class ReplacementUtilsTest method replaceWithNameableCollection.
@Test
public void replaceWithNameableCollection() {
Nameable item = () -> PROPERTY_VALUE;
List<Nameable> items = Collections.singletonList(item);
validateReplacements(ReplacementUtils.replaceWithNameable(PROPERTY_NAME, items), items);
}
Aggregations