use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class StorageSnapshotListModel method onRemove.
private void onRemove() {
ConfirmationModel model = (ConfirmationModel) getWindow();
ArrayList<ActionParametersBase> paramerterList = new ArrayList<>();
Map<Guid, List<Guid>> diskImageIdsMap = groupImageIdsByDiskId(getSelectedItems());
for (List<Guid> imageIds : diskImageIdsMap.values()) {
RemoveDiskSnapshotsParameters parameters = new RemoveDiskSnapshotsParameters(new ArrayList<>(imageIds));
paramerterList.add(parameters);
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.RemoveDiskSnapshots, paramerterList, result -> {
StorageSnapshotListModel localModel = (StorageSnapshotListModel) result.getState();
localModel.stopProgress();
cancel();
}, this);
}
use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class ConsoleModel method displayConsoleConnectConfirmPopup.
private void displayConsoleConnectConfirmPopup(final UICommand onConfirmCommand) {
ConfirmationModel model = new ConfirmationModel();
parentModel.setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().confirmConsoleConnect());
model.setHelpTag(HelpTag.confirm_console_connect);
// $NON-NLS-1$
model.setHashName("confirm_console_connect");
model.setMessage(ConstantsManager.getInstance().getConstants().confirmConsoleConnectMessage());
UICommand confirmAndCloseCommand = new UICommand("Confirm", new // $NON-NLS-1$
BaseCommandTarget() {
@Override
public void executeCommand(UICommand uiCommand) {
onConfirmCommand.execute();
parentModel.setWindow(null);
}
});
confirmAndCloseCommand.setTitle(ConstantsManager.getInstance().getConstants().ok());
confirmAndCloseCommand.setIsDefault(true);
model.getCommands().add(confirmAndCloseCommand);
UICommand cancelCommand = new UICommand("Cancel", new // $NON-NLS-1$
BaseCommandTarget() {
@Override
public void executeCommand(UICommand uiCommand) {
parentModel.setWindow(null);
}
});
cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel());
cancelCommand.setIsCancel(true);
model.getCommands().add(cancelCommand);
}
use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class ConsoleModelErrorEventListener method consoleModelError.
private void consoleModelError(Object sender, String message) {
ConfirmationModel model = new ConfirmationModel();
if (parentModel.getConfirmWindow() == null) {
parentModel.setConfirmWindow(model);
}
model.setTitle(ConstantsManager.getInstance().getConstants().consoleDisconnectedTitle());
model.setHelpTag(HelpTag.console_disconnected);
// $NON-NLS-1$
model.setHashName("console_disconnected");
model.setMessage(message);
// $NON-NLS-1$
UICommand tempVar = new UICommand("CancelError", this);
tempVar.setTitle(ConstantsManager.getInstance().getConstants().close());
tempVar.setIsDefault(true);
tempVar.setIsCancel(true);
model.getCommands().add(tempVar);
}
use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class ModelBoundPopupHandler method handleWindowModelChange.
/**
* Handles the change of given property (as defined by {@code propertyName})
* for the given model.
* <p>
* {@code currentPopup} represents the GWTP popup instance associated with the
* property (can be {@code null} to indicate that the associated popup is not
* active at the moment).
* <p>
* {@code isConfirmation} is used to differentiate between "Window"-like and
* "ConfirmWindow"-like properties:
* <ul>
* <li>"Window"-like properties have popups resolved via
* {@link ModelBoundPopupResolver#getModelPopup} method</li>
* <li>"ConfirmWindow"-like properties have popups resolved via
* {@link ModelBoundPopupResolver#getConfirmModelPopup} method</li>
* </ul>
*/
@SuppressWarnings("unchecked")
void handleWindowModelChange(M sourceModel, String propertyName, AbstractModelBoundPopupPresenterWidget<?, ?> currentPopup, boolean isConfirmation) {
// Model behind the popup
Model windowModel = isConfirmation ? sourceModel.getConfirmWindowProperties().get(propertyName) : sourceModel.getWindowProperties().get(propertyName);
// Reveal new popup
if (windowModel != null && currentPopup == null) {
// 1. Resolve
AbstractModelBoundPopupPresenterWidget<?, ?> newPopup = null;
UICommand lastExecutedCommand = sourceModel.getLastExecutedCommand();
if (windowModel instanceof ConfirmationModel) {
// Resolve confirmation popup
newPopup = popupResolver.getConfirmModelPopup(sourceModel, lastExecutedCommand);
if (newPopup == null && defaultConfirmPopupProvider != null) {
// Fall back to basic confirmation popup
newPopup = defaultConfirmPopupProvider.get();
}
} else {
// Resolve main popup
newPopup = popupResolver.getModelPopup(sourceModel, lastExecutedCommand, windowModel);
}
// 2. Reveal
if (newPopup != null) {
revealAndAssignPopup(windowModel, propertyName, (AbstractModelBoundPopupPresenterWidget<Model, ?>) newPopup, isConfirmation);
} else {
if (isConfirmation) {
sourceModel.setConfirmWindowProperty(propertyName, null);
} else {
sourceModel.setWindowProperty(propertyName, null);
}
}
} else // Close existing popup
if (windowModel == null && currentPopup != null) {
hideAndClearPopup(propertyName, currentPopup, isConfirmation);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method onSaveSanStorage.
private void onSaveSanStorage() {
ConfirmationModel confirmationModel = (ConfirmationModel) getConfirmWindow();
if (confirmationModel != null && !confirmationModel.validate()) {
return;
}
cancelConfirm();
getWindow().startProgress();
StorageModel model = (StorageModel) getWindow();
SanStorageModelBase sanModel = (SanStorageModelBase) model.getCurrentStorageItem();
VDS host = model.getHost().getSelectedItem();
boolean force = sanModel.isForce();
HashSet<String> lunIds = new HashSet<>();
for (LunModel lun : sanModel.getAddedLuns()) {
lunIds.add(lun.getLunId());
}
AddSANStorageDomainParameters params = new AddSANStorageDomainParameters(storageDomain);
params.setVdsId(host.getId());
params.setLunIds(new HashSet<>(lunIds));
params.setForce(force);
Frontend.getInstance().runAction(ActionType.AddSANStorageDomain, params, result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
StorageModel storageModel = (StorageModel) dataCenterGuideModel.getWindow();
StoragePool dataCenter = storageModel.getDataCenter().getSelectedItem();
if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
ActionReturnValue returnValue = result.getReturnValue();
Guid storageId = returnValue.getActionReturnValue();
dataCenterGuideModel.attachStorageToDataCenter(storageId, dataCenter.getId());
}
dataCenterGuideModel.onFinish(dataCenterGuideModel.context, true, dataCenterGuideModel.storageModel);
}, this);
}
Aggregations