use of org.ovirt.engine.ui.uicommonweb.UICommand in project ovirt-engine by oVirt.
the class StorageListModel method remove.
private void remove() {
if (getWindow() != null) {
return;
}
final RemoveStorageModel model = new RemoveStorageModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().removeStoragesTitle());
model.setHelpTag(HelpTag.remove_storage);
// $NON-NLS-1$
model.setHashName("remove_storage");
StorageDomain storage = getSelectedItem();
boolean localFsOnly = storage.getStorageType() == StorageType.LOCALFS;
AsyncDataProvider.getInstance().getHostsForStorageOperation(new AsyncQuery<>(hosts -> {
model.getHostList().setItems(hosts);
model.getHostList().setSelectedItem(Linq.firstOrNull(hosts));
if (hosts.isEmpty()) {
// $NON-NLS-1$
UICommand tempVar = createCancelCommand("Cancel");
tempVar.setIsDefault(true);
model.getCommands().add(tempVar);
} else {
UICommand command;
// $NON-NLS-1$
command = UICommand.createDefaultOkUiCommand("OnRemove", StorageListModel.this);
model.getCommands().add(command);
// $NON-NLS-1$
command = createCancelCommand("Cancel");
model.getCommands().add(command);
}
}), null, localFsOnly);
}
use of org.ovirt.engine.ui.uicommonweb.UICommand in project ovirt-engine by oVirt.
the class StorageListModel method forceCreationWarning.
private void forceCreationWarning(ArrayList<String> usedLunsMessages) {
StorageModel storageModel = (StorageModel) getWindow();
SanStorageModelBase sanStorageModelBase = (SanStorageModelBase) storageModel.getCurrentStorageItem();
sanStorageModelBase.setForce(true);
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().forceStorageDomainCreation());
model.setMessage(ConstantsManager.getInstance().getConstants().lunsAlreadyInUse());
model.setHelpTag(HelpTag.force_storage_domain_creation);
// $NON-NLS-1$
model.setHashName("force_storage_domain_creation");
model.setItems(usedLunsMessages);
// $NON-NLS-1$
UICommand command = UICommand.createDefaultOkUiCommand("OnSaveSanStorage", this);
model.getCommands().add(command);
// $NON-NLS-1$
command = createCancelCommand("CancelConfirm");
model.getCommands().add(command);
}
use of org.ovirt.engine.ui.uicommonweb.UICommand 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.UICommand 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());
}
use of org.ovirt.engine.ui.uicommonweb.UICommand in project ovirt-engine by oVirt.
the class TemplateListModel method vmInitLoaded.
private void vmInitLoaded(VmTemplate template) {
UnitVmModel model = createModel(createBehavior(template));
model.setIsAdvancedModeLocalStorageKey(getEditTemplateAdvancedModelKey());
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().editTemplateTitle());
model.setHelpTag(HelpTag.edit_template);
// $NON-NLS-1$
model.setHashName("edit_template");
model.getVmType().setSelectedItem(template.getVmType());
model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
model.initialize();
VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
switchModeCommand.init(model);
model.getCommands().add(switchModeCommand);
// $NON-NLS-1$
UICommand onSaveCommand = UICommand.createDefaultOkUiCommand("OnSave", this);
model.getCommands().add(onSaveCommand);
// $NON-NLS-1$
UICommand cancelCommand = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(cancelCommand);
model.getIsHighlyAvailable().setEntity(template.isAutoStartup());
if (template.getDefaultDisplayType() == DisplayType.none) {
model.getIsHeadlessModeEnabled().setEntity(true);
}
}
Aggregations