use of org.ovirt.engine.ui.uicompat.UIMessages in project ovirt-engine by oVirt.
the class VmListModel method initImportModelForVmsToImportNamesOnly.
private void initImportModelForVmsToImportNamesOnly(final ImportVmsModel importVmsModel, final ImportVmModel importVmModel) {
final UIMessages messages = ConstantsManager.getInstance().getMessages();
final UIConstants constants = ConstantsManager.getInstance().getConstants();
final List<String> vmsToImport = new ArrayList<>();
OriginType originType = convertImportSourceToOriginType(importVmsModel.getImportSources().getSelectedItem());
final List<VM> externalVms = importVmsModel.getVmsToImport();
for (VM vm : externalVms) {
vmsToImport.add(vm.getName());
}
importVmsModel.clearProblem();
importVmsModel.startProgress();
importVmModel.setMessage("");
AsyncQuery query = new AsyncQuery(returnValue -> {
if (returnValue instanceof QueryReturnValue) {
importVmsModel.setError(messages.providerFailure());
importVmsModel.stopProgress();
} else {
List<VM> remoteVms = (List<VM>) returnValue;
List<VM> remoteDownVms = new ArrayList<>();
List<VM> nonRetrievedVms = new ArrayList<>();
// find vms with status=down
for (VM vm : remoteVms) {
if (vm.isDown()) {
remoteDownVms.add(vm);
}
}
// i.e. they were retrieved with their names only but not with their full info
if (remoteVms.size() != externalVms.size()) {
for (VM vm : externalVms) {
if (!remoteVms.contains(vm)) {
nonRetrievedVms.add(vm);
}
}
}
importVmsModel.stopProgress();
// prepare error message to be displayed in one of the models
String messageForImportVm = null;
String messageForImportVms = null;
if (remoteVms.size() != remoteDownVms.size()) {
if (!nonRetrievedVms.isEmpty()) {
messageForImportVm = constants.nonRetrievedAndRunningVmsWereFilteredOnImportVm();
messageForImportVms = constants.nonRetrievedAndRunningVmsWereAllFilteredOnImportVm();
} else {
messageForImportVm = constants.runningVmsWereFilteredOnImportVm();
messageForImportVms = constants.runningVmsWereAllFilteredOnImportVm();
}
} else if (!nonRetrievedVms.isEmpty()) {
messageForImportVm = constants.nonRetrievedVmsWereFilteredOnImportVm();
messageForImportVms = constants.nonRetrievedVmsWereAllFilteredOnImportVm();
}
if (remoteDownVms.isEmpty() && messageForImportVms != null) {
importVmsModel.setError(messageForImportVms);
}
if (!importVmsModel.validateArchitectures(remoteDownVms)) {
return;
}
// init and display next dialog - the importVmsModel model
importVmModel.init(remoteDownVms, importVmsModel.getDataCenters().getSelectedItem().getId());
setWindow(null);
setWindow(importVmModel);
if (messageForImportVm != null) {
importVmModel.setMessage(messageForImportVm);
}
}
});
if (!(importVmModel instanceof ImportVmFromExternalSourceModel)) {
importVmsModel.setError(messages.providerImportFailure());
importVmsModel.stopProgress();
return;
}
ImportVmFromExternalSourceModel importVmsFromExternalSource = (ImportVmFromExternalSourceModel) importVmModel;
query.setHandleFailure(true);
AsyncDataProvider.getInstance().getVmsFromExternalServer(query, importVmsModel.getDataCenters().getSelectedItem().getId(), importVmsFromExternalSource.getProxyHostId(), importVmsFromExternalSource.getUrl(), importVmsFromExternalSource.getUsername(), importVmsFromExternalSource.getPassword(), originType, vmsToImport);
}
use of org.ovirt.engine.ui.uicompat.UIMessages in project ovirt-engine by oVirt.
the class SanStorageModelBase method updateGrayedOut.
private void updateGrayedOut(boolean isInMaintenance, Set<String> metadataDevices, LunModel lunModel) {
UIConstants constants = ConstantsManager.getInstance().getConstants();
UIMessages messages = ConstantsManager.getInstance().getMessages();
LUNs lun = lunModel.getEntity();
boolean nonEmpty = lun.getStorageDomainId() != null || lun.getDiskId() != null || lun.getStatus() == LunStatus.Unusable;
// Graying out LUNs
lunModel.setIsGrayedOut(isIgnoreGrayedOut() ? lun.getDiskId() != null : nonEmpty);
// Adding 'GrayedOutReasons'
if (lun.getDiskId() != null) {
lunModel.getGrayedOutReasons().add(messages.lunUsedByDiskWarning(lun.getDiskAlias()));
} else if (lun.getStorageDomainId() != null && !isInMaintenance) {
lunModel.getGrayedOutReasons().add(messages.lunAlreadyPartOfStorageDomainWarning(lun.getStorageDomainName()));
} else if (isInMaintenance && metadataDevices.contains(lun.getId())) {
lunModel.getGrayedOutReasons().add(messages.lunIsMetadataDevice(lun.getStorageDomainName()));
} else if (lun.getStatus() == LunStatus.Unusable) {
lunModel.getGrayedOutReasons().add(constants.lunUnusable());
}
}
use of org.ovirt.engine.ui.uicompat.UIMessages in project ovirt-engine by oVirt.
the class HostListModel method restart.
public void restart(String uiCommand) {
final UIConstants constants = ConstantsManager.getInstance().getConstants();
final UIMessages messages = ConstantsManager.getInstance().getMessages();
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(constants.restartHostsTitle());
model.setHelpTag(HelpTag.restart_host);
// $NON-NLS-1$
model.setHashName("restart_host");
model.setMessage(constants.areYouSureYouWantToRestartTheFollowingHostsMsg());
ArrayList<String> items = new ArrayList<>();
for (Object item : getSelectedItems()) {
VDS vds = (VDS) item;
int runningVms = vds.getVmCount();
if (runningVms > 0) {
items.add(messages.hostNumberOfRunningVms(vds.getName(), runningVms));
} else {
items.add(vds.getName());
}
}
model.setItems(items);
// $NON-NLS-1$
UICommand tempVar = new UICommand(uiCommand, this);
tempVar.setTitle(constants.ok());
tempVar.setIsDefault(true);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = new UICommand("Cancel", this);
tempVar2.setTitle(constants.cancel());
tempVar2.setIsCancel(true);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.ui.uicompat.UIMessages in project ovirt-engine by oVirt.
the class HostSetupNetworksModel method setLabelErrorsOnNicModels.
private void setLabelErrorsOnNicModels(Map<String, NetworkInterfaceModel> nicModels, List<LogicalNetworkModel> networkModelsWithLabelError, Map<String, String> labelToDesiredNicName) {
for (LogicalNetworkModel networkModel : networkModelsWithLabelError) {
NetworkInterfaceModel desiredNicModel = nicModels.get(labelToDesiredNicName.get(networkModel.getNetwork().getLabel()));
NetworkOperation operation = NetworkOperationFactory.operationFor(networkModel, desiredNicModel);
UIMessages messages = ConstantsManager.getInstance().getMessages();
// Should be attached but can't due to conflict
if (desiredNicModel != null) {
if (operation.isNullOperation()) {
networkModel.setErrorMessage(messages.networkLabelConflict(desiredNicModel.getName(), networkModel.getNetwork().getLabel()) + " " + // $NON-NLS-1$
operation.getMessage(networkModel, desiredNicModel));
} else {
networkModel.setErrorMessage(messages.labeledNetworkNotAttached(desiredNicModel.getName(), networkModel.getNetwork().getLabel()));
}
}
}
}
use of org.ovirt.engine.ui.uicompat.UIMessages in project ovirt-engine by oVirt.
the class VmModelHelper method sendWarningForNonExportableDisks.
public static void sendWarningForNonExportableDisks(Model model, List<Disk> vmDisks, WarningType warningType) {
final List<Disk> sharedImageDisks = new ArrayList<>();
final List<Disk> directLunDisks = new ArrayList<>();
final List<Disk> snapshotDisks = new ArrayList<>();
for (Disk disk : vmDisks) {
if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
if (disk.isShareable()) {
sharedImageDisks.add(disk);
} else if (disk.isDiskSnapshot()) {
snapshotDisks.add(disk);
}
} else if (disk.getDiskStorageType() == DiskStorageType.LUN) {
directLunDisks.add(disk);
}
}
final UIMessages messages = ConstantsManager.getInstance().getMessages();
// check if VM provides any disk for the export
if (vmDisks.size() - (sharedImageDisks.size() + directLunDisks.size() + snapshotDisks.size()) == 0) {
switch(warningType) {
case VM_EXPORT:
model.setMessage(messages.noExportableDisksFoundForTheExport());
break;
case VM_SNAPSHOT:
model.setMessage(messages.noExportableDisksFoundForTheSnapshot());
break;
case VM_TEMPLATE:
model.setMessage(messages.noExportableDisksFoundForTheTemplate());
break;
}
}
String diskLabels = getDiskLabelList(sharedImageDisks);
if (diskLabels != null) {
switch(warningType) {
case VM_EXPORT:
model.setMessage(messages.sharedDisksWillNotBePartOfTheExport(diskLabels));
break;
case VM_SNAPSHOT:
model.setMessage(messages.sharedDisksWillNotBePartOfTheSnapshot(diskLabels));
break;
case VM_TEMPLATE:
model.setMessage(messages.sharedDisksWillNotBePartOfTheTemplate(diskLabels));
break;
}
}
diskLabels = getDiskLabelList(directLunDisks);
if (diskLabels != null) {
switch(warningType) {
case VM_EXPORT:
model.setMessage(messages.directLUNDisksWillNotBePartOfTheExport(diskLabels));
break;
case VM_SNAPSHOT:
model.setMessage(messages.directLUNDisksWillNotBePartOfTheSnapshot(diskLabels));
break;
case VM_TEMPLATE:
model.setMessage(messages.directLUNDisksWillNotBePartOfTheTemplate(diskLabels));
break;
}
}
diskLabels = getDiskLabelList(snapshotDisks);
if (diskLabels != null) {
switch(warningType) {
case VM_EXPORT:
model.setMessage(messages.snapshotDisksWillNotBePartOfTheExport(diskLabels));
break;
case VM_SNAPSHOT:
model.setMessage(messages.snapshotDisksWillNotBePartOfTheSnapshot(diskLabels));
break;
case VM_TEMPLATE:
model.setMessage(messages.snapshotDisksWillNotBePartOfTheTemplate(diskLabels));
break;
}
}
}
Aggregations