use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.
the class InstanceTypeListModel method createWindow.
private void createWindow(VmModelBehaviorBase<UnitVmModel> behavior, String hashName, String onOkAction, boolean isNew, String title, HelpTag helpTag) {
if (getWindow() != null) {
return;
}
UnitVmModel model = new UnitVmModel(behavior, this);
// $NON-NLS-1$
model.setIsAdvancedModeLocalStorageKey("instance_type_dialog");
setWindow(model);
model.setTitle(title);
model.setHelpTag(helpTag);
// $NON-NLS-1$
model.setHashName(hashName);
model.setIsNew(isNew);
model.initialize();
VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
switchModeCommand.init(model);
model.getCommands().add(switchModeCommand);
UICommand newTemplate = UICommand.createDefaultOkUiCommand(onOkAction, this);
model.getCommands().add(newTemplate);
// $NON-NLS-1$
UICommand cancel = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(cancel);
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.
the class InstanceTypeListModel method onEditInstanceType.
private void onEditInstanceType() {
UnitVmModel model = (UnitVmModel) getWindow();
if (!model.validateInstanceTypePart()) {
return;
}
VmTemplate instanceType = (VmTemplate) Cloner.clone(selectedItem);
instanceType.setTemplateType(VmEntityType.INSTANCE_TYPE);
buildVmStatic(instanceType);
instanceType.setDescription(model.getDescription().getEntity());
UpdateVmTemplateParameters updateInstanceTypeParameters = new UpdateVmTemplateParameters(instanceType);
updateInstanceTypeParameters.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity());
updateInstanceTypeParameters.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity());
updateInstanceTypeParameters.setBalloonEnabled(model.getMemoryBalloonDeviceEnabled().getEntity());
updateInstanceTypeParameters.setVirtioScsiEnabled(model.getIsVirtioScsiEnabled().getEntity());
if (model.getIsHeadlessModeEnabled().getEntity()) {
updateInstanceTypeParameters.getVmTemplateData().setDefaultDisplayType(DisplayType.none);
}
setVmWatchdogToParams(model, updateInstanceTypeParameters);
setRngDeviceToParams(model, updateInstanceTypeParameters);
BuilderExecutor.build(model, updateInstanceTypeParameters, new UnitToGraphicsDeviceParamsBuilder());
getWindow().startProgress();
Frontend.getInstance().runAction(ActionType.UpdateVmTemplate, updateInstanceTypeParameters, new UnitVmModelNetworkAsyncCallback(model, addInstanceTypeNetworkManager, instanceType.getId()), this);
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.
the class TemplateListModel method postUpdateVmTemplate.
public void postUpdateVmTemplate(ActionReturnValue returnValue) {
UnitVmModel model = (UnitVmModel) getWindow();
model.stopProgress();
if (returnValue != null && returnValue.getSucceeded()) {
cancel();
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.
the class TemplateListModel method onSave.
private void onSave() {
final UnitVmModel model = (UnitVmModel) getWindow();
if (!model.validate()) {
return;
}
final String name = model.getName().getEntity();
boolean isBaseTemplate = false;
if (model.getBehavior().isExistingTemplateBehavior()) {
isBaseTemplate = ((TemplateVmModelBehavior) model.getBehavior()).getVmTemplate().isBaseTemplate();
} else if (model.getBehavior().isBlankTemplateBehavior()) {
isBaseTemplate = true;
}
if (isBaseTemplate) {
AsyncDataProvider.getInstance().isTemplateNameUnique(new AsyncQuery<>(isNameUnique -> {
if (model.getBehavior().isExistingTemplateBehavior()) {
selectedItem = ((TemplateVmModelBehavior) model.getBehavior()).getVmTemplate();
} else {
selectedItem = ((ExistingBlankTemplateModelBehavior) model.getBehavior()).getVmTemplate();
}
if (!isNameUnique && name.compareToIgnoreCase(selectedItem.getName()) != 0) {
model.getName().getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason());
model.getName().setIsValid(false);
model.setValidTab(TabName.GENERAL_TAB, false);
model.fireValidationCompleteEvent();
return;
}
String selectedCpu = model.getCustomCpu().getSelectedItem();
if (selectedCpu != null && !selectedCpu.isEmpty() && !model.getCustomCpu().getItems().contains(selectedCpu)) {
ConfirmationModel confirmModel = new ConfirmationModel();
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().vmUnsupportedCpuTitle());
confirmModel.setMessage(ConstantsManager.getInstance().getConstants().vmUnsupportedCpuMessage());
confirmModel.setHelpTag(HelpTag.edit_unsupported_cpu);
// $NON-NLS-1$
confirmModel.setHashName("edit_unsupported_cpu");
confirmModel.getCommands().add(// $NON-NLS-1$
new UICommand("postNameUniqueCheck", TemplateListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
confirmModel.getCommands().add(// $NON-NLS-1$
UICommand.createCancelUiCommand("CancelConfirmation", TemplateListModel.this));
setConfirmWindow(confirmModel);
} else {
postNameUniqueCheck();
}
}), name, model.getSelectedDataCenter() == null ? null : model.getSelectedDataCenter().getId());
} else {
postNameUniqueCheck();
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel in project ovirt-engine by oVirt.
the class TemplateListModel method createVMFromTemplate.
private void createVMFromTemplate() {
VmTemplate template = getSelectedItem();
final List<UICommand> commands = new ArrayList<>();
// $NON-NLS-1$
commands.add(UICommand.createDefaultOkUiCommand("OnSaveVm", this));
// $NON-NLS-1$
commands.add(UICommand.createCancelUiCommand("Cancel", this));
AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(withVmInit -> setupNewVmModel(new UnitVmModel(new NewVmFromTemplateModelBehavior(withVmInit), TemplateListModel.this), withVmInit.getVmType(), commands)), template.getId());
}
Aggregations