use of org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand 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.VmBasedWidgetSwitchModeCommand 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);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand in project ovirt-engine by oVirt.
the class VmBaseListModel method setupNewVmModel.
protected void setupNewVmModel(UnitVmModel model, VmType vmtype, List<UICommand> uiCommands) {
model.setTitle(ConstantsManager.getInstance().getConstants().newVmTitle());
model.setHelpTag(HelpTag.new_vm);
// $NON-NLS-1$
model.setHashName("new_vm");
model.setIsNew(true);
model.getVmType().setSelectedItem(vmtype);
model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
// $NON-NLS-1$
model.setIsAdvancedModeLocalStorageKey("wa_vm_dialog");
setWindow(model);
model.initialize();
VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
switchModeCommand.init(model);
model.getCommands().add(switchModeCommand);
model.getProvisioning().setEntity(true);
for (UICommand uicommand : uiCommands) {
model.getCommands().add(uicommand);
}
model.initForemanProviders(null);
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand in project ovirt-engine by oVirt.
the class PoolListModel method edit.
public void edit() {
final VmPool pool = getSelectedItem();
if (getWindow() != null) {
return;
}
final PoolListModel poolListModel = this;
Frontend.getInstance().runQuery(QueryType.GetVmDataByPoolId, new IdQueryParameters(pool.getVmPoolId()), new AsyncQuery<QueryReturnValue>(result -> {
final VM vm = result.getReturnValue();
final ExistingPoolModelBehavior behavior = new ExistingPoolModelBehavior(vm, pool);
behavior.getPoolModelBehaviorInitializedEvent().addListener((ev, sender, args) -> {
final PoolModel model = behavior.getModel();
for (EntityModel<VmPoolType> item : model.getPoolType().getItems()) {
if (item.getEntity() == pool.getVmPoolType()) {
model.getPoolType().setSelectedItem(item);
break;
}
}
String cdImage = null;
if (vm != null) {
model.getDataCenterWithClustersList().setSelectedItem(null);
model.getDataCenterWithClustersList().setSelectedItem(Linq.firstOrNull(model.getDataCenterWithClustersList().getItems(), new Linq.DataCenterWithClusterPredicate(vm.getStoragePoolId(), vm.getClusterId())));
model.getTemplateWithVersion().setIsChangeable(false);
cdImage = vm.getIsoPath();
model.getVmType().setSelectedItem(vm.getVmType());
} else {
model.getDataCenterWithClustersList().setSelectedItem(Linq.firstOrNull(model.getDataCenterWithClustersList().getItems()));
}
model.getDataCenterWithClustersList().setIsChangeable(vm == null);
boolean hasCd = !StringHelper.isNullOrEmpty(cdImage);
model.getCdImage().setIsChangeable(hasCd);
model.getCdAttached().setEntity(hasCd);
model.getProvisioning().setIsChangeable(false);
model.getStorageDomain().setIsChangeable(false);
});
PoolModel model = new PoolModel(behavior);
model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
// $NON-NLS-1$
model.setIsAdvancedModeLocalStorageKey("wa_pool_dialog");
setWindow(model);
VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
switchModeCommand.init(model);
model.getCommands().add(switchModeCommand);
// $NON-NLS-1$
UICommand command = UICommand.createDefaultOkUiCommand("OnSave", poolListModel);
model.getCommands().add(command);
// $NON-NLS-1$
model.getCommands().add(UICommand.createCancelUiCommand("Cancel", poolListModel));
model.setTitle(ConstantsManager.getInstance().getConstants().editPoolTitle());
model.setHelpTag(HelpTag.edit_pool);
// $NON-NLS-1$
model.setHashName("edit_pool");
model.initialize();
model.getName().setEntity(pool.getName());
model.getDescription().setEntity(pool.getVmPoolDescription());
model.getComment().setEntity(pool.getComment());
model.getPoolStateful().setEntity(pool.isStateful());
model.getAssignedVms().setEntity(pool.getAssignedVmsCount());
model.getPrestartedVms().setEntity(pool.getPrestartedVms());
// $NON-NLS-1$
model.setPrestartedVmsHint("0-" + pool.getAssignedVmsCount());
model.getMaxAssignedVmsPerUser().setEntity(pool.getMaxAssignedVmsPerUser());
}));
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.VmBasedWidgetSwitchModeCommand in project ovirt-engine by oVirt.
the class PoolListModel method newEntity.
public void newEntity() {
if (getWindow() != null) {
return;
}
PoolModel model = new PoolModel(new NewPoolModelBehavior());
model.setIsNew(true);
model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
// $NON-NLS-1$
model.setIsAdvancedModeLocalStorageKey("wa_pool_dialog");
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().newPoolTitle());
model.setHelpTag(HelpTag.new_pool);
// $NON-NLS-1$
model.setHashName("new_pool");
model.getVmType().setSelectedItem(VmType.Desktop);
model.initialize();
VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
switchModeCommand.init(model);
model.getCommands().add(switchModeCommand);
// $NON-NLS-1$
UICommand command = UICommand.createDefaultOkUiCommand("OnSave", this);
model.getCommands().add(command);
// $NON-NLS-1$
model.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Aggregations