use of org.ovirt.engine.ui.uicommonweb.UICommand 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.UICommand 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.UICommand in project ovirt-engine by oVirt.
the class TabModelProvider method modelBoundWidgetChange.
/**
* Called when the widget-model property of a model is changed
* TODO this seems important. What does it do? What is a widget model?
*/
@SuppressWarnings("unchecked")
void modelBoundWidgetChange() {
UICommand lastExecutedCommand = getModel().getLastExecutedCommand();
ModelBoundPresenterWidget<?> modelBoundPresenterWidget = getModelBoundWidget(lastExecutedCommand);
((ModelBoundPresenterWidget<Model>) modelBoundPresenterWidget).init(getModel().getWidgetModel());
}
use of org.ovirt.engine.ui.uicommonweb.UICommand 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.UICommand in project ovirt-engine by oVirt.
the class DataCenterGuideModel method updateAddAndSelectHostAvailability.
private void updateAddAndSelectHostAvailability(List<VDS> hosts, List<VDS> availableHosts) {
// $NON-NLS-1$
UICommand addHostAction = new UICommand("AddHost", this);
addHostAction.setIsExecutionAllowed(clusters.size() > 0);
if (hosts.isEmpty()) {
addHostAction.setTitle(DataCenterConfigureHostsAction);
getCompulsoryActions().add(addHostAction);
} else {
addHostAction.setTitle(DataCenterAddAnotherHostAction);
getOptionalActions().add(addHostAction);
}
// Select host action.
// $NON-NLS-1$
UICommand selectHostAction = new UICommand("SelectHost", this);
// If now compatible hosts are found - disable the select host button
selectHostAction.setIsChangeable(availableHosts.size() > 0);
selectHostAction.setIsExecutionAllowed(availableHosts.size() > 0);
if (clusters.size() > 0) {
if (hosts.isEmpty()) {
selectHostAction.setTitle(DataCenterSelectHostsAction);
getCompulsoryActions().add(selectHostAction);
} else {
selectHostAction.setTitle(DataCenterSelectHostsAction);
getOptionalActions().add(selectHostAction);
}
}
}
Aggregations