use of org.ovirt.engine.ui.uicompat.EventArgs in project ovirt-engine by oVirt.
the class RoleListModel method eventRaised.
@Override
public void eventRaised(Event ev, Object sender, EventArgs args) {
super.eventRaised(ev, sender, args);
if (getWindow() != null && sender == ((RoleModel) getWindow()).getIsAdminRole()) {
if (commandType == CommandType.New) {
List<ActionGroup> selectedActionGroups = new ArrayList<>();
selectedActionGroups.add(ActionGroup.LOGIN);
setAttachedActionGroups(selectedActionGroups);
} else {
Role role = getSelectedItem();
Frontend.getInstance().runQuery(QueryType.GetRoleActionGroupsByRoleId, new IdQueryParameters(role.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
publicAttachedActions = returnValue.getReturnValue();
setAttachedActionGroups(publicAttachedActions);
}));
}
}
}
use of org.ovirt.engine.ui.uicompat.EventArgs in project ovirt-engine by oVirt.
the class HeaderPresenterWidget method onBind.
@SuppressWarnings("unchecked")
@Override
protected void onBind() {
super.onBind();
registerHandler(getView().getLogoutLink().addClickHandler(event -> user.logout()));
registerHandler(getView().getGuideLink().addClickHandler(event -> WebUtils.openUrlInNewWindow(windowName, guideUrl)));
registerHandler(getView().getOptionsLink().addClickHandler(event -> {
OptionsModel model = optionsProvider.getModel();
model.executeCommand(model.getEditCommand());
}));
registerHandler(getView().getAboutLink().addClickHandler(event -> RevealRootPopupContentEvent.fire(HeaderPresenterWidget.this, aboutPopupProvider.get())));
registerHandler(getView().getTasksWidget().addClickHandler(event -> toggleOverlayPresenter(tasksPresenter)));
registerHandler(getView().getBookmarkLink().addClickHandler(event -> toggleOverlayPresenter(bookmarksPresenter)));
registerHandler(getView().getTagsLink().addClickHandler(event -> toggleOverlayPresenter(tagsPresenter)));
getView().getAlertActionWidget().addAction(constants.dismissAlert(), this.alertModelProvider.getModel().getDismissCommand(), (command, log) -> {
AlertListModel model = alertModelProvider.getModel();
if (log != null) {
model.setSelectedItem(log);
model.executeCommand(command);
}
});
getView().getAlertActionWidget().addClearAllAction(constants.clearAllDismissedAlerts(), this.alertModelProvider.getModel().getClearAllCommand(), (command, log) -> alertModelProvider.getModel().executeCommand(command));
getView().getAlertActionWidget().addRestoreAllAction(constants.displayAllDismissedAlerts(), this.alertModelProvider.getModel().getDisplayAllCommand(), (command, log) -> alertModelProvider.getModel().executeCommand(command));
getView().getEventActionWidget().addAction(constants.dismissEvent(), this.eventModelProvider.getModel().getDismissCommand(), (command, log) -> {
EventListModel<?> model = eventModelProvider.getModel();
if (log != null) {
model.setSelectedItem(log);
model.executeCommand(command);
}
});
getView().getEventActionWidget().addClearAllAction(constants.clearAllDismissedEvents(), this.eventModelProvider.getModel().getClearAllCommand(), (command, log) -> eventModelProvider.getModel().executeCommand(command));
getView().getEventActionWidget().addRestoreAllAction(constants.displayAllDismissedEvents(), this.eventModelProvider.getModel().getDisplayAllCommand(), (command, log) -> eventModelProvider.getModel().executeCommand(command));
taskModelProvider.getModel().getItemsChangedEvent().addListener(new IEventListener<EventArgs>() {
@Override
public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
Collection<Job> jobs = taskModelProvider.getModel().getItems();
long count = jobs.stream().filter(job -> JobExecutionStatus.STARTED.equals(job.getStatus())).count();
// I know I will never have more than 100 items, so I can cast to int.
getView().setRunningTaskCount((int) count);
}
});
alertModelProvider.getModel().getItemsChangedEvent().addListener(new IEventListener<EventArgs>() {
@Override
public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
Collection<AuditLog> alerts = alertModelProvider.getModel().getItems();
long count = alerts.stream().filter(alert -> AuditLogSeverity.ALERT.equals(alert.getSeverity())).count();
// I know I will never have more than 100 items, so I can cast to int.
getView().setAlertCount((int) count);
}
});
}
use of org.ovirt.engine.ui.uicompat.EventArgs in project ovirt-engine by oVirt.
the class TasksPresenterWidget method onBind.
@SuppressWarnings("unchecked")
@Override
public void onBind() {
super.onBind();
taskModelProvider.getModel().getItemsChangedEvent().addListener(new IEventListener<EventArgs>() {
@Override
public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
getView().updateTaskStatus(taskModelProvider.getModel());
Collection<Job> jobs = taskModelProvider.getModel().getItems();
jobs.forEach(job -> {
String id = job.getCorrelationId().startsWith(TaskListModel.WEBADMIN) ? job.getCorrelationId() : job.getId().toString();
if (JobExecutionStatus.STARTED.equals(job.getStatus())) {
// Since its a set, it will be replaced when its a duplicate.
runningTasks.add(id);
} else if (JobExecutionStatus.FINISHED.equals(job.getStatus()) || JobExecutionStatus.FAILED.equals(job.getStatus()) || JobExecutionStatus.ABORTED.equals(job.getStatus())) {
if (runningTasks.contains(id) || (ACTION_TYPE_WHITELIST.contains(job.getActionType()) && job.getEndTime().after(lastNotificationDate))) {
ToastNotification notification = ToastNotification.createNotification(// $NON-NLS-1$
getPrefixText(job.getStatus()) + " " + job.getDescription());
notification.setStatus(getNotificationStatus(job.getStatus()));
}
runningTasks.remove(id);
}
lastNotificationDate = new Date();
});
}
});
}
use of org.ovirt.engine.ui.uicompat.EventArgs in project ovirt-engine by oVirt.
the class HostPopupView method edit.
@Override
public void edit(final HostModel object) {
driver.edit(object);
setTabIndexes(0);
object.getFetchResult().getEntityChangedEvent().addListener((ev, sender, args) -> {
String fetchResultText = object.getFetchResult().getEntity();
if (ConstantsManager.getInstance().getConstants().errorLoadingFingerprint().equals(fetchResultText)) {
fetchResult.addStyleName(style.fetchResultErrorLabel());
} else {
fetchResult.removeStyleName(style.fetchResultErrorLabel());
}
fetchResult.setText(fetchResultText);
});
object.getPkSection().getPropertyChangedEvent().addListener((ev, sender, args) -> {
if ("IsAvailable".equals(args.propertyName)) {
// $NON-NLS-1$
setPkPasswordSectionVisiblity(false);
}
});
object.getProviders().getSelectedItemChangedEvent().addListener((ev, sender, args) -> object.updateHosts());
object.getExternalHostProviderEnabled().getEntityChangedEvent().addListener((ev, sender, args) -> {
boolean showForemanProviders = object.getExternalHostProviderEnabled().getEntity();
boolean doProvisioning = object.externalProvisionEnabled();
boolean isProvisioned = showForemanProviders && doProvisioning;
providersEditor.setVisible(showForemanProviders);
// showing or hiding radio buttons
provisionedHostSection.setVisible(isProvisioned);
discoveredHostSection.setVisible(isProvisioned);
// disabling ip and name textbox when using provisioned hosts
hostAddressEditor.setEnabled(!isProvisioned);
hostAddressLabel.setStyleName(OvirtCss.LABEL_DISABLED, isProvisioned);
if (isProvisioned) {
object.updateHosts();
object.getIsDiscoveredHosts().setEntity(true);
} else {
if (doProvisioning) {
object.cleanHostParametersFields();
}
hideProviderWidgets(object);
object.getIsDiscoveredHosts().setEntity(null);
}
});
object.getIsDiscoveredHosts().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (object.getIsDiscoveredHosts().getEntity() != null) {
if (object.getIsDiscoveredHosts().getEntity()) {
rbDiscoveredHost.asRadioButton().setValue(true);
showDiscoveredHostsWidgets(true);
} else if (!object.getIsDiscoveredHosts().getEntity()) {
rbProvisionedHost.asRadioButton().setValue(true);
showProvisionedHostsWidgets(true);
}
}
});
nameEditor.asValueBox().addKeyDownHandler(event -> Scheduler.get().scheduleDeferred(() -> {
if (object.getExternalHostProviderEnabled().getEntity() && Boolean.TRUE.equals(object.getIsDiscoveredHosts().getEntity())) {
ExternalHostGroup dhg = (ExternalHostGroup) object.getExternalHostGroups().getSelectedItem();
if (dhg != null) {
String base = nameEditor.asEditor().getSubEditor().getValue();
if (base == null) {
base = constants.empty();
}
String generatedHostName = // $NON-NLS-1$
base + "." + (dhg.getDomainName() != null ? dhg.getDomainName() : constants.empty());
object.getHost().setEntity(generatedHostName);
}
}
}));
if (object.isPasswordSectionViewable()) {
rbPassword.setValue(true);
rbPassword.setFocus(true);
fetchSshFingerprint.hideLabel();
object.setAuthenticationMethod(AuthenticationMethod.Password);
displayPassPkWindow(true);
rbPassword.addClickHandler(event -> {
object.setAuthenticationMethod(AuthenticationMethod.Password);
displayPassPkWindow(true);
});
rbPublicKey.addClickHandler(event -> {
object.setAuthenticationMethod(AuthenticationMethod.PublicKey);
displayPassPkWindow(false);
});
} else {
passwordSection.getElement().getStyle().setDisplay(Display.NONE);
rbPublicKey.getElement().getStyle().setDisplay(Display.NONE);
rbPublicKeyLabel.setStyleName(OvirtCss.LABEL_DISABLED);
object.setAuthenticationMethod(AuthenticationMethod.PublicKey);
}
updateHostsButton.setResource(resources.searchButtonImage());
// Create SPM related controls.
IEventListener<EventArgs> spmListener = (ev, sender, args) -> createSpmControls(object);
object.getSpmPriority().getItemsChangedEvent().addListener(spmListener);
object.getSpmPriority().getSelectedItemChangedEvent().addListener(spmListener);
createSpmControls(object);
initExternalHostProviderWidgets(object.showExternalProviderPanel());
// TODO: remove setIsChangeable when configured ssh username is enabled
userNameEditor.setEnabled(false);
networkProviderTab.setVisible(object.showNetworkProviderTab());
networkProviderWidget.edit(object.getNetworkProviderModel());
this.fenceAgentsEditor.edit(object.getFenceAgentListModel());
this.proxySourceEditor.edit(object.getPmProxyPreferencesList());
addTextAndLinkAlert(fetchPanel, constants.fetchingHostFingerprint(), object.getSSHFingerPrint());
providerSearchFilterLabel.setText(constants.hostPopupProviderSearchFilter());
nameEditor.setFocus(true);
hostedEngineTab.setVisible(object.getIsHeSystem() && object.getIsNew());
object.getHostedEngineWarning().getPropertyChangedEvent().addListener((ev, sender, args) -> {
EntityModel entity = (EntityModel) sender;
if ("IsAvailable".equals(args.propertyName)) {
// $NON-NLS-1$
hostedEngineWarningLabel.setVisible(entity.getIsAvailable());
}
});
affinityLabelSelectionWidget.init(object.getLabelList());
}
use of org.ovirt.engine.ui.uicompat.EventArgs in project ovirt-engine by oVirt.
the class NetworkModel method createDefaultProfile.
private VnicProfileModel createDefaultProfile() {
final VnicProfileModel defaultProfile = new NewVnicProfileModel();
// make sure default profile's name is in sync with network's name
defaultProfile.getName().setEntity(getName().getEntity());
final IEventListener<EventArgs> networkNameListener = (ev, sender, args) -> defaultProfile.getName().setEntity(getName().getEntity());
getName().getEntityChangedEvent().addListener(networkNameListener);
// if user overrides default name, stop tracking network's name
defaultProfile.getName().getEntityChangedEvent().addListener(new IEventListener<EventArgs>() {
@Override
public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
String defaultProfileName = defaultProfile.getName().getEntity();
if ((defaultProfileName != null) && (!defaultProfileName.equals(getName().getEntity()))) {
getName().getEntityChangedEvent().removeListener(networkNameListener);
defaultProfile.getName().getEntityChangedEvent().removeListener(this);
}
}
});
return defaultProfile;
}
Aggregations